CI: ogni lavoro «immagine» pota ciò che nessuno usa, il lunedì tutto
Alla fine di ogni lavoro «immagine» di verifica e rilascio, dopo la pulizia dell'esecuzione, gira pulizia-docker.sh penzolanti: le immagini senza nome e la cache penzolante del demone se ne vanno subito invece di aspettare il lunedì, e un errore resta un avviso, così il lavoro non diventa rosso per la pulizia. pulizia.yml passa al modo «completa» e, a mano, ha la casella «Solo prova» (input booleano: Gitea 28 lo mette nell'evento come «true» o «false»), con cui elenca che cosa toglierebbe e non tocca nulla: da lanciare prima della prima pulizia vera. Il passo riceve REGISTRY_TOKEN, l'indirizzo dell'API e il proprietario per le etichette del registro. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f11fc5220
commit
016bbf73eb
4 files changed
+80
-15
No files matched your search
@@ -74,6 +74,38 @@ public sealed partial class PipelineTests
|
||||
StringAssert.Contains(Script("versioni-registro.js"), "/^sha-[0-9a-f]{7,40}$/");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EveryImageJobEndsByPruningWhatNobodyUsesAndThatNeverFailsTheJob()
|
||||
{
|
||||
foreach (var name in new[] { "verifica.yml", "rilascio.yml" })
|
||||
{
|
||||
var cleanup = Step(Job(Workflow(name), "immagine"), "Pulizia (sempre)");
|
||||
StringAssert.Contains(cleanup, "if: always()", name);
|
||||
var own = cleanup.IndexOf("bash .gitea/scripts/pulizia-docker.sh esecuzione \"$ESECUZIONE\"", StringComparison.Ordinal);
|
||||
var everyone = cleanup.IndexOf("bash .gitea/scripts/pulizia-docker.sh penzolanti || echo \"::warning::", StringComparison.Ordinal);
|
||||
Assert.IsTrue(own >= 0 && everyone > own, $"{name}: after the cleanup of the run, and a failure is only a warning");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheWeeklyCleanupIsCompleteAndCanBeTriedFirstWithoutRemovingAnything()
|
||||
{
|
||||
var weekly = Workflow("pulizia.yml");
|
||||
StringAssert.Contains(weekly, "schedule:\n - cron: \"17 4 * * 1\"");
|
||||
StringAssert.Contains(weekly, " workflow_dispatch:\n inputs:\n prova:\n");
|
||||
var input = weekly[weekly.IndexOf(" prova:\n", StringComparison.Ordinal)..weekly.IndexOf("\npermissions:", StringComparison.Ordinal)];
|
||||
StringAssert.Contains(input, "type: boolean", "Gitea 28 shows a checkbox and puts \"true\" or \"false\" in the event");
|
||||
StringAssert.Contains(input, "default: false", "by hand the cleanup is real unless the box is ticked");
|
||||
|
||||
var step = Step(Job(weekly, "docker"), "Pulizia completa del demone Docker e del registro");
|
||||
StringAssert.Contains(step, "PROVA: ${{ gitea.event.inputs.prova }}");
|
||||
StringAssert.Contains(step, "REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}");
|
||||
StringAssert.Contains(step, "GITEA_API: ${{ gitea.server_url }}/api/v1");
|
||||
StringAssert.Contains(step, "PROPRIETARIO: ${{ gitea.repository_owner }}");
|
||||
StringAssert.Contains(step, "if [ \"${PROVA:-}\" = true ]; then\n bash .gitea/scripts/pulizia-docker.sh completa --prova\n else\n bash .gitea/scripts/pulizia-docker.sh completa\n");
|
||||
Assert.DoesNotContain("settimanale", Code(weekly), "the weekly cleanup is the complete one");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(300_000, CooperativeCancellation = true)]
|
||||
public async Task OnADaemonSharedWithARealFebeTheCleanupOfTheCiTakesOnlyWhatTheCiMade()
|
||||
|
||||
Reference in new issue
Block a user