From 56fd29be807bea6dc7a08a7dcbf2f4566dddbc51 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 20 Oct 2026 12:04:42 +0200 Subject: [PATCH] CI: se la cima di main non si legge, avviso e pubblicazione della sola :sha- Il passo di pubblicazione gira con bash -e -o pipefail: un errore di git ls-remote chiudeva il passo prima dell'avviso previsto, e il lavoro immagine di main diventava rosso senza pubblicare nemmeno :sha-. Ora l'assegnazione ha un ripiego vuoto e si arriva all'avviso, come promettono il commento e docs/decisioni.md. Rilievo ls-remote-set-e della revisione. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/verifica.yml | 4 +++- tests/Febe.Tests/Packaging/PipelineTests.cs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/verifica.yml b/.gitea/workflows/verifica.yml index 862b077..93885f0 100644 --- a/.gitea/workflows/verifica.yml +++ b/.gitea/workflows/verifica.yml @@ -282,7 +282,9 @@ jobs: mv "$CONFIG/config.json.nuovo" "$CONFIG/config.json" NOMI=("$IMAGE:sha-${GITHUB_SHA::7}") # :main solo se main è ancora a questo commit: un'esecuzione arrivata in ritardo non lo riporta indietro. - CIMA=$(git ls-remote origin refs/heads/main 2> /dev/null | cut -f1) + # Il passo gira con «bash -e -o pipefail»: senza «|| CIMA=""» un errore di ls-remote chiuderebbe il passo + # prima dell'avviso, e non uscirebbe nemmeno la :sha-. + CIMA=$(git ls-remote origin refs/heads/main 2> /dev/null | cut -f1) || CIMA="" if [ "$CIMA" = "$GITHUB_SHA" ]; then NOMI+=("$IMAGE:main") elif [ -z "$CIMA" ]; then diff --git a/tests/Febe.Tests/Packaging/PipelineTests.cs b/tests/Febe.Tests/Packaging/PipelineTests.cs index 0f11e54..dae448b 100644 --- a/tests/Febe.Tests/Packaging/PipelineTests.cs +++ b/tests/Febe.Tests/Packaging/PipelineTests.cs @@ -95,6 +95,7 @@ public sealed partial class PipelineTests StringAssert.Contains(publish, "\"$IMAGE:sha-${GITHUB_SHA::7}\""); StringAssert.Contains(publish, "\"$IMAGE:main\""); StringAssert.Contains(publish, "bash .gitea/scripts/costruisci-immagine.sh pubblica"); + StringAssert.Contains(publish, "| cut -f1) || CIMA=\"\"", "under bash -e an unreadable main must reach the warning and still publish :sha-"); Assert.DoesNotContain(":latest", Code(Workflow("verifica.yml")), ":latest belongs to the release"); // Built with buildx, tried without a network and scanned before anything is published; always cleaned up.