diff --git a/.github/workflows/post-testing-e2e.yml b/.github/workflows/post-testing-e2e.yml index 7bbfcc48..3febeb57 100644 --- a/.github/workflows/post-testing-e2e.yml +++ b/.github/workflows/post-testing-e2e.yml @@ -16,9 +16,21 @@ 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 + 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" - name: Download all flavor digests env: GH_TOKEN: ${{ github.token }} @@ -27,6 +39,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 +49,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":