Repository navigation
refactor(flavors): make flavors.py the only flavor-to-image-name map - #44
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
The mapping was written three times: the IMAGE dict in scripts/flavors.py, the case in the `image_name` recipe, and a second identical case inside build-ghcr. gen-sbom and secureboot already delegate to `image_name`; build-ghcr -- the recipe that actually tags and pushes the image -- did not. These copies are read on different paths, which is what makes the duplication dangerous rather than merely untidy. `flavors.py images` and `flavors.py releases` feed the promote and release matrices; `image_name` and build-ghcr decide what the build tags and pushes. A disagreement between them does not fail the build. It produces a build that pushes one name and a promote matrix that looks for another, surfacing a workflow later as a tag that reusable-promote-squash cannot find. Both cases now call a new `flavors.py image FLAVOR`, which resolves against the configured flavor set -- so it rejects a flavor that is absent from config/flavors.json, not merely one absent from a case arm. `just check` already refused flavored image names under .github/workflows/, but never scanned the Justfile, where two of the three copies lived. That guard is extended to the Justfile; it was confirmed to fail against the case statements this commit removes. A `flavors.py count` query is added here for the promotion gate, which is the subject of a separate issue. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hanthor
left a comment
There was a problem hiding this comment.
The red check is pre-existing, and the static gate that matters passed
Recording this so the failing Build Utah isn't held against the change. This PR's run 34026114549, job build_main / image:
install: cannot create regular file '/usr/local/libexec/utah-install-packages': No such file or directory
Error: building at STEP "RUN for pair in install-packages.py:utah-install-packages ..."
error: recipe `build-ghcr` failed with exit code 1
Identical failure on the unmodified base — main@636b48e, run 34654001732, same step, same message. This is Containerfile:81 (#55/#56), not anything in this PR, which touches only Justfile and scripts/flavors.py.
The contract job — which runs just check and therefore the new flavor-literal guard — passed. For a PR whose entire surface is a Justfile recipe and a Python CLI, that is the job that matters, and it is green.
The reasoning in the description is the strongest part. The point that copies 1 and 2/3 are read on different paths, so a disagreement doesn't fail the build but instead produces a push to utah-<a> while the promote matrix looks for utah-<b>, surfacing a workflow later inside reusable-promote-squash as a missing tag — that is a correct and non-obvious failure analysis. Resolving image against the configured flavor set rather than a case arm is the right strengthening, since it catches a flavor missing from config/flavors.json rather than merely one missing from a shell branch.
Confirmed the Justfile really did carry two independent copies of the mapping on main (image_name, and build-ghcr with its own case), and that just check's existing guard only scanned .github/workflows/ — so two of the three copies were never covered. Extending it to the Justfile closes the actual hole.
Conflicts with #64 — these two were designed as a pair and both grew the same half
#64 also adds flavors.py count and also adds guards to the check recipe. They collide:
$ git apply /tmp/pr64.diff && git apply --check /tmp/pr44.diff
error: patch failed: Justfile:79
error: Justfile: patch does not applyThis PR's "Not included" section explains why: the post-testing-e2e.yml fix was left out because the agent App token lacked workflows permission, with flavors.py count added here as groundwork. #64 is that follow-up — but it added its own count rather than depending on this one.
Cleanest sequence is #44 first, then #64 rebased to drop its duplicate flavors.py hunk and keep only the workflow edit plus guard. Worth noting #40 also touches the check recipe and adds tests for flavors.py, so it is a third party to the same region; if #40 lands first, count gets test coverage for free.
Two small things
The commented-out assertion. Leaving the post-testing-e2e.yml guard commented in place rather than silently omitting it is the right instinct. But a commented assertion is invisible to just check and easy to lose — worth making sure #42/#64 actually uncomments it rather than writing a third version.
Base branch is testing, not main. This PR targets testing while #64, #40 and most of the queue target main. Given sync-main-to-testing.yml pushes main → testing, landing this on testing first means it arrives on main only via the promotion path. Worth confirming that is intended, since the Justfile changes it makes are wanted on both.
Both hold and the red base are what's actually blocking here; the change itself looks sound.
Generated by Claude Code
|
Closing: this conflicts with Generated by Claude Code |
Collapses the flavor → image-name mapping onto
scripts/flavors.py, the file that already declares itself the single source for the flavor set.What was wrong
The mapping was written three times:
scripts/flavors.pyIMAGEdictJustfileimage_namegen-sbom,secureboot, reusable build workflowJustfilebuild-ghcr(identical case, not a call to #2)gen-sbomandsecurebootalready delegate toimage_name.build-ghcr— the recipe that tags and pushes the image — carried its own copy.The duplication is dangerous rather than merely untidy because copies 1 and 2/3 are read on different paths. A disagreement does not fail the build: it produces a build that pushes
utah-<a>while the promote matrix looks forutah-<b>, and the failure surfaces one workflow later insidereusable-promote-squashas a tag that does not exist.What this does
flavors.py image FLAVOR. It resolves against the configured flavor set, so it rejects a flavor missing fromconfig/flavors.json— not merely one missing from acasearm, which is what the old code checked.image_nameandbuild-ghcrboth call it. Copies 2 and 3 are gone.flavors.py count, needed by the promotion-gate fix ([architect] :testing promotion gate hardcodes the flavor count — a fifth literal outside config/flavors.json #42).just checkguard. It already refused flavored image names under.github/workflows/, but never scanned theJustfile— where two of the three copies lived. The guard skips its owngreplines, which necessarily quote the names.Verification
The new guard was confirmed to fail against the case statements this PR removes, and to pass after. Behaviour is unchanged for all four current flavors.
Not included
The related fix to
.github/workflows/post-testing-e2e.yml— which hardcodestest "$count" -eq 4— is not in this PR. The agent App token lacks theworkflowspermission and the push is rejected.flavors.py countis added here so that fix is a two-line change once a human can push it. Ajust checkassertion for it is left commented in place rather than silently omitted.Closes #43. Groundwork for #42.
🛑 hold — for maintainer review.