From 98df8fb8aa2836af4850a4de8b1579af747f7c53 Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 11 Sep 2026 11:53:34 -0400 Subject: [PATCH 1/2] ci: derive testing promotion flavor count Signed-off-by: Danathar --- .github/workflows/post-testing-e2e.yml | 9 ++++++++- Justfile | 2 ++ scripts/flavors.py | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/post-testing-e2e.yml b/.github/workflows/post-testing-e2e.yml index 7bbfcc48..17434021 100644 --- a/.github/workflows/post-testing-e2e.yml +++ b/.github/workflows/post-testing-e2e.yml @@ -16,9 +16,15 @@ jobs: github.event.workflow_run.head_branch == 'testing' runs-on: ubuntu-latest permissions: + contents: read packages: write actions: read steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + - name: Resolve the expected image count + id: flavors + run: echo "count=$(python3 scripts/flavors.py count)" >> "$GITHUB_OUTPUT" - name: Download all flavor digests env: GH_TOKEN: ${{ github.token }} @@ -27,6 +33,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} REGISTRY: ghcr.io/${{ github.repository_owner }} + EXPECTED: ${{ steps.flavors.outputs.count }} run: | set -euo pipefail echo "$GH_TOKEN" | skopeo login ghcr.io --username "${{ github.actor }}" --password-stdin @@ -36,4 +43,4 @@ jobs: skopeo copy --all "docker://${REGISTRY}/${name}@${digest}" "docker://${REGISTRY}/${name}:testing" count=$((count + 1)) done < <(find /tmp/digests -name '*.txt' -exec cat {} +) - test "$count" -eq 4 + test "$count" -eq "$EXPECTED" diff --git a/Justfile b/Justfile index 6706129f..32eb866c 100644 --- a/Justfile +++ b/Justfile @@ -79,6 +79,8 @@ check: <(grep -m1 '^ARG BASE_IMAGE=' Containerfile.kernel) python3 -m py_compile scripts/flavors.py python3 scripts/flavors.py list >/dev/null + ! grep -nE 'count" -eq [0-9]' .github/workflows/post-testing-e2e.yml + grep -q 'flavors.py count' .github/workflows/post-testing-e2e.yml pip install --quiet pyyaml 2>/dev/null || true python3 scripts/check_workflow_outputs.py pip install --quiet jsonschema 2>/dev/null || true diff --git a/scripts/flavors.py b/scripts/flavors.py index e6f03d0a..fc243d3e 100755 --- a/scripts/flavors.py +++ b/scripts/flavors.py @@ -11,6 +11,7 @@ next to the list rather than in a commit message. flavors.py list ["main"] + flavors.py count 1 flavors.py images [{"image": "utah"}, ...] promote flavors.py releases [{"image": "utah", "source_tag": ...}, ...] release flavors.py needs-kernel true / false @@ -37,6 +38,8 @@ what = sys.argv[1] if len(sys.argv) > 1 else "list" if what == "list": print(json.dumps(flavors)) +elif what == "count": + print(len(flavors)) elif what == "images": print(json.dumps([{"image": IMAGE[f]} for f in flavors])) elif what == "releases": From ffff479a30bae2653309f146f8431ea5721cb55d Mon Sep 17 00:00:00 2001 From: Danathar Date: Sat, 12 Sep 2026 10:10:53 +0000 Subject: [PATCH 2/2] fix(ci): checkout the promoted commit, not the default branch hanthor's review on #64 found that the workflow_run trigger's checkout step had no ref:, so it resolved main (the default branch) rather than the commit that produced the images being promoted to testing. The if: already gates on head_branch == 'testing', so the flavor count and the digests being promoted could silently come from two different commits -- latent today since main and testing agree, but wrong precisely when a flavor-set change makes them disagree, which is the scenario this count exists to catch. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01LNgJ8VMdoqzGequbxsP2Kc --- .github/workflows/post-testing-e2e.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/post-testing-e2e.yml b/.github/workflows/post-testing-e2e.yml index 17434021..3febeb57 100644 --- a/.github/workflows/post-testing-e2e.yml +++ b/.github/workflows/post-testing-e2e.yml @@ -22,6 +22,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + # workflow_run has no ref: default; without this, checkout resolves + # the default branch instead of the commit that produced the images + # being promoted, so the flavor count and the digests being + # promoted could come from two different commits. + ref: ${{ github.event.workflow_run.head_sha }} - name: Resolve the expected image count id: flavors run: echo "count=$(python3 scripts/flavors.py count)" >> "$GITHUB_OUTPUT"