Publish the image on version tags and test what is delivered

A v* tag now builds, tries and publishes the image: the version must be the
one of Directory.Build.props, latest only moves forward and the registry
token is in one step, given to docker on its input. The same script works by
hand. The image says its version and commit, and its health check also
covers the engine loop and the live prices.

The Unraid template is final: a test compares it with appendix E and with
the variables the loader really reads, and another reads the workflow.

refs #70
refs #71

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 19:21:40 +01:00
1 parent 4d92a39fef
commit 3cd214ae78
16 files changed
+859 -27

No files matched your search

+32 -1
View File
@@ -39,7 +39,7 @@ internal static partial class Endpoints
Forms.Map(app);
}
// Healthy only when the database answers and the scheduler loop is alive (SPEC 15.2); the body says why not.
// Healthy only when the database answers, the loops turn and the prices arrive (SPEC 15.2); the body says why not.
private static async Task<IResult> HealthAsync(AnubisHost host, CancellationToken cancellationToken)
{
var status = host.Status;
@@ -62,6 +62,11 @@ internal static partial class Endpoints
checks["scheduler"] = host.SchedulerRunning ? "ok" : "fermo";
healthy &= host.SchedulerRunning;
var (loop, loopOk) = HealthRules.Loop(host.Clock.UtcNow, services.Trading is { IsStarted: true }, services.Trading?.LastTurnAt);
var (feed, feedOk) = HealthRules.Feed(host.Clock.UtcNow, services.MarketData?.LiveFeed.Since, services.MarketData?.LiveFeed.LastDataAt);
checks["motore"] = loop;
checks["dati"] = feed;
healthy &= loopOk && feedOk;
}
var body = new HealthResponse(healthy ? "ok" : "unavailable", AnubisInfo.Name, AnubisInfo.Version, status.Mode.ToString(), checks);
@@ -500,3 +505,29 @@ internal static partial class Endpoints
given is not null && expected is not null &&
CryptographicOperations.FixedTimeEquals(SHA256.HashData(Encoding.UTF8.GetBytes(given)), SHA256.HashData(Encoding.UTF8.GetBytes(expected)));
}
/// <summary>What the health check of the container says about the engine's loop and the live prices (SPEC 15.2).</summary>
internal static class HealthRules
{
/// <summary>The same silence after which the guard steps in (SPEC 9.3).</summary>
public static readonly TimeSpan LoopLimit = TimeSpan.FromMinutes(2);
/// <summary>Longer than the silence that blocks new entries (SPEC 6.5): a line that drops for a moment is not an ill container.</summary>
public static readonly TimeSpan FeedLimit = TimeSpan.FromMinutes(5);
public static (string Text, bool Ok) Loop(DateTimeOffset now, bool started, DateTimeOffset? lastTurn) => (started, lastTurn) switch
{
(false, _) => ("non avviato", true),
(_, null) => ("in avvio", true),
(_, { } at) when now - at > LoopLimit => ("fermo", false),
_ => ("ok", true),
};
public static (string Text, bool Ok) Feed(DateTimeOffset now, DateTimeOffset? since, DateTimeOffset? lastData) => (since, lastData) switch
{
(null, _) => ("in attesa", true),
({ } from, null) when now - from <= FeedLimit => ("in attesa", true),
(_, { } at) when now - at <= FeedLimit => ("ok", true),
_ => ("fermi", false),
};
}
+12 -3
View File
@@ -147,9 +147,18 @@ internal sealed record SystemView(
? new SystemPart("Prezzi di mercato", "aggiornati " + Ago(now - at), now - at > TimeSpan.FromMinutes(5) ? PartState.Warn : PartState.Ok)
: new SystemPart("Prezzi di mercato", "in attesa dei primi prezzi", PartState.Off));
// News arrive with phase 7 (SPEC 10).
parts.Add(new SystemPart("Lettura delle notizie", "non ancora attiva", PartState.Off));
tiles.Add(new SystemPart("Notizie", "non ancora attive", PartState.Off));
// The news sources read every two minutes (SPEC 4.4): the ones the user left on, and when one last answered.
var read = market is null || market.Offline ? [] : (await market.News.Store.ListSourcesAsync(cancellationToken).ConfigureAwait(false)).Where(s => s.Enabled).ToList();
var heard = read.Max(s => s.LastOkAt);
var (newsText, newsState) = (read.Count, heard) switch
{
(0, _) => ("spenta", PartState.Off),
(_, null) => ("in attesa della prima lettura", PartState.Off),
(_, { } last) when now - last > TimeSpan.FromMinutes(30) => ("le fonti non rispondono, ultima lettura " + When(last, now, zone) + ": riprovo da solo", PartState.Warn),
(_, { } last) => ($"{read.Count} fonti, ultima lettura {When(last, now, zone)}", PartState.Ok),
};
parts.Add(new SystemPart("Lettura delle notizie", newsText, newsState));
tiles.Add(new SystemPart("Notizie", heard is { } h ? "lette " + When(h, now, zone) : newsText, newsState));
// The database: engine, size, last backup.
var engine = services.Db.Engine == DbEngine.Postgres ? "PostgreSQL" : "SQLite";