Repository navigation
fix(ci): a matrix job's per-leg names cannot be required status checks - #365
Merged
Merged
Conversation
I made `plan (state-backend)`, `plan (core)`, `plan (dev)` and `plan (prod)` required in #360's follow-up. The next non-infra PR — #359, the agentic workflows — went unmergeable, with all four stuck on "Expected — waiting for status to be reported", and the four contexts have been removed from branch protection to unblock it. The behaviour, stated exactly, because it is genuinely surprising: While a matrix job RUNS it reports one check-run per leg — `plan (core)`, `plan (dev)`, … — which look like perfectly good contexts. When the job is SKIPPED by its `if:`, GitHub reports a single check-run under the literal, uninterpolated name `plan (${{ matrix.key }})`. So per-leg contexts never report at all on a PR that skips the tier, and a required context that never reports blocks the PR forever — the same failure mode as a `paths:` filter, which is precisely what this workflow's `detect` job exists to avoid. I replaced one trap with another wearing a different hat. `fmt + validate (credential-free)` was fine throughout, and the contrast is the diagnosis: it is not a matrix job, so it reports `skipped` under its own name and branch protection accepts that. The fix is a non-matrix aggregator, `terraform plan`, which `needs: plan` and inspects `needs.plan.result` — the aggregate, `success` only if every leg succeeded. It reports `skipped` when the tier is skipped, so it is safe to require in the legs' place. Two details in it: - `skipped` is ACCEPTED. Exactly one thing produces it: a fork PR, which is issued no `id-token` and so cannot assume the plan role (the `plan` job skips itself for that reason). Treating it as failure would make every fork PR unmergeable — this same bug pointed the other way. - anything unrecognised, including an empty result, FAILS. Verified against all five values `needs.*.result` can take. Documented where the next person will hit it: the `ci-and-supply-chain` skill now carries it as the third `name:`-is-a-context failure mode, and the generated job table — which displays `plan (${{ matrix.key }})` verbatim, i.e. the trap itself — gained a preamble line saying a context containing `${{ matrix.* }}` cannot be required. Nothing is added to branch protection here. That comes after this reports green on `main`, which is the only safe order. One bug caught while verifying, in the gate's own message: a backticked word inside a double-quoted shell string is command substitution, so the first draft ran `validate` and printed its empty output in place of the word. Single-quoted now. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
terraform plan
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I made
plan (state-backend),plan (core),plan (dev)andplan (prod)required after #360. The next non-infra PR — #359, the agentic workflows — went unmergeable with all four stuck on "Expected — waiting for status to be reported". The four contexts are already removed from branch protection, so #359 is unblocked; this PR is the proper fix.The behaviour, stated exactly
While a matrix job runs, it reports one check-run per leg —
plan (core),plan (dev), … — which look like perfectly good contexts. When the job is skipped by itsif:, GitHub reports a single check-run under the literal, uninterpolated nameplan (${{ matrix.key }}).Observed on #359's head:
So the per-leg contexts never report at all on a PR that skips the tier — and a required context that never reports blocks the PR forever. That is the same failure mode as a
paths:filter, which is precisely what this workflow'sdetectjob exists to avoid. I replaced one trap with another wearing a different hat.fmt + validate (credential-free)was fine throughout, and the contrast is the diagnosis: it isn't a matrix job, so it reportsskippedunder its own name and branch protection accepts that.The fix
A non-matrix aggregator job, context
terraform plan, whichneeds: planand inspectsneeds.plan.result— the aggregate,successonly if every leg succeeded. Being non-matrix, it reportsskippedwhen the tier is skipped, so it's safe to require in the legs' place.Two details:
skippedis accepted. Exactly one thing produces it: a fork PR, which is issued noid-tokenand so cannot assume the plan role at all (theplanjob skips itself for that reason). Treating it as a failure would make every fork PR unmergeable — this same bug pointed the other way.Verified against all five values
needs.*.resultcan take, by extracting the step's shell from the YAML:needs.plan.resultsuccessskippedfailurecancelledDocumented where the next person hits it
The
ci-and-supply-chainskill now carries this as the third "a job'sname:is its context" failure mode, alongside renaming and adding-before-it-exists. And the generated job table — which displaysplan (${{ matrix.key }})verbatim, i.e. the trap itself — gained a preamble line saying a context containing${{ matrix.* }}cannot be required and to require an aggregator instead.Branch protection is not touched here
That comes after this reports green on
main— the only safe order. The intended end state for infra is three contexts, all non-matrix:fmt + validate (credential-free)(already required),terraform plan, andterraform ci helpers (self-test).One bug caught while verifying, in the gate's own message: a backticked word inside a double-quoted shell string is command substitution, so the first draft ran
validateand printed its empty output in place of the word. Single-quoted now.required-checks.mdandskills-check.shwill conflict with #359 — both PRs touch them. Whoever merges second re-runsscripts/skills-check.sh regen.🤖 Generated with Claude Code