refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
1 parent
c99842cc86
commit
f2b58522b9
1801 files changed
+11804
-10676
No files matched your search
@@ -0,0 +1,109 @@
|
||||
using Chronos.Data.Postgres;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Infrastructure;
|
||||
|
||||
/// <summary>Engine a dialect-parameterised test class runs against.</summary>
|
||||
public enum Backend
|
||||
{
|
||||
SqliteMemory,
|
||||
SqliteFile,
|
||||
Postgres,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The PostgreSQL server named by <c>CHRONOS_TEST_PG</c>. Every test gets its own schema (selected through
|
||||
/// <c>Search Path</c>), so classes run in parallel without seeing each other's tables.
|
||||
/// </summary>
|
||||
internal static class PgTestServer
|
||||
{
|
||||
public const string Variable = "CHRONOS_TEST_PG";
|
||||
|
||||
private static readonly Lazy<PostgresDatabase> Admin = new(() =>
|
||||
new PostgresDatabase(PostgresSettings.Parse(ConnectionString) with { MaxPoolSize = 4 }));
|
||||
|
||||
public static string ConnectionString =>
|
||||
Environment.GetEnvironmentVariable(Variable) is { Length: > 0 } cs ? cs : throw new SkipException($"{Variable} not set");
|
||||
|
||||
/// <summary>A connection string for another role (MD5, cleartext, trust tests), or a skip when not configured.</summary>
|
||||
public static string Optional(string variable) =>
|
||||
Environment.GetEnvironmentVariable(variable) is { Length: > 0 } cs ? cs : throw new SkipException($"{variable} not set");
|
||||
|
||||
/// <summary>Set to 1 where the server was set up with TLS (CI): a server that refuses TLS then fails the TLS tests.</summary>
|
||||
public const string TlsVariable = "CHRONOS_TEST_PG_TLS";
|
||||
|
||||
public static bool TlsExpected => Environment.GetEnvironmentVariable(TlsVariable) is "1" or "true";
|
||||
|
||||
public static async Task<string> CreateSchemaAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var name = "chronos_t_" + Guid.NewGuid().ToString("N")[..16];
|
||||
await using var session = await Admin.Value.OpenAsync(cancellationToken);
|
||||
await session.ExecuteScriptAsync($"CREATE SCHEMA {name}", cancellationToken);
|
||||
return name;
|
||||
}
|
||||
|
||||
public static async Task DropSchemaAsync(string name)
|
||||
{
|
||||
await using var session = await Admin.Value.OpenAsync(CancellationToken.None);
|
||||
await session.ExecuteScriptAsync($"DROP SCHEMA IF EXISTS {name} CASCADE", CancellationToken.None);
|
||||
}
|
||||
|
||||
public static string With(string connectionString, string extra) => connectionString.TrimEnd(';', ' ') + ";" + extra;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base of tests that run against a fresh database per test: an in-memory or temporary-file SQLite database, or
|
||||
/// a private schema on the PostgreSQL test server. Everything opened through it is disposed after the test.
|
||||
/// </summary>
|
||||
public abstract class DatabaseTest(TestContext context) : IAsyncDisposable
|
||||
{
|
||||
private readonly List<IAsyncDisposable> _owned = [];
|
||||
private readonly List<string> _schemas = [];
|
||||
|
||||
protected TestContext Context => context;
|
||||
|
||||
protected CancellationToken Ct => context.Cancellation;
|
||||
|
||||
protected abstract Backend Backend { get; }
|
||||
|
||||
protected Dialect Dialect => Backend == Backend.Postgres ? Dialect.Postgres : Dialect.Sqlite;
|
||||
|
||||
/// <summary>Picks the DDL/SQL variant of the current dialect.</summary>
|
||||
protected string ForDialect(string sqlite, string postgres) => Dialect == Dialect.Postgres ? postgres : sqlite;
|
||||
|
||||
/// <summary>Options for a new empty database; <paramref name="multiConnection"/> forces a SQLite file (pooled readers).</summary>
|
||||
protected async Task<DatabaseOptions> NewOptionsAsync(bool multiConnection = false, string? extraPostgres = null)
|
||||
{
|
||||
switch (Backend)
|
||||
{
|
||||
case Backend.SqliteMemory when !multiConnection:
|
||||
return DatabaseOptions.SqliteInMemory();
|
||||
case Backend.SqliteMemory or Backend.SqliteFile:
|
||||
return DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory(), "chronos.db"));
|
||||
default:
|
||||
var schema = await PgTestServer.CreateSchemaAsync(Ct);
|
||||
_schemas.Add(schema);
|
||||
var cs = PgTestServer.With(PgTestServer.ConnectionString, $"Search Path={schema};Maximum Pool Size=12");
|
||||
return DatabaseOptions.Postgres(extraPostgres is null ? cs : PgTestServer.With(cs, extraPostgres));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Opens a bare database (no migrations).</summary>
|
||||
protected async Task<IDatabase> OpenDatabaseAsync(bool multiConnection = false)
|
||||
{
|
||||
var database = DatabaseFactory.Open(await NewOptionsAsync(multiConnection));
|
||||
return Own(database);
|
||||
}
|
||||
|
||||
protected T Own<T>(T disposable) where T : IAsyncDisposable
|
||||
{
|
||||
_owned.Add(disposable);
|
||||
return disposable;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
for (var i = _owned.Count - 1; i >= 0; i--) await _owned[i].DisposeAsync();
|
||||
foreach (var schema in _schemas) await PgTestServer.DropSchemaAsync(schema);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Infrastructure;
|
||||
|
||||
/// <summary>Base of repository tests: a migrated <see cref="ChronosDatabase"/> per test.</summary>
|
||||
public abstract class RepositoryTest(TestContext context) : DatabaseTest(context)
|
||||
{
|
||||
/// <summary>Opens a fresh migrated database; <paramref name="multiConnection"/> forces a SQLite file.</summary>
|
||||
protected async Task<ChronosDatabase> OpenChronosAsync(bool multiConnection = false) =>
|
||||
Own(await ChronosDatabase.OpenAsync(await NewOptionsAsync(multiConnection), Ct));
|
||||
}
|
||||
|
||||
/// <summary>Builders of valid entities with distinct ids; override fields with <c>with</c>.</summary>
|
||||
internal static class TestData
|
||||
{
|
||||
/// <summary>A fixed reference instant (microsecond precision, like the databases).</summary>
|
||||
public static readonly DateTimeOffset Now = new(2026, 10, 2, 9, 0, 0, TimeSpan.Zero);
|
||||
|
||||
public static Archive Archive(string name = "Main") => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Name = name,
|
||||
RootPath = "/archive/" + name,
|
||||
Created = Now,
|
||||
};
|
||||
|
||||
public static Sequence Sequence(Guid archiveId, DateTime? firstCapture = null, string? title = null, string camera = "EOS R5") => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ArchiveId = archiveId,
|
||||
Title = title,
|
||||
Folder = $"2026/{Guid.NewGuid():N}",
|
||||
CameraMake = "Canon",
|
||||
CameraModel = camera,
|
||||
FirstCapture = firstCapture,
|
||||
LastCapture = firstCapture?.AddHours(1),
|
||||
UpdatedAt = Now,
|
||||
};
|
||||
|
||||
public static Frame Frame(Guid sequenceId, int index, DateTime? capturedAt = null) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
SequenceId = sequenceId,
|
||||
Index = index,
|
||||
RelativePath = $"2026/seq/originals/IMG_{index:0000}.CR3",
|
||||
FileName = $"IMG_{index:0000}.CR3",
|
||||
Size = 25_000_000 + index,
|
||||
Sha256 = Convert.ToHexStringLower(BitConverter.GetBytes((long)index)).PadLeft(64, '0'),
|
||||
CapturedAt = capturedAt ?? new DateTime(2026, 9, 28, 18, 0, 0).AddSeconds(5 * index),
|
||||
TimestampSource = TimestampSource.ExifOriginal,
|
||||
ExposureTime = 1 / 250.0,
|
||||
FNumber = 8,
|
||||
Iso = 100,
|
||||
FocalLength = 24,
|
||||
Width = 8192,
|
||||
Height = 5464,
|
||||
Format = ImageFileFormat.Cr3,
|
||||
};
|
||||
|
||||
public static Job Job(JobKind kind = JobKind.Scan, JobPriority priority = JobPriority.Normal, DateTimeOffset? created = null) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = kind,
|
||||
Priority = priority,
|
||||
State = JobState.Queued,
|
||||
Created = created ?? Now,
|
||||
};
|
||||
|
||||
public static User User(string username = "alice") => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Username = username,
|
||||
PasswordHash = "pbkdf2-sha512$210000$salt$hash",
|
||||
Role = UserRole.Editor,
|
||||
Permissions = RolePermissions.Default(UserRole.Editor),
|
||||
Created = Now,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user