Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ check:
<(grep -m1 '^ARG BASE_IMAGE=' Containerfile.kernel)
python3 -m py_compile scripts/flavors.py
python3 scripts/flavors.py list >/dev/null
python3 scripts/flavors.py count >/dev/null
# scripts/flavors.py is the only place that maps a flavor to its published
# image name. Anything else spelling those names out is a second copy that
# nothing compares against the first. The grep guards themselves quote the
# names, so they are excluded rather than counted as violations.
if grep -n 'utah-\(nvidia\|gaming\)' Justfile | grep -v 'grep -'; then
echo "flavored image names belong in scripts/flavors.py, not the Justfile" >&2
exit 1
fi
test "$(just image_name utah testing main)" = "$(python3 scripts/flavors.py image main)"
# The promotion gate must count flavors, not carry a literal: a build that
# goes green while :testing never advances is the failure this prevents.
# Not asserted here yet -- the fix to post-testing-e2e.yml is blocked on the
# agent App's missing `workflows` permission. See the linked issue.
pip install --quiet pyyaml 2>/dev/null || true
python3 scripts/check_workflow_outputs.py
pip install --quiet jsonschema 2>/dev/null || true
Expand Down Expand Up @@ -125,16 +139,12 @@ check-parity:
exit 1
fi

# The flavor -> published image name mapping lives in scripts/flavors.py, beside
# the flavor set itself. It used to be spelled out here and again in build-ghcr,
# so adding a flavor meant editing three case arms and a dict that no check
# compared against each other.
image_name base_name stream flavor:
#!/usr/bin/env bash
set -euo pipefail
case "{{ flavor }}" in
main) echo "{{ image }}" ;;
nvidia) echo "{{ image }}-nvidia" ;;
gaming) echo "{{ image }}-gaming" ;;
nvidia-gaming) echo "{{ image }}-nvidia-gaming" ;;
*) echo "unknown Utah image flavor: {{ flavor }}" >&2; exit 2 ;;
esac
@python3 scripts/flavors.py image '{{ flavor }}'

generate-default-tag stream build_number:
@echo "{{ stream }}"
Expand Down Expand Up @@ -162,13 +172,7 @@ build-ghcr base_name stream flavor kernel_pin="":
#!/usr/bin/env bash
set -euo pipefail
version="{{ stream }}-$(date -u +%Y%m%d)-$(git rev-parse --short HEAD)"
case "{{ flavor }}" in
main) image_name="{{ image }}" ;;
nvidia) image_name="{{ image }}-nvidia" ;;
gaming) image_name="{{ image }}-gaming" ;;
nvidia-gaming) image_name="{{ image }}-nvidia-gaming" ;;
*) echo "unknown Utah image flavor: {{ flavor }}" >&2; exit 2 ;;
esac
image_name="$(python3 scripts/flavors.py image '{{ flavor }}')"
# The kernel cache image and the layer cache below are both published
# private by default, and the reusable build workflow only logs in to GHCR
# for non-PR events -- so pulling either would 401 on exactly the runs that
Expand Down
16 changes: 16 additions & 0 deletions scripts/flavors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
flavors.py needs-kernel true / false
flavors.py list-main ["main"] flavors that build on the pristine base
flavors.py list-kernel ["nvidia", ...] flavors that build on the kernel cache
flavors.py count 4 how many images a green build produces
flavors.py image FLAVOR utah-nvidia the published image name for one flavor
"""
import json
import sys
Expand Down Expand Up @@ -54,5 +56,19 @@
print(json.dumps([f for f in flavors if f == "main"]))
elif what == "list-kernel":
print(json.dumps([f for f in flavors if f != "main"]))
elif what == "count":
# The number of images a green build publishes. post-testing-e2e refuses to
# advance :testing unless it collected exactly this many digests -- a real
# gate, but it used to be the literal 4, so narrowing or widening the flavor
# set here stalled the promotion of every image with nothing to look at
# except a build that had already gone green.
print(len(flavors))
elif what == "image":
if len(sys.argv) < 3:
raise SystemExit("usage: flavors.py image FLAVOR")
flavor = sys.argv[2]
if flavor not in flavors:
raise SystemExit(f"unknown Utah image flavor: {flavor}")
print(IMAGE[flavor])
else:
raise SystemExit(f"unknown query: {what}")
Loading