Skip to content

ci: one definition of the gate, so a tag runs what a PR runs - #500

Merged
scttfrdmn merged 3 commits into
mainfrom
ci/one-gate-definition
Sep 15, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
ci/one-gate-definition

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

The release gate was not the CI gate. It was a disjoint set.

ci.yml defined 16 jobs, release.yml defined 5, they shared not one job id, and grep -c workflow_call .github/workflows/*.yml returned 0 in every file.

So v0.14.0 was tagged and published without test, lint, coverage, fuzz-smoke, config-examples, docs-site, sdk-metrics, deploy-manifests, systemd-unit, packaging, modulefiles, labels, install-script or repo-install ever having run against it. A PR merged green and a tag cut from that same commit were verified by two different things, and only the smaller one had a say over what reached users.

The design, and why it is this one

ci.yml gains a workflow_call trigger. release.yml gains a gate job that does uses: ./.github/workflows/ci.yml.

The tempting shape — extract the jobs into a new gate.yml and have ci.yml call it too — would have blocked every pull request in the repository, indefinitely, with nothing red to point at. A workflow_call job reports its checks as <caller-job-id> / <called-job-id>, and 19 of main's 20 required contexts are pinned as literal bare strings (test, lint, coverage, config-examples, packaging, six build-tags (...), six cross-build (...), two modulefiles (...)). Extraction renames all 19 at once; a required context that never arrives is not a failing check, it is an absent one.

Making ci.yml itself the reusable workflow avoids that entirely: on push and pull_request it is still the top-level workflow, so every check name is byte-identical.

No branch-protection change is required. Nothing to run, nothing to wedge.

The only renaming happens on the tag run (gate / test, ...), where nothing is protected.

Second defect found on the way

docker-build-push had no needs: at all. On a tag it logged in to ghcr and pushed {{version}}, {{major}}.{{minor}}, {{major}} and latest in parallel with everything else — whether the tests passed, and whether the binary build passed. That is precisely the failure release.yml's own header documents for v0.10.0's empty release page, except an image, unlike a release page, cannot be un-pulled.

The gate is now a dependency of the graph's roots (build, package-linux, docker-build-push), so every job is transitively gated by construction rather than by whoever adds the next one remembering to.

Per-job reasoning

All 16 jobs are in the gate, and that is a decision rather than a default — the long comment at the top of ci.yml records the check. There is not one github.event.* reference in the file; the complete expression set is env.GO_VERSION_FILE, github.base_ref || ..., github.ref, github.workflow, matrix.* and secrets.GITHUB_TOKEN, all of which resolve on a tag. Two carry a caveat stated rather than hidden:

  • lint gates on --new-from-merge-base=origin/$base_ref, and base_ref is empty outside a PR, so on a tag the blocking diff is empty. Weaker, not vacuous: golangci-lint config verify and the whole-repo count still run, and the diff was already gated at the PR. Excluding it would let a lint config that no longer parses reach a release.
  • install-script deliberately fetches the last published release, so on a tag it is one release behind. Still the right job here: it is what catches scripts/install.sh having been edited into something that cannot install anything, before that script is what the next release tells users to pipe into a shell.

Tests

internal/config/release_gate_test.go, five tests, each verified by mutation (not by prediction):

mutation test that caught it
drop workflow_call: from ci.yml TestCIWorkflowIsReusable
drop needs: gate from build TestReleaseIsGatedByCI (also flagged security-scan)
drop issues: read from the caller TestGateCallerGrantsWhatTheGateNeeds
rename modulefiles' name: TestRequiredChecksStillHaveAJobToReportThem
rename the test job id TestRequiredChecksStillHaveAJobToReportThem
release.yml restates a ci job id TestReleaseDoesNotRestateTheGate

The permissions test is the non-obvious one: a called workflow's token is derived from the caller's grants and can only be narrowed, never widened, so a missing issues: read does not fail the run — it hands labels a token that quietly cannot list labels, and the job then reports on a skip.

Two traps hit for real while writing this

  1. The mutation harness found a bug in my own test. Recording both the job id and the declared name: meant renaming modulefiles' name: still matched on the id, and that mutation passed. A job reports under name: when it has one; only one of the two is ever the check name. Fixed in the second commit — and this is exactly why the mutation run is not optional.
  2. The first draft of the ci.yml comment contained a literal empty expression-brace pair while explaining that expressions interpolate inside comments. That is the one form guaranteed to fail the entire file to parse — no job, no log, and check-yaml passes it. TestWorkflowExpressionsAreValid caught it. The comment now spells the syntax out instead of demonstrating it.

Not in this PR

goreleaser/cosign and SHA-pinning are evaluated separately, so this is mergeable on its own.

ci.yml gains a workflow_call trigger and release.yml calls it. Before this,
the two files defined disjoint job sets and neither contained the string
workflow_call, so v0.14.0 was published without test, lint, coverage,
fuzz-smoke, packaging, modulefiles, install-script or labels ever running.

ci.yml is made the reusable workflow rather than extracting a gate.yml,
because a workflow_call job reports as '<caller> / <job>' and nineteen of
main's twenty required contexts are pinned to the bare names. No branch
protection change is needed.

docker-build-push had no needs: at all and pushed to ghcr in parallel with
the build. The gate is now a dependency of the graph's roots so everything
downstream is transitively gated.
Recording both the job id and the declared name meant renaming a job's
name: still matched on the id, so the mutation that renames modulefiles
passed. A job reports under name: when it has one; only one of the two is
ever the check name.
golangci-lint's modernize analyzer is blocking on changed code, and it was right
three times. No behaviour change: `any` is an alias for `interface{}`.
@scttfrdmn
scttfrdmn merged commit 9b2fa5b into main Sep 15, 2026
43 checks passed
@scttfrdmn
scttfrdmn deleted the ci/one-gate-definition branch September 15, 2026 22:33
scttfrdmn added a commit that referenced this pull request Sep 15, 2026
CHANGELOG.md conflicted with #500's entry: both added an Unreleased section at
the same line. Resolved by keeping both, one `### Added` and one `### Fixed`, in
Keep a Changelog order. No content dropped from either side. release.yml merged
without conflict — #500 touched the job graph's `needs:`, this branch touched the
publish job's steps and permissions.
@scttfrdmn

Copy link
Copy Markdown
Owner Author

Post-merge note: the one thing this PR could not show on its own run is now measured rather than predicted.

release.yml is on: push: tags only, so the gate call itself never executes on a pull request — a green PR run proves ci.yml still works as a top-level workflow, not that it is callable. Rather than find out at the next tag, a throwaway branch carried a temporary caller (uses: ./.github/workflows/ci.yml, same permissions: block as the real gate job). Run 35030982940 started, resolved the call, and expanded to 39 jobs in exactly 16 groups:

7 gate / build-tags        1 gate / labels
1 gate / config-examples   1 gate / lint
1 gate / coverage          2 gate / modulefiles
6 gate / cross-build       1 gate / packaging
1 gate / deploy-manifests  1 gate / repo-install
1 gate / docs-site         1 gate / sdk-metrics
10 gate / fuzz-smoke       1 gate / systemd-unit
3 gate / install-script    1 gate / test

Three things that were arguments in the PR body are now observations:

  1. The call resolves. A typo in the path, or workflow_call: written in a way that does not register, would have failed at run startup — and would have done so on the tag, after the artifacts existed.
  2. All 16 job groups reach the tag path. That is the set the release was missing.
  3. The check names on that path really are gate / <job>, confirming why extracting into a separate gate.yml would have renamed all 19 bare-name required contexts at once.

The probe run was cancelled once the job list was readable, and the branch is deleted. Nothing about it survives in main.

On the same PR run, all 20 of main's required contexts reported, byte-identical, MISSING: none — so no branch-protection change was needed and none was made.

scttfrdmn added a commit that referenced this pull request Sep 15, 2026
CHANGELOG conflict only, and the two sides do not overlap: #500/#501 added
### Added and ### Fixed, this branch adds ### Changed and ### Removed. Resolved
by keeping both in Keep a Changelog order (Added, Changed, Removed, Fixed).
Verified the result is the exact union of both parents' Unreleased sections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant