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,139 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Server.Tests.Jobs;
|
||||
|
||||
[Category("server")]
|
||||
public sealed class JobApiTests(TestContext context)
|
||||
{
|
||||
[Test]
|
||||
public async Task JobsMoveThroughPauseResumeAndDone()
|
||||
{
|
||||
var handler = new BlockingJobHandler(JobKind.DeepAnalyse);
|
||||
await using var server = await TestServer.StartAsync(context, services: s => s.AddSingleton<IJobHandler>(handler));
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
||||
var sequence = await CreateSequenceAsync(editor);
|
||||
|
||||
var job = await CreateAsync(editor, "deep-analyse", sequence);
|
||||
Assert.Equal(("queued", "user", "Harbour sunset"), (job.State, job.Priority, job.TargetLabel));
|
||||
await handler.Started.Task.WaitAsync(TimeSpan.FromSeconds(10));
|
||||
await WaitForAsync(editor, job.Id, "running");
|
||||
|
||||
Assert.Equal("paused", (await ActAsync(editor, job.Id, "pause", HttpStatusCode.OK)).State);
|
||||
await WaitForAsync(editor, job.Id, "paused");
|
||||
await ActAsync(editor, job.Id, "pause", HttpStatusCode.Conflict);
|
||||
await ActAsync(editor, job.Id, "retry", HttpStatusCode.Conflict);
|
||||
|
||||
await ActAsync(editor, job.Id, "resume", HttpStatusCode.OK);
|
||||
await WaitForAsync(editor, job.Id, "running");
|
||||
handler.Release();
|
||||
var done = await WaitForAsync(editor, job.Id, "done");
|
||||
Assert.Equal((4L, 4L), (done.ProgressDone, done.ProgressTotal));
|
||||
await ActAsync(editor, job.Id, "cancel", HttpStatusCode.Conflict);
|
||||
|
||||
using var list = await editor.GetAsync("/api/v1/jobs?state=done&kind=deep-analyse");
|
||||
Assert.Equal(job.Id, (await list.ReadAsync(ProtocolJson.Default.PageJobDto)).Items.Single().Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FailedJobsRetryAndRunningJobsCancel()
|
||||
{
|
||||
var handler = new BlockingJobHandler(JobKind.Proxies) { FailWith = "decoder exploded" };
|
||||
await using var server = await TestServer.StartAsync(context, services: s => s.AddSingleton<IJobHandler>(handler));
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
||||
var sequence = await CreateSequenceAsync(editor);
|
||||
|
||||
var job = await CreateAsync(editor, "proxies", sequence);
|
||||
var failed = await WaitForAsync(editor, job.Id, "failed");
|
||||
Assert.Equal("decoder exploded", failed.Error);
|
||||
Assert.Contains("decoder exploded", failed.LogTail);
|
||||
|
||||
await ActAsync(editor, job.Id, "retry", HttpStatusCode.OK);
|
||||
await WaitForAsync(editor, job.Id, "running");
|
||||
Assert.Equal("cancelled", (await ActAsync(editor, job.Id, "cancel", HttpStatusCode.OK)).State);
|
||||
await Task.Delay(200);
|
||||
Assert.Equal("cancelled", (await GetAsync(editor, job.Id)).State);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task WaitingJobsChangePriorityAndRightsAreChecked()
|
||||
{
|
||||
var handler = new BlockingJobHandler(JobKind.Thumbs);
|
||||
await using var server = await TestServer.StartAsync(context, o => o.Parallelism = 1, s => s.AddSingleton<IJobHandler>(handler));
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
||||
var (viewer, _, _) = await server.UserAsync("marco", "viewer");
|
||||
var sequence = await CreateSequenceAsync(editor);
|
||||
|
||||
var first = await CreateAsync(editor, "thumbs", sequence);
|
||||
await WaitForAsync(editor, first.Id, "running");
|
||||
var second = await CreateAsync(editor, "thumbs", sequence);
|
||||
using (var lower = await editor.PostAsJsonAsync($"/api/v1/jobs/{second.Id}/priority", new JobPriorityRequest("background"), ProtocolJson.Default.JobPriorityRequest))
|
||||
Assert.Equal("background", (await lower.ReadAsync(ProtocolJson.Default.JobDto)).Priority);
|
||||
using (var bad = await editor.PostAsJsonAsync($"/api/v1/jobs/{second.Id}/priority", new JobPriorityRequest("urgent"), ProtocolJson.Default.JobPriorityRequest))
|
||||
await bad.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_priority");
|
||||
|
||||
using (var foreign = await viewer.PostAsync($"/api/v1/jobs/{second.Id}/cancel", null)) await foreign.ExpectErrorAsync(HttpStatusCode.Forbidden, "forbidden");
|
||||
using (var create = await viewer.PostAsJsonAsync("/api/v1/jobs", new CreateJobRequest("thumbs", [sequence], null), ProtocolJson.Default.CreateJobRequest))
|
||||
await create.ExpectErrorAsync(HttpStatusCode.Forbidden, "forbidden");
|
||||
using (var unknown = await editor.PostAsJsonAsync("/api/v1/jobs", new CreateJobRequest("teleport", [sequence], null), ProtocolJson.Default.CreateJobRequest))
|
||||
await unknown.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_job_kind");
|
||||
using (var unavailable = await editor.PostAsJsonAsync("/api/v1/jobs", new CreateJobRequest("deep-analyse", [sequence], null), ProtocolJson.Default.CreateJobRequest))
|
||||
await unavailable.ExpectErrorAsync(HttpStatusCode.Conflict, "job_unavailable");
|
||||
using (var render = await editor.PostAsJsonAsync("/api/v1/jobs", new CreateJobRequest("render", [sequence], "{}"), ProtocolJson.Default.CreateJobRequest))
|
||||
await render.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_parameters");
|
||||
|
||||
var admin = await server.AdminAsync();
|
||||
using (var removed = await admin.PostAsync($"/api/v1/jobs/{second.Id}/cancel", null)) await removed.ExpectAsync(HttpStatusCode.OK);
|
||||
handler.Release();
|
||||
await WaitForAsync(editor, first.Id, "done");
|
||||
}
|
||||
|
||||
public static async Task<Guid> CreateSequenceAsync(HttpClient client, string title = "Harbour sunset")
|
||||
{
|
||||
using var created = await client.PostAsJsonAsync("/api/v1/sequences", new CreateSequenceRequest(title, null), ProtocolJson.Default.CreateSequenceRequest);
|
||||
await created.ExpectAsync(HttpStatusCode.Created);
|
||||
return (await created.ReadAsync(ProtocolJson.Default.SequenceDto)).Id;
|
||||
}
|
||||
|
||||
public static async Task<JobDto> CreateAsync(HttpClient client, string kind, Guid target, string? parameters = null)
|
||||
{
|
||||
using var response = await client.PostAsJsonAsync("/api/v1/jobs", new CreateJobRequest(kind, [target], parameters), ProtocolJson.Default.CreateJobRequest);
|
||||
await response.ExpectAsync(HttpStatusCode.Accepted);
|
||||
return await response.ReadAsync(ProtocolJson.Default.JobDto);
|
||||
}
|
||||
|
||||
public static async Task<JobDto> GetAsync(HttpClient client, Guid id)
|
||||
{
|
||||
using var response = await client.GetAsync($"/api/v1/jobs/{id}");
|
||||
return await response.ReadAsync(ProtocolJson.Default.JobDto);
|
||||
}
|
||||
|
||||
public static async Task<JobDto> WaitForAsync(HttpClient client, Guid id, string state)
|
||||
{
|
||||
var deadline = DateTime.UtcNow.AddSeconds(15);
|
||||
while (true)
|
||||
{
|
||||
var job = await GetAsync(client, id);
|
||||
if (job.State == state) return job;
|
||||
if (DateTime.UtcNow > deadline) Assert.Fail($"Job {id} is {job.State}, expected {state}");
|
||||
await Task.Delay(50);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<JobDto> ActAsync(HttpClient client, Guid id, string action, HttpStatusCode expected)
|
||||
{
|
||||
using var response = await client.PostAsync($"/api/v1/jobs/{id}/{action}", null);
|
||||
if (expected != HttpStatusCode.OK)
|
||||
{
|
||||
await response.ExpectErrorAsync(expected, "invalid_state");
|
||||
return await GetAsync(client, id);
|
||||
}
|
||||
await response.ExpectAsync(expected);
|
||||
return await response.ReadAsync(ProtocolJson.Default.JobDto);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user