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

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:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-23 12:45:18 +02:00
1 parent c99842cc86
commit f2b58522b9
1801 files changed
+11804 -10676

No files matched your search

+186
View File
@@ -0,0 +1,186 @@
using Chronos.Data.Migrations;
using Chronos.Data.Repositories;
using Chronos.Data.Sqlite;
namespace Chronos.Data;
/// <summary>The repositories of the Chronos schema, bound either to the database (one session per call) or to one transaction.</summary>
public abstract class ChronosRepositories
{
private protected ChronosRepositories(DbAccess access)
{
Archives = new ArchiveRepository(access);
Sequences = new SequenceRepository(access);
Frames = new FrameRepository(access);
Renders = new RenderRepository(access);
Jobs = new JobRepository(access);
MediaCards = new MediaCardRepository(access);
Users = new UserRepository(access);
Tokens = new TokenRepository(access);
RenderNodes = new RenderNodeRepository(access);
Settings = new SettingsRepository(access);
Tags = new TagRepository(access);
Audit = new AuditRepository(access);
Uploads = new UploadRepository(access);
}
public ArchiveRepository Archives { get; }
public SequenceRepository Sequences { get; }
public FrameRepository Frames { get; }
public RenderRepository Renders { get; }
public JobRepository Jobs { get; }
public MediaCardRepository MediaCards { get; }
public UserRepository Users { get; }
public TokenRepository Tokens { get; }
public RenderNodeRepository RenderNodes { get; }
public SettingsRepository Settings { get; }
public TagRepository Tags { get; }
public AuditRepository Audit { get; }
public UploadRepository Uploads { get; }
}
/// <summary>
/// Entry point of the data layer: opens SQLite or PostgreSQL, migrates the schema and exposes the repositories.
/// Each repository call borrows a pooled session; use <see cref="BeginAsync"/> to group calls atomically.
/// </summary>
/// <example>
/// <code>
/// await using var db = await ChronosDatabase.OpenAsync(DatabaseOptions.Parse(connectionString), ct);
/// var page = await db.Sequences.ListAsync(new SequenceQuery { Year = 2026 }, ct);
/// await using var tx = await db.BeginAsync(ct);
/// await tx.Frames.InsertAsync(frame, ct);
/// await tx.Sequences.RefreshStatsAsync(frame.SequenceId, ct);
/// await tx.CommitAsync(ct);
/// </code>
/// </example>
public sealed class ChronosDatabase : ChronosRepositories, IAsyncDisposable
{
private ChronosDatabase(IDatabase database, int schemaVersion)
: base(new DbAccess(database))
{
Database = database;
SchemaVersion = schemaVersion;
}
/// <summary>The underlying engine, for raw sessions and engine-specific features (backups, LISTEN).</summary>
public IDatabase Database { get; }
public Dialect Dialect => Database.Dialect;
/// <summary>Schema version after migration.</summary>
public int SchemaVersion { get; private set; }
/// <summary>
/// Opens the database and applies pending migrations. Throws <see cref="SchemaTooNewException"/> when a newer
/// build already migrated it.
/// </summary>
public static async Task<ChronosDatabase> OpenAsync(DatabaseOptions options, CancellationToken cancellationToken = default)
{
var database = DatabaseFactory.Open(options);
try
{
var version = await MigrationRunner.MigrateAsync(database, cancellationToken).ConfigureAwait(false);
return new ChronosDatabase(database, version);
}
catch
{
await database.DisposeAsync().ConfigureAwait(false);
throw;
}
}
/// <summary>Starts a transaction whose repositories all run on it; dispose without committing to roll back.</summary>
public async Task<ChronosTransaction> BeginAsync(CancellationToken cancellationToken = default)
{
var session = await Database.OpenAsync(cancellationToken).ConfigureAwait(false);
try
{
return new ChronosTransaction(session, await session.BeginAsync(cancellationToken).ConfigureAwait(false));
}
catch
{
await session.DisposeAsync().ConfigureAwait(false);
throw;
}
}
/// <summary>SQLite only: writes a <c>VACUUM INTO</c> copy into <paramref name="directory"/>, keeping the newest <paramref name="keep"/>.</summary>
public Task<string> BackupAsync(string directory, int keep = 3, CancellationToken cancellationToken = default) =>
AsSqlite().BackupAsync(directory, keep, cancellationToken);
/// <summary>SQLite only: replaces the database with a backup, then migrates it to this build's schema.</summary>
public async Task RestoreAsync(string backupPath, CancellationToken cancellationToken = default)
{
await AsSqlite().RestoreAsync(backupPath, cancellationToken).ConfigureAwait(false);
SchemaVersion = await MigrationRunner.MigrateAsync(Database, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// SQLite only: the size of the database file and the bytes its free pages hold, which <see cref="VacuumAsync"/> gives
/// back; null on PostgreSQL, whose autovacuum keeps the tables compact by itself.
/// </summary>
public async Task<IndexSpace?> SpaceAsync(CancellationToken cancellationToken = default)
{
if (Dialect != Dialect.Sqlite) return null;
await using var session = await Database.OpenAsync(cancellationToken).ConfigureAwait(false);
var pageSize = await session.ScalarAsync<long>("PRAGMA page_size", [], cancellationToken).ConfigureAwait(false);
var pages = await session.ScalarAsync<long>("PRAGMA page_count", [], cancellationToken).ConfigureAwait(false);
var free = await session.ScalarAsync<long>("PRAGMA freelist_count", [], cancellationToken).ConfigureAwait(false);
return new IndexSpace(pages * pageSize, free * pageSize);
}
/// <summary>
/// SQLite only: rewrites the database without its free pages (<c>VACUUM</c>, BRIEF §12.5 Maintenance). Writers wait
/// meanwhile; readers continue on the previous snapshot. Returns the space before and after.
/// </summary>
public async Task<(IndexSpace Before, IndexSpace After)> VacuumAsync(CancellationToken cancellationToken = default)
{
AsSqlite();
var before = (await SpaceAsync(cancellationToken).ConfigureAwait(false))!;
await using (var session = await Database.OpenAsync(cancellationToken).ConfigureAwait(false))
await session.ExecuteScriptAsync("VACUUM", cancellationToken).ConfigureAwait(false);
var after = (await SpaceAsync(cancellationToken).ConfigureAwait(false))!;
return (before, after);
}
public ValueTask DisposeAsync() => Database.DisposeAsync();
private SqliteDatabase AsSqlite() =>
Database as SqliteDatabase ?? throw new NotSupportedException("Backups of a PostgreSQL database are made with the server's own tools.");
}
/// <summary>Size of an SQLite index file and the bytes of its free pages (reclaimable by a vacuum).</summary>
public sealed record IndexSpace(long FileBytes, long ReclaimableBytes);
/// <summary>Repositories bound to one open transaction.</summary>
public sealed class ChronosTransaction : ChronosRepositories, IAsyncDisposable
{
private readonly IDbTransaction _transaction;
internal ChronosTransaction(IDbSession session, IDbTransaction transaction)
: base(new DbAccess(session))
{
Session = session;
_transaction = transaction;
}
/// <summary>The session the transaction runs on, for statements of your own inside it.</summary>
public IDbSession Session { get; }
public Task CommitAsync(CancellationToken cancellationToken = default) => _transaction.CommitAsync(cancellationToken);
public Task RollbackAsync(CancellationToken cancellationToken = default) => _transaction.RollbackAsync(cancellationToken);
/// <summary>Rolls back unless committed, and returns the session to the pool.</summary>
public async ValueTask DisposeAsync()
{
try
{
await _transaction.DisposeAsync().ConfigureAwait(false);
}
finally
{
await Session.DisposeAsync().ConfigureAwait(false);
}
}
}