diff --git a/.abcd/development/release-gate/README.md b/.abcd/development/release-gate/README.md index f149d7e36c..bab4368cc0 100644 --- a/.abcd/development/release-gate/README.md +++ b/.abcd/development/release-gate/README.md @@ -13,30 +13,61 @@ Design of record: [`../plans/2026-07-11-iss35-semantic-release-gate.md`](../plan ## Deterministic gates (CI-enforced) The [`release.yml`](../../../.github/workflows/release.yml) `verify` job runs -these, in order, on Linux (`ubuntu-latest`); `ci.yml`'s `check` job gates the -merge on Linux as well. `release.yml` is authoritative; this list is the -human-readable mirror. The macOS suite runs beside `verify` on the same commit -(see *The macOS gate* below). - -1. Format (gofmt) -2. Build -3. Vet -4. Test -5. Test (race, internal) -6. Record-lint (design-record drift gate) -7. Docs-lint (docs-currency gate) -8. Reviews-charter discipline (RD001-RD004) -9. Smoke every command (self-discovering harness) -10. Plugin archive reproduces the committed pin (fail-closed) -11. The release tag names the released CHANGELOG version (fail-closed) - -Gate 11 runs on a real release only too: it refuses unless the release tag is +these, in order, on Linux (`ubuntu-latest`). `release.yml` is authoritative; +this list is the human-readable mirror. The macOS suite runs beside `verify` on +the same commit (see *The macOS gate* below). + +1. Merge queue check passed on the released commit (fail-closed) +2. Record-lint (design-record drift gate) +3. Docs-lint (docs-currency gate) +4. Reviews-charter discipline (RD001-RD004) +5. Plugin archive reproduces the committed pin (fail-closed) +6. The release tag names the released CHANGELOG version (fail-closed) + +`verify` runs no Linux test of its own. The merge queue already ran `ci.yml`'s +`check (ubuntu-latest)` job (format, build, vet, the plain and race passes) on +exactly the commit a release cuts, because the queue merges the commit it +tested, and its required `smoke` check ran beside it. Running them again cost 55 +to 85 Linux minutes a release attempt, and the only `verify` failures in a month +were flaky tests on trees the queue had passed (iss-2612031238180751). Gate 1 +reads that check instead, with the job token's `checks: read` and `actions: +read`, and admits the commit only when a check run named `check (ubuntu-latest)`, +in its latest attempt, completed with success, made by GitHub Actions, in a +check suite of this repository at the released commit, owned by a workflow run +of `.github/workflows/ci.yml` that the `merge_group` event started — and only +when that run's own latest jobs list a job of that name, on that commit, +completed with success, whose check run is that same check run. The second read +is the binding: any token holding `checks: write`, which a workflow pushed on a +branch can grant itself, can create a check run of that name and outcome on the +commit, but a check run made through the Checks API is never a job of the run. +A pull-request or dispatched run, another workflow file, another repository or +commit, a check or job that failed, was skipped or has not finished, a check run +no job of the run stands behind, a read that fails, and a commit with no such +run all refuse, before anything is checked out. A commit that never went +through the queue is the last case: a rehearsal dispatched on a branch head is +refused here by design, and one dispatched on the default branch's tip, which +the queue tested, passes. The refusal tags nothing; land the change through the +queue, and its push starts the release again. + +Gate 1 also refuses a commit carrying more than 100 GitHub Actions check suites, +more than its one read lists, rather than guess at the rest. It fails closed, so +the cost is availability: nightly and dispatched runs pile up on a default-branch +tip that does not move, so a late re-release of an old tag can meet it. + +Gate 1 reads `check (ubuntu-latest)` alone. That smoke ran on the released +commit rests on the ruleset, not on this gate: the queue merges a commit only +once every required check passed, and `smoke` is one of them +(`.abcd/work/rulesets/main-protection.json`). A ruleset change that drops `smoke` +from the required list, or adds a bypass actor, would let a commit whose smoke +never passed reach a release with nothing here noticing. + +Gate 6 runs on a real release only too: it refuses unless the release tag is `v` plus the version `record-lint --released-version` reads from the released -tree, the reader the semantic receipts are bound with. Gate 10 refuses such a -tag first on this repository's own release; gate 11 is the check a scaffolded +tree, the reader the semantic receipts are bound with. Gate 5 refuses such a +tag first on this repository's own release; gate 6 is the check a scaffolded repository, which has no archive gate, relies on (iss-2609251945586202). -Gate 10 runs on a real release only (a rehearsal has no release tag to bind). It +Gate 5 runs on a real release only (a rehearsal has no release tag to bind). It re-renders the release's plugin archive from the tagged commit and refuses unless its SHA-256 is the one the ship pinned in `.claude-plugin/marketplace.json` ([adr-2609231048308186](../decisions/adrs/2609231048308186-the-catalog-pins-the-latest-release-s.md)). @@ -108,7 +139,8 @@ repository pays for each macOS minute. ## Enforced at merge only -`verify` is a subset of what CI enforces at merge, not a substitute for it: the +`verify` reads one of the merge gate's checks and does not repeat it, and the +rest of what CI enforces at merge it does not re-check at all: the merge gate additionally runs the issue-resolution gate (RS001-RS003 plus its cases), the site-render gate, secret scanning, the workflow audit, dependency review, `govulncheck`, the attribution gate and the external review. The macOS diff --git a/.abcd/record-lint.json b/.abcd/record-lint.json index 1478251cec..6bdcca7297 100644 --- a/.abcd/record-lint.json +++ b/.abcd/record-lint.json @@ -684,7 +684,7 @@ "Set up Go", "Semantic-gate receipts (fail-closed, before tag)" ], - "min_gates": 9 + "min_gates": 6 }, "forbidden_synonyms": { "enabled": true, diff --git a/.abcd/work/issues/resolved/iss-2612031238180751-the-release-workflow-s-verify-job.md b/.abcd/work/issues/resolved/iss-2612031238180751-the-release-workflow-s-verify-job.md new file mode 100644 index 0000000000..62700a0c91 --- /dev/null +++ b/.abcd/work/issues/resolved/iss-2612031238180751-the-release-workflow-s-verify-job.md @@ -0,0 +1,17 @@ +--- +schema_version: 1 +id: "iss-2612031238180751" +slug: "the-release-workflow-s-verify-job" +severity: "minor" +category: "process" +source: "user-observation" +found_during: "manual-capture" +origin: researcher-authored +production_mode: hand-written +found_at: ".github/workflows/release.yml" +remedy: "Cut verify to its release-specific steps and, in place of the tests, require a successful check (ubuntu-latest) check run from a merge_group run of .github/workflows/ci.yml on this repository at the released sha, read in one GraphQL call with read-only scopes, refusing a sha with no such run" +resolution: "release.yml's verify job no longer runs the tests: its first step requires a successful check (ubuntu-latest) from a merge_group run of .github/workflows/ci.yml on this repository at the released commit, read in one GraphQL call with checks: read and actions: read, and refuses any other; the rest of verify is the release-specific gates" +impact: internal +--- + +The release workflow's verify job re-runs the merge queue's tests on the commit the queue already passed: lab 8 (R2) found every release run since 1 Nov ran on a head sha whose merge_group ci run had passed, verify repeating the race step, build, vet and smoke plus a plain go test on a cacheless runner, 55 to 85 Linux minutes per attempt, and all four verify failures in the window were flakes on trees the queue had passed; v0.17.1 lost three runs to them diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 4a19305281..551b7debc2 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -149,7 +149,10 @@ jobs: # transitive: release.yml in turn calls site.yml (adr-48), so this job hands # down every scope BOTH workflows' jobs need (contents/id-token/attestations: # write). The three happen to be the same set, so the site deploy widens - # nothing here. + # nothing here. The two read scopes are verify's alone: its first step reads + # the merge queue's check on the released commit (iss-2612031238180751), and + # a called job asking for a scope its caller withholds fails the whole run + # before any job starts. release: needs: detect # Run when a release is needed: a fresh version (need_tag, so release.yml @@ -160,6 +163,8 @@ jobs: contents: write # release.yml: push the new tag after verify, create the draft Release; site.yml: attach site.tar.gz and publish the Release id-token: write # release.yml + site.yml: OIDC for build-provenance attestation attestations: write # release.yml: publish + read back the attestations; site.yml: attest site.tar.gz + checks: read # release.yml verify: the released commit's check suites and check runs + actions: read # release.yml verify: the workflow run that owns each suite (its event and file) uses: ./.github/workflows/release.yml with: tag: v${{ needs.detect.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f137c2417..0fa9fa86c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,13 @@ name: release # Releases are made by auto-release from main: a merge that rolls a new dated -# CHANGELOG version calls this workflow, which first re-runs the deterministic, -# Linux-only verify gate (gofmt, build, vet, the race leg, and the -# record/docs/reviews gates — a subset of the merge gate, which is the -# authority; see the release-gate runbook for what gates the merge alone) -# against the commit being released; only if that gate is green does it tag +# CHANGELOG version calls this workflow, which first runs the verify gate +# against the commit being released: it requires the merge queue's own Linux +# check (check (ubuntu-latest), from a merge_group run of ci.yml) to have passed +# on that commit, in place of running the tests again, and then runs the steps +# particular to a release (the record/docs/reviews gates, the plugin archive +# pin, the tag's version, the semantic receipts; see the release-gate runbook +# for what gates the merge alone); only if that gate is green does it tag # that commit, cross-compile the four binaries FROM THAT SAME COMMIT, generate a # checksums.txt manifest over them, and create the GitHub Release with the # binaries + checksums.txt attached (plus their SLSA build-provenance @@ -104,27 +106,31 @@ jobs: printf "refusing to release '%s' from a pushed tag: auto-release tags and releases the newest dated CHANGELOG version once it merges to main\n" "$TAG" >&2 exit 1 - # Gate the release on the pushed commit: the deterministic, Linux-only re-run - # of the build and record gates (gofmt, build, vet, test, the race leg, the - # record/docs drift gates, the reviews-charter discipline, smoke) — a subset - # of ci.yml's merge gate, not a substitute for it. A red step here aborts - # before anything is built - # or published. Checked out at github.sha — the commit the pushed tag pointed at, - # never the default-branch tip or the re-resolvable tag name — so the gate - # exercises exactly the commit whose binaries will ship. + # Gate the release on the pushed commit. The merge queue already ran ci.yml's + # check (ubuntu-latest) on exactly this commit (gofmt, build, vet, the plain + # and race passes), and the queue's required checks ran smoke beside it (the + # ruleset alone holds that: verify reads the one check, not smoke), so + # verify does not run them again (iss-2612031238180751): its first step + # requires that check's success, read from GitHub, and the rest are the steps + # particular to a release (the record/docs drift gates, the reviews-charter + # discipline, the plugin archive pin, the tag's version, the semantic + # receipts). A red step here aborts before anything is built or published. + # Checked out at github.sha — the commit the pushed tag pointed at, never the + # default-branch tip or the re-resolvable tag name — so the gate exercises + # exactly the commit whose binaries will ship. verify: # Skipped on a pushed tag's run, which the pushed-tag job refuses. if: github.event_name != 'push' || github.ref_type != 'tag' - # Each go test step's own -timeout must fire before this does, or a hang - # reads as a cancelled job with no goroutine dump. The smoke step fits too: - # 40m for Test, 70m for the race step (sized in ci.yml), its own 8m, and - # three minutes for the untimed steps, 121 in all (evallanebudget_test.go). A - # limit here only frees a stuck runner and does not judge speed, so a slow runner - # does not fail a cut with no failing test (dcn-2611062222587959). - timeout-minutes: 125 + # No test runs here: one API read, the record and docs lints, the reviews + # charter and the archive render, each compiling on a runner with no cache. + # A limit here only frees a stuck runner and does not judge speed + # (TestReleaseVerifyTrustsTheMergeQueueCheck). + timeout-minutes: 20 runs-on: ubuntu-latest permissions: contents: read + checks: read # the merge-queue step: the commit's check suites and their check runs + actions: read # the merge-queue step: the workflow run that owns each suite (its event and file) # The reviewed content commit the semantic gate below admitted, handed to # the release job so it signs the receipts of exactly the commit that was # gated rather than re-deriving it (iss-2608291814573570). Empty when the @@ -132,6 +138,132 @@ jobs: outputs: content_sha: ${{ steps.receipts.outputs.content_sha }} steps: + # --- The merge queue tested this commit (iss-2612031238180751) --------- + # Admit the commit only if GitHub records a check run named + # check (ubuntu-latest) whose latest attempt completed with success, made + # by GitHub Actions (app 15368, the integration the ruleset requires the + # context from), in a check suite of THIS repository at THIS commit, owned + # by a workflow run of .github/workflows/ci.yml started by the merge_group + # event, and only if that run's own latest jobs list a job named + # check (ubuntu-latest), on this commit, that completed with success and + # whose check run IS that check run (a job's id is its check run's id). + # The second read is what binds the check run to ci.yml: any token holding + # checks: write (a branch workflow can grant itself that) can create a + # check run of that name and outcome on the commit, and GitHub may file it + # in the merge_group suite, but a check run made through the Checks API is + # never a job of the run, so it is refused. Each of these facts is + # compared in the script below, and a pull_request run, a dispatched run, + # another workflow file, another repository, another commit, a skipped or + # failed or unfinished check or job, or no such run at all (a commit that + # never went through the queue: a rehearsal on a branch head) refuses the + # release before anything is checked out. Two reads, a GraphQL read of the + # commit's check suites and a REST read of the run's jobs, with the job + # token's checks: read and actions: read. GATED_COMMIT is the commit the + # rest of this run gates, tags and builds, and every value reaches the + # script through env (injection-safe). A read that fails, or a commit with + # more check suites than one read lists, refuses rather than guesses. + - name: Merge queue check passed on the released commit (fail-closed) + env: + GH_TOKEN: ${{ github.token }} + GATED_COMMIT: ${{ inputs.ref || github.sha }} + run: | + set -euo pipefail + refuse() { + printf "refusing to release '%s': %s\n" "$TAG" "$1" >&2 + echo "::error title=The merge queue's check is not on record for this commit::$1" + printf '### The merge queue check stopped this release\n\n%s\n' "$1" >>"$GITHUB_STEP_SUMMARY" + exit 1 + } + sha_re='^[0-9a-f]{40}([0-9a-f]{24})?$' + if [[ ! $GATED_COMMIT =~ $sha_re ]]; then + refuse "the released commit '${GATED_COMMIT}' is not a full commit sha" + fi + want_app=15368 + want_event=merge_group + want_path=.github/workflows/ci.yml + want_check='check (ubuntu-latest)' + query='query($owner: String!, $name: String!, $sha: GitObjectID!) { + repository(owner: $owner, name: $name) { + object(oid: $sha) { + ... on Commit { + checkSuites(first: 100, filterBy: {appId: 15368}) { + totalCount + nodes { + app { databaseId } + repository { nameWithOwner } + commit { oid } + workflowRun { databaseId event file { path } url } + checkRuns(first: 10, filterBy: {checkName: "check (ubuntu-latest)", checkType: LATEST}) { + nodes { databaseId name status conclusion } + } + } + } + } + } + } + }' + # First line: the suite count ("none" when the repository holds no + # such commit). Then one line per check run of that name, each with + # the facts of the suite that holds it. + filter='.data.repository.object.checkSuites as $cs + | (($cs.totalCount // "none") | tostring), + (($cs.nodes // [])[] as $s + | ($s.checkRuns.nodes // [])[] + | [(($s.app.databaseId // "") | tostring), ($s.repository.nameWithOwner // ""), + ($s.commit.oid // ""), ($s.workflowRun.event // ""), ($s.workflowRun.file.path // ""), + (.name // ""), (.status // ""), (.conclusion // ""), + (($s.workflowRun.databaseId // "") | tostring), ((.databaseId // "") | tostring), + ($s.workflowRun.url // "")] + | @tsv)' + if ! rows="$(gh api graphql -f query="$query" -f owner="${GITHUB_REPOSITORY%%/*}" \ + -f name="${GITHUB_REPOSITORY#*/}" -f sha="$GATED_COMMIT" --jq "$filter")"; then + refuse "cannot read the check runs of ${GATED_COMMIT} in ${GITHUB_REPOSITORY}" + fi + total="${rows%%$'\n'*}" + if [[ ! $total =~ ^[0-9]+$ ]]; then + refuse "${GITHUB_REPOSITORY} holds no commit ${GATED_COMMIT}" + fi + if [ "$total" -gt 100 ]; then + refuse "${GATED_COMMIT} carries ${total} check suites, more than one read lists" + fi + id_re='^[0-9]+$' + candidates=() + while IFS=$'\t' read -r app repo oid event path check status conclusion run_id check_run_id url; do + echo "check run: app=${app} repository=${repo} commit=${oid} event=${event} workflow=${path} name=${check} status=${status} conclusion=${conclusion} run=${run_id} check_run=${check_run_id} ${url}" + if [ "$app" = "$want_app" ] && [ "$repo" = "$GITHUB_REPOSITORY" ] && [ "$oid" = "$GATED_COMMIT" ] \ + && [ "$event" = "$want_event" ] && [ "$path" = "$want_path" ] && [ "$check" = "$want_check" ] \ + && [ "$status" = COMPLETED ] && [ "$conclusion" = SUCCESS ] \ + && [[ $run_id =~ $id_re ]] && [[ $check_run_id =~ $id_re ]]; then + candidates+=("${run_id} ${check_run_id} ${url}") + fi + done < <(tail -n +2 <<<"$rows") + # Bind each candidate check run to a job of its own run: the run's + # latest jobs must hold a job of that name, on this commit, completed + # with success, whose id and check run are the candidate's. + api="${GITHUB_API_URL:-https://api.github.com}" + admitted="" + # The ${a[@]+...} spelling keeps an empty list from tripping set -u. + for candidate in ${candidates[@]+"${candidates[@]}"}; do + read -r run_id check_run_id url <<<"$candidate" + if ! jobs="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?filter=latest&per_page=100" --paginate \ + --jq '.jobs[] | [(.name // ""), ((.id // "") | tostring), ((.run_id // "") | tostring), (.head_sha // ""), + (.status // ""), (.conclusion // ""), (.check_run_url // "")] | @tsv')"; then + refuse "cannot read the jobs of run ${run_id}, which holds the check run ${check_run_id} on ${GATED_COMMIT}" + fi + while IFS=$'\t' read -r job_name job_id job_run job_sha job_status job_conclusion job_check_run; do + if [ "$job_name" = "$want_check" ] && [ "$job_id" = "$check_run_id" ] && [ "$job_run" = "$run_id" ] \ + && [ "$job_sha" = "$GATED_COMMIT" ] && [ "$job_status" = completed ] && [ "$job_conclusion" = success ] \ + && [ "$job_check_run" = "${api}/repos/${GITHUB_REPOSITORY}/check-runs/${check_run_id}" ]; then + echo "job ${job_id} of run ${run_id} is that check run, and it succeeded" + admitted="$url" + fi + done <<<"$jobs" + done + if [ -z "$admitted" ]; then + refuse "no successful '${want_check}' job of a ${want_event} run of ${want_path} in ${GITHUB_REPOSITORY} is on record for ${GATED_COMMIT}. A release cuts only a commit the merge queue tested; land the change through the queue, and its push starts the release again" + fi + echo "the merge queue's ${want_check} passed on ${GATED_COMMIT}: ${admitted}" + - name: Check out the pushed commit uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -158,36 +290,6 @@ jobs: # release-triggering workflow is a cache-poisoning vector (zizmor). cache: false - - name: Format (gofmt) - # One definition of the gate, INVOKED rather than restated: the Makefile - # target resolves gofmt from the toolchain go.mod declares, so the release - # lane, the merge lane and the developer's pre-push run are one gate judged - # by one binary (.abcd/development/principles/one-canonical-primitive.md). - run: make fmt-check - - - name: Build - run: go build ./... - - - name: Vet - run: go vet ./... - - # Past this limit a package fails with no test failing, after the merge queue - # passed it, so it holds about twice the slowest package here, with room for - # its growth (dcn-2611062222587959). Both test steps carry the check job's - # switches, so a cut tests the longest packages the way the merge gate does - # (TestCIRacePassesShardLikePreflight). - - name: Test - env: - ABCD_TEST_SKIP_FLUSH: "1" - ABCD_TEST_SHARDS: "3" - run: go test -count=1 -timeout 40m ./... - - - name: Test (race, internal) - env: - ABCD_TEST_SKIP_FLUSH: "1" - ABCD_TEST_SHARDS: "3" - run: go test -race -count=1 -timeout 70m ./internal/surface/cli ./internal/core/reading ./internal/core/launch ./internal/core/lifeboat ./internal/core/lint ./internal/adapter/scanner ./internal/core/implement/loop ./internal/core/interview ./internal/core/capture ./internal/core/ahoy ./internal/core/site ./internal/... - - name: Record-lint (design-record drift gate) run: go run ./cmd/record-lint @@ -197,9 +299,6 @@ jobs: - name: Reviews-charter discipline (RD001-RD004) run: bash scripts/check-reviews.sh - - name: Smoke every command (self-discovering harness) - run: make smoke EVAL_TIMEOUT=8m - # --- The pinned plugin archive (adr-2609231048308186; ruling E1) -------- # The ship committed the release's plugin archive — its download address # and SHA-256 — into .claude-plugin/marketplace.json, and every install or diff --git a/commands/launch.md b/commands/launch.md index 0a9726514b..3e64ff7bf8 100644 --- a/commands/launch.md +++ b/commands/launch.md @@ -291,9 +291,10 @@ Click it, tick the **release** environment, optionally leave a comment, and clic do, described above. **If the banner does not appear**, the run has not reached that job yet. The -jobs before it build, test and lint the commit the tag will name (`verify`, -and in abcd's own workflow the four macOS suite shards `macos-gate` collects), -then `tag` tags it. Wait for each job before `release` to go green. +jobs before it check the commit the tag will name (`verify`, which in abcd's +own workflow reads the merge queue's Linux check on that commit instead of +running the tests again, and there the five macOS suite shards `macos-gate` +collects), then `tag` tags it. Wait for each job before `release` to go green. **The install window.** From the moment the release PR merges, the catalog on `main` names this release's archive, and the archive is downloadable only once diff --git a/internal/core/launch/scaffold/render.go b/internal/core/launch/scaffold/render.go index a65d8f072c..f9e2f15d4f 100644 --- a/internal/core/launch/scaffold/render.go +++ b/internal/core/launch/scaffold/render.go @@ -126,8 +126,12 @@ func (s Substitutions) VerifiesPushedTag() bool { } // ExtraBase is the number the runbook gives the first extra gate: it follows -// the five Go gates when the repository is a Go module, and leads otherwise. +// abcd-cli's one merge-queue gate, which stands in for the Go leg there; the +// five Go gates when the repository is a Go module; and leads otherwise. func (s Substitutions) ExtraBase() int { + if s.Abcd { + return 2 + } if s.GoModule { return 6 } diff --git a/internal/core/launch/scaffold/scaffold_test.go b/internal/core/launch/scaffold/scaffold_test.go index ca01408ce4..c49a50595d 100644 --- a/internal/core/launch/scaffold/scaffold_test.go +++ b/internal/core/launch/scaffold/scaffold_test.go @@ -161,7 +161,8 @@ func TestBareRunbookGateListMatchesWorkflow(t *testing.T) { // TestAbcdRunbookNumbersExtraGates proves the abcd runbook's numbered list is // rendered from the same ExtraGates source as the workflow steps (the in-template -// gate_lockstep invariant), continuing 6..9. +// gate_lockstep invariant), continuing 2..4 after the merge-queue gate that +// stands in for the Go leg. func TestAbcdRunbookNumbersExtraGates(t *testing.T) { rendered, err := Render(AbcdSubstitutions()) if err != nil { @@ -169,10 +170,12 @@ func TestAbcdRunbookNumbersExtraGates(t *testing.T) { } book := string(rendered.Runbook) for _, want := range []string{ - "6. Record-lint (design-record drift gate)", - "7. Docs-lint (docs-currency gate)", - "8. Reviews-charter discipline (RD001-RD004)", - "9. Smoke every command (self-discovering harness)", + "1. Merge queue check passed on the released commit (fail-closed)", + "2. Record-lint (design-record drift gate)", + "3. Docs-lint (docs-currency gate)", + "4. Reviews-charter discipline (RD001-RD004)", + "5. Plugin archive reproduces the committed pin (fail-closed)", + "6. The release tag names the released CHANGELOG version (fail-closed)", } { if !strings.Contains(book, want) { t.Errorf("abcd runbook must number extra gate %q", want) diff --git a/internal/core/launch/scaffold/substitutions.go b/internal/core/launch/scaffold/substitutions.go index 697488174a..d339a9131e 100644 --- a/internal/core/launch/scaffold/substitutions.go +++ b/internal/core/launch/scaffold/substitutions.go @@ -5,10 +5,13 @@ package scaffold // semantic-gate set the self-scaffold parity rendering reproduces. var abcdSemanticGates = []string{"docs-currency-reviewer", "iss35-brief-surface-crosscheck"} -// abcdExtraGates are the deterministic verify steps abcd-cli runs beyond the -// generic Go leg (gofmt/build/vet/test/race). They render into both the verify -// job and the runbook's numbered gate list from this one source, so the -// gate_lockstep invariant (runbook list == workflow steps) holds by construction. +// abcdExtraGates are the deterministic verify steps abcd-cli runs after its +// merge-queue step, in place of the generic Go leg (gofmt/build/vet/test/race), +// which the queue's check (ubuntu-latest) already ran on the released commit, +// as its required smoke check ran smoke (iss-2612031238180751). They render +// into both the verify job and the runbook's numbered gate list from this one +// source, so the gate_lockstep invariant (runbook list == workflow steps) +// holds by construction. // // The docs lint runs with --release-gate here, and only here: a citation past // its staleness threshold blocks a release, while ci.yml's commit-time lint @@ -17,7 +20,6 @@ var abcdExtraGates = []Gate{ {Name: "Record-lint (design-record drift gate)", Run: "go run ./cmd/record-lint"}, {Name: "Docs-lint (docs-currency gate)", Run: "go run ./cmd/abcd lint docs --release-gate"}, {Name: "Reviews-charter discipline (RD001-RD004)", Run: "bash scripts/check-reviews.sh"}, - {Name: "Smoke every command (self-discovering harness)", Run: "make smoke EVAL_TIMEOUT=8m"}, } // AbcdSubstitutions is abcd-cli's own fact set: the fixed inputs that regenerate diff --git a/internal/core/launch/scaffold/templates/auto-release.yml.tmpl b/internal/core/launch/scaffold/templates/auto-release.yml.tmpl index 128f1e0dcc..b9e3e48227 100644 --- a/internal/core/launch/scaffold/templates/auto-release.yml.tmpl +++ b/internal/core/launch/scaffold/templates/auto-release.yml.tmpl @@ -199,7 +199,10 @@ jobs: # transitive: <% .ReleaseWorkflow %> in turn calls site.yml (adr-48), so this job hands # down every scope BOTH workflows' jobs need (contents/id-token/attestations: # write). The three happen to be the same set, so the site deploy widens - # nothing here. + # nothing here. The two read scopes are verify's alone: its first step reads + # the merge queue's check on the released commit (iss-2612031238180751), and + # a called job asking for a scope its caller withholds fails the whole run + # before any job starts. <%- else %> # A called workflow is capped by the caller's grants, so this job hands down # every scope <% .ReleaseWorkflow %>'s jobs need (contents: write). @@ -215,6 +218,8 @@ jobs: contents: write # <% .ReleaseWorkflow %>: push the new tag after verify, create the draft Release; site.yml: attach site.tar.gz and publish the Release id-token: write # <% .ReleaseWorkflow %> + site.yml: OIDC for build-provenance attestation attestations: write # <% .ReleaseWorkflow %>: publish + read back the attestations; site.yml: attest site.tar.gz + checks: read # <% .ReleaseWorkflow %> verify: the released commit's check suites and check runs + actions: read # <% .ReleaseWorkflow %> verify: the workflow run that owns each suite (its event and file) <%- else %> contents: write # <% .ReleaseWorkflow %>: push the new tag after verify, create the Release <%- end %> diff --git a/internal/core/launch/scaffold/templates/release.yml.tmpl b/internal/core/launch/scaffold/templates/release.yml.tmpl index 9f2a2b51f2..c39f12e55e 100644 --- a/internal/core/launch/scaffold/templates/release.yml.tmpl +++ b/internal/core/launch/scaffold/templates/release.yml.tmpl @@ -1,11 +1,13 @@ name: <% if .Gate %>abcd-release-gate<% else %>release<% end %> <% if .Abcd %> # Releases are made by auto-release from main: a merge that rolls a new dated -# CHANGELOG version calls this workflow, which first re-runs the deterministic, -# Linux-only verify gate (gofmt, build, vet, the race leg, and the -# record/docs/reviews gates — a subset of the merge gate, which is the -# authority; see the release-gate runbook for what gates the merge alone) -# against the commit being released; only if that gate is green does it tag +# CHANGELOG version calls this workflow, which first runs the verify gate +# against the commit being released: it requires the merge queue's own Linux +# check (check (ubuntu-latest), from a merge_group run of ci.yml) to have passed +# on that commit, in place of running the tests again, and then runs the steps +# particular to a release (the record/docs/reviews gates, the plugin archive +# pin, the tag's version, the semantic receipts; see the release-gate runbook +# for what gates the merge alone); only if that gate is green does it tag # that commit, cross-compile the four binaries FROM THAT SAME COMMIT, generate a # checksums.txt manifest over them, and create the GitHub Release with the # binaries + checksums.txt attached (plus their SLSA build-provenance @@ -158,14 +160,18 @@ jobs: <%- end %> <%- if .Abcd %> - # Gate the release on the pushed commit: the deterministic, Linux-only re-run - # of the build and record gates (gofmt, build, vet, test, the race leg, the - # record/docs drift gates, the reviews-charter discipline, smoke) — a subset - # of ci.yml's merge gate, not a substitute for it. A red step here aborts - # before anything is built - # or published. Checked out at github.sha — the commit the pushed tag pointed at, - # never the default-branch tip or the re-resolvable tag name — so the gate - # exercises exactly the commit whose binaries will ship. + # Gate the release on the pushed commit. The merge queue already ran ci.yml's + # check (ubuntu-latest) on exactly this commit (gofmt, build, vet, the plain + # and race passes), and the queue's required checks ran smoke beside it (the + # ruleset alone holds that: verify reads the one check, not smoke), so + # verify does not run them again (iss-2612031238180751): its first step + # requires that check's success, read from GitHub, and the rest are the steps + # particular to a release (the record/docs drift gates, the reviews-charter + # discipline, the plugin archive pin, the tag's version, the semantic + # receipts). A red step here aborts before anything is built or published. + # Checked out at github.sha — the commit the pushed tag pointed at, never the + # default-branch tip or the re-resolvable tag name — so the gate exercises + # exactly the commit whose binaries will ship. <%- else %> <%- if .RefusesPushedTag %> <% end %> @@ -201,19 +207,21 @@ jobs: if: github.event_name != 'push' || github.ref_type != 'tag' <%- end %> <%- if .Abcd %> - # Each go test step's own -timeout must fire before this does, or a hang - # reads as a cancelled job with no goroutine dump. The smoke step fits too: - # 40m for Test, 70m for the race step (sized in ci.yml), its own 8m, and - # three minutes for the untimed steps, 121 in all (evallanebudget_test.go). A - # limit here only frees a stuck runner and does not judge speed, so a slow runner - # does not fail a cut with no failing test (dcn-2611062222587959). - timeout-minutes: 125 + # No test runs here: one API read, the record and docs lints, the reviews + # charter and the archive render, each compiling on a runner with no cache. + # A limit here only frees a stuck runner and does not judge speed + # (TestReleaseVerifyTrustsTheMergeQueueCheck). + timeout-minutes: 20 <%- else %> timeout-minutes: 15 <%- end %> runs-on: ubuntu-latest permissions: contents: read +<%- if .Abcd %> + checks: read # the merge-queue step: the commit's check suites and their check runs + actions: read # the merge-queue step: the workflow run that owns each suite (its event and file) +<%- end %> <%- if .SemanticGates %> # The reviewed content commit the semantic gate below admitted, handed to # the release job so it signs the receipts of exactly the commit that was @@ -223,6 +231,133 @@ jobs: content_sha: ${{ steps.receipts.outputs.content_sha }} <%- end %> steps: +<%- if .Abcd %> + # --- The merge queue tested this commit (iss-2612031238180751) --------- + # Admit the commit only if GitHub records a check run named + # check (ubuntu-latest) whose latest attempt completed with success, made + # by GitHub Actions (app 15368, the integration the ruleset requires the + # context from), in a check suite of THIS repository at THIS commit, owned + # by a workflow run of .github/workflows/ci.yml started by the merge_group + # event, and only if that run's own latest jobs list a job named + # check (ubuntu-latest), on this commit, that completed with success and + # whose check run IS that check run (a job's id is its check run's id). + # The second read is what binds the check run to ci.yml: any token holding + # checks: write (a branch workflow can grant itself that) can create a + # check run of that name and outcome on the commit, and GitHub may file it + # in the merge_group suite, but a check run made through the Checks API is + # never a job of the run, so it is refused. Each of these facts is + # compared in the script below, and a pull_request run, a dispatched run, + # another workflow file, another repository, another commit, a skipped or + # failed or unfinished check or job, or no such run at all (a commit that + # never went through the queue: a rehearsal on a branch head) refuses the + # release before anything is checked out. Two reads, a GraphQL read of the + # commit's check suites and a REST read of the run's jobs, with the job + # token's checks: read and actions: read. GATED_COMMIT is the commit the + # rest of this run gates, tags and builds, and every value reaches the + # script through env (injection-safe). A read that fails, or a commit with + # more check suites than one read lists, refuses rather than guesses. + - name: Merge queue check passed on the released commit (fail-closed) + env: + GH_TOKEN: ${{ github.token }} + GATED_COMMIT: ${{ inputs.ref || github.sha }} + run: | + set -euo pipefail + refuse() { + printf "refusing to release '%s': %s\n" "$TAG" "$1" >&2 + echo "::error title=The merge queue's check is not on record for this commit::$1" + printf '### The merge queue check stopped this release\n\n%s\n' "$1" >>"$GITHUB_STEP_SUMMARY" + exit 1 + } + sha_re='^[0-9a-f]{40}([0-9a-f]{24})?$' + if [[ ! $GATED_COMMIT =~ $sha_re ]]; then + refuse "the released commit '${GATED_COMMIT}' is not a full commit sha" + fi + want_app=15368 + want_event=merge_group + want_path=.github/workflows/ci.yml + want_check='check (ubuntu-latest)' + query='query($owner: String!, $name: String!, $sha: GitObjectID!) { + repository(owner: $owner, name: $name) { + object(oid: $sha) { + ... on Commit { + checkSuites(first: 100, filterBy: {appId: 15368}) { + totalCount + nodes { + app { databaseId } + repository { nameWithOwner } + commit { oid } + workflowRun { databaseId event file { path } url } + checkRuns(first: 10, filterBy: {checkName: "check (ubuntu-latest)", checkType: LATEST}) { + nodes { databaseId name status conclusion } + } + } + } + } + } + } + }' + # First line: the suite count ("none" when the repository holds no + # such commit). Then one line per check run of that name, each with + # the facts of the suite that holds it. + filter='.data.repository.object.checkSuites as $cs + | (($cs.totalCount // "none") | tostring), + (($cs.nodes // [])[] as $s + | ($s.checkRuns.nodes // [])[] + | [(($s.app.databaseId // "") | tostring), ($s.repository.nameWithOwner // ""), + ($s.commit.oid // ""), ($s.workflowRun.event // ""), ($s.workflowRun.file.path // ""), + (.name // ""), (.status // ""), (.conclusion // ""), + (($s.workflowRun.databaseId // "") | tostring), ((.databaseId // "") | tostring), + ($s.workflowRun.url // "")] + | @tsv)' + if ! rows="$(gh api graphql -f query="$query" -f owner="${GITHUB_REPOSITORY%%/*}" \ + -f name="${GITHUB_REPOSITORY#*/}" -f sha="$GATED_COMMIT" --jq "$filter")"; then + refuse "cannot read the check runs of ${GATED_COMMIT} in ${GITHUB_REPOSITORY}" + fi + total="${rows%%$'\n'*}" + if [[ ! $total =~ ^[0-9]+$ ]]; then + refuse "${GITHUB_REPOSITORY} holds no commit ${GATED_COMMIT}" + fi + if [ "$total" -gt 100 ]; then + refuse "${GATED_COMMIT} carries ${total} check suites, more than one read lists" + fi + id_re='^[0-9]+$' + candidates=() + while IFS=$'\t' read -r app repo oid event path check status conclusion run_id check_run_id url; do + echo "check run: app=${app} repository=${repo} commit=${oid} event=${event} workflow=${path} name=${check} status=${status} conclusion=${conclusion} run=${run_id} check_run=${check_run_id} ${url}" + if [ "$app" = "$want_app" ] && [ "$repo" = "$GITHUB_REPOSITORY" ] && [ "$oid" = "$GATED_COMMIT" ] \ + && [ "$event" = "$want_event" ] && [ "$path" = "$want_path" ] && [ "$check" = "$want_check" ] \ + && [ "$status" = COMPLETED ] && [ "$conclusion" = SUCCESS ] \ + && [[ $run_id =~ $id_re ]] && [[ $check_run_id =~ $id_re ]]; then + candidates+=("${run_id} ${check_run_id} ${url}") + fi + done < <(tail -n +2 <<<"$rows") + # Bind each candidate check run to a job of its own run: the run's + # latest jobs must hold a job of that name, on this commit, completed + # with success, whose id and check run are the candidate's. + api="${GITHUB_API_URL:-https://api.github.com}" + admitted="" + # The ${a[@]+...} spelling keeps an empty list from tripping set -u. + for candidate in ${candidates[@]+"${candidates[@]}"}; do + read -r run_id check_run_id url <<<"$candidate" + if ! jobs="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?filter=latest&per_page=100" --paginate \ + --jq '.jobs[] | [(.name // ""), ((.id // "") | tostring), ((.run_id // "") | tostring), (.head_sha // ""), + (.status // ""), (.conclusion // ""), (.check_run_url // "")] | @tsv')"; then + refuse "cannot read the jobs of run ${run_id}, which holds the check run ${check_run_id} on ${GATED_COMMIT}" + fi + while IFS=$'\t' read -r job_name job_id job_run job_sha job_status job_conclusion job_check_run; do + if [ "$job_name" = "$want_check" ] && [ "$job_id" = "$check_run_id" ] && [ "$job_run" = "$run_id" ] \ + && [ "$job_sha" = "$GATED_COMMIT" ] && [ "$job_status" = completed ] && [ "$job_conclusion" = success ] \ + && [ "$job_check_run" = "${api}/repos/${GITHUB_REPOSITORY}/check-runs/${check_run_id}" ]; then + echo "job ${job_id} of run ${run_id} is that check run, and it succeeded" + admitted="$url" + fi + done <<<"$jobs" + done + if [ -z "$admitted" ]; then + refuse "no successful '${want_check}' job of a ${want_event} run of ${want_path} in ${GITHUB_REPOSITORY} is on record for ${GATED_COMMIT}. A release cuts only a commit the merge queue tested; land the change through the queue, and its push starts the release again" + fi + echo "the merge queue's ${want_check} passed on ${GATED_COMMIT}: ${admitted}" +<% end %> - name: Check out the pushed commit uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -253,15 +388,9 @@ jobs: # cache: false — this workflow is tag-triggered; module caching in a # release-triggering workflow is a cache-poisoning vector (zizmor). cache: false +<%- if not .Abcd %> - name: Format (gofmt) -<%- if .Abcd %> - # One definition of the gate, INVOKED rather than restated: the Makefile - # target resolves gofmt from the toolchain go.mod declares, so the release - # lane, the merge lane and the developer's pre-push run are one gate judged - # by one binary (.abcd/development/principles/one-canonical-primitive.md). - run: make fmt-check -<%- else %> # The gofmt inside the GOROOT this module's own toolchain resolves to, never # whichever one PATH offers. gofmt's rules move between releases, so a runner # whose preinstalled Go is newer than the go directive names files unformatted @@ -280,32 +409,12 @@ jobs: echo "$unformatted" >&2 exit 1 fi -<%- end %> - name: Build run: go build ./... - name: Vet run: go vet ./... -<%- if .Abcd %> - - # Past this limit a package fails with no test failing, after the merge queue - # passed it, so it holds about twice the slowest package here, with room for - # its growth (dcn-2611062222587959). Both test steps carry the check job's - # switches, so a cut tests the longest packages the way the merge gate does - # (TestCIRacePassesShardLikePreflight). - - name: Test - env: - ABCD_TEST_SKIP_FLUSH: "1" - ABCD_TEST_SHARDS: "3" - run: go test -count=1 -timeout 40m ./... - - - name: Test (race, internal) - env: - ABCD_TEST_SKIP_FLUSH: "1" - ABCD_TEST_SHARDS: "3" - run: go test -race -count=1 -timeout 70m ./internal/surface/cli ./internal/core/reading ./internal/core/launch ./internal/core/lifeboat ./internal/core/lint ./internal/adapter/scanner ./internal/core/implement/loop ./internal/core/interview ./internal/core/capture ./internal/core/ahoy ./internal/core/site ./internal/... -<%- else %> - name: Test run: go test -count=1 ./... diff --git a/internal/core/launch/scaffold/templates/runbook.md.tmpl b/internal/core/launch/scaffold/templates/runbook.md.tmpl index 7666481953..c34ef6a4f4 100644 --- a/internal/core/launch/scaffold/templates/runbook.md.tmpl +++ b/internal/core/launch/scaffold/templates/runbook.md.tmpl @@ -101,25 +101,23 @@ Run zizmor, or the workflow auditor this repository already uses, over The `<% .ReleaseWorkflow %>` `verify` job runs these, in order, on the released commit. `<% .ReleaseWorkflow %>` is authoritative; this list is the human-readable mirror. -<% if .GoModule %> +<% if .Abcd %> +1. Merge queue check passed on the released commit (fail-closed) +<%- else if .GoModule %> 1. Format (gofmt) 2. Build 3. Vet 4. Test -<%- if .Abcd %> -5. Test (race, internal) -<%- else %> 5. Test (race) <%- end %> -<%- end %> <%- range $i, $g := .ExtraGates %> <% add $i $.ExtraBase %>. <% $g.Name %> <%- end %> <%- if .Abcd %> -<% add (len .ExtraGates) 6 %>. Plugin archive reproduces the committed pin (fail-closed) +<% add (len .ExtraGates) .ExtraBase %>. Plugin archive reproduces the committed pin (fail-closed) <%- end %> <%- if .SemanticGates %> -<% if .Abcd %><% add (len .ExtraGates) 7 %><% else %><% add (len .ExtraGates) .ExtraBase %><% end %>. The release tag names the released CHANGELOG version (fail-closed) +<% if .Abcd %><% add (len .ExtraGates) (add .ExtraBase 1) %><% else %><% add (len .ExtraGates) .ExtraBase %><% end %>. The release tag names the released CHANGELOG version (fail-closed) <%- end %> <%- if .Abcd %> diff --git a/internal/core/launch/scaffold/testbudget_workflow_test.go b/internal/core/launch/scaffold/testbudget_workflow_test.go index 9e6a8a82e9..b2b24c9795 100644 --- a/internal/core/launch/scaffold/testbudget_workflow_test.go +++ b/internal/core/launch/scaffold/testbudget_workflow_test.go @@ -16,7 +16,9 @@ var ( // A hang must fail on go test's own limit, which prints a goroutine dump, not on // the job's, which cancels with none. The eval and race lane budget tests read // abcd's own release.yml, so a scaffolded repository's render is held here. Go's -// default limit counts when a step sets none. +// default limit counts when a step sets none. abcd's own render runs no test in +// verify: it reads its merge queue's check on the released commit instead +// (iss-2612031238180751), so its absence here is the property. func TestEveryRenderedTestStepLimitFitsUnderTheVerifyJob(t *testing.T) { const goDefault = 10 * time.Minute for name, subs := range map[string]Substitutions{ @@ -50,16 +52,19 @@ func TestEveryRenderedTestStepLimitFitsUnderTheVerifyJob(t *testing.T) { t.Errorf("%s: %q has a %s limit, not under the job's %s; a hang would be cancelled with no goroutine dump", name, strings.TrimSpace(line), limit, job) } } - if steps == 0 { + if name == "abcd" && steps != 0 { + t.Errorf("abcd: the verify job runs %d go test step(s); the merge queue's check already ran them on the released commit", steps) + } + if name != "abcd" && steps == 0 { t.Errorf("%s: the verify job runs no go test; the render or this test changed shape", name) } } } -// abcd's own verify job tests its longest packages the way its merge gate does, -// through switches only abcd's test binaries read (internal/testshard). A managed -// repository's render carries neither: they would mean nothing to its tests. -func TestOnlyAbcdsRenderedVerifyJobSetsItsTestSwitches(t *testing.T) { +// abcd's test switches (internal/testshard) mean nothing to a managed +// repository's tests, so no render's verify job carries them: a managed +// repository's would ignore them, and abcd's own runs no test there. +func TestNoRenderedVerifyJobSetsAbcdsTestSwitches(t *testing.T) { for name, subs := range map[string]Substitutions{ "abcd": AbcdSubstitutions(), "bare": BareSubstitutions("main"), "gate": GateSubstitutions("main", ""), } { @@ -69,11 +74,7 @@ func TestOnlyAbcdsRenderedVerifyJobSetsItsTestSwitches(t *testing.T) { } verify := jobSection(t, string(rendered.ReleaseYML), "verify") for _, word := range []string{`ABCD_TEST_SHARDS: "3"`, `ABCD_TEST_SKIP_FLUSH: "1"`} { - got, want := strings.Count(verify, word), 0 - if name == "abcd" { - want = 2 // the plain step and the race step - } - if got != want { + if got, want := strings.Count(verify, word), 0; got != want { t.Errorf("%s: the verify job sets %s %d times; want %d", name, word, got, want) } } diff --git a/internal/core/lint/cishards_test.go b/internal/core/lint/cishards_test.go index 69814c7a73..4e9cfdaec4 100644 --- a/internal/core/lint/cishards_test.go +++ b/internal/core/lint/cishards_test.go @@ -24,9 +24,10 @@ import ( // across runners does not make a package shorter on the runner it lands on. The // check job's plain pass on an inert change, its only test pass there, shards the // same way: as one process internal/core/implement/loop crossed go -// test's ten-minute default with no test hung (iss-2610302058222905). Both test -// steps of release.yml's verify job shard too, and each pass here also skips the -// flush, so a cut tests the longest packages the way the merge gate does. +// test's ten-minute default with no test hung (iss-2610302058222905). Each pass +// here also skips the flush. release.yml's verify job runs no test pass of its +// own: it reads the merge gate's check on the released commit +// (iss-2612031238180751). func TestCIRacePassesShardLikePreflight(t *testing.T) { root := filepath.Join("..", "..", "..") @@ -38,16 +39,11 @@ func TestCIRacePassesShardLikePreflight(t *testing.T) { want := `ABCD_TEST_SHARDS: "` + m[1] + `"` const ci = ".github/workflows/ci.yml" - const release = ".github/workflows/release.yml" const skipFlush = `ABCD_TEST_SKIP_FLUSH: "1"` for _, pass := range []struct{ file, name string }{ {ci, "Test (race, internal)"}, {macOSSuiteWorkflow, macOSRaceStep}, {ci, "Test"}, - // A cut tests the longest packages the way the merge gate does, so a - // package the merge gate passed does not then fail the cut. - {release, "Test (race, internal)"}, - {release, "Test"}, } { file, name := pass.file, pass.name step, ok := workflowStepBlock(readRepoFile(t, root, file), name) diff --git a/internal/core/lint/evallanebudget_test.go b/internal/core/lint/evallanebudget_test.go index 82ba2aa7ce..2cf5fc9529 100644 --- a/internal/core/lint/evallanebudget_test.go +++ b/internal/core/lint/evallanebudget_test.go @@ -24,16 +24,18 @@ import ( // or as a make argument where the step is rendered from the release scaffold, // whose gates carry a run line only), and the // job's timeout-minutes must hold that budget after everything before it: the -// -timeout of every earlier step in the job (release.yml's verify job runs smoke -// after its 70m race step) plus evalJobHeadroom for the untimed steps. +// -timeout of every earlier step in the job plus evalJobHeadroom for the +// untimed steps. release.yml is read too, though its verify job runs no eval +// lane now: the merge queue's required smoke check ran it on the released +// commit (iss-2612031238180751). const minLocalEvalBudget = 20 * time.Minute // evalJobHeadroom is what a job spends in steps that declare no -timeout before // its eval step: checkout, setup-go and the load check took about half a minute // in CI's smoke and cold-reading-evals jobs (merge-group runs of 2026-10-24), and -// release.yml's verify job about two outside its timed steps on the v0.16.2 cut. -// Rounded up to three. +// release.yml's verify job, when it still ran smoke, about two outside its timed +// steps on the v0.16.2 cut. Rounded up to three. const evalJobHeadroom = 3 * time.Minute var ( diff --git a/internal/core/lint/preflightgates_test.go b/internal/core/lint/preflightgates_test.go index 338a9d9600..6714f1f98a 100644 --- a/internal/core/lint/preflightgates_test.go +++ b/internal/core/lint/preflightgates_test.go @@ -576,8 +576,10 @@ const formatStepName = "Format (gofmt)" // scaffold template. A workflow that grows a format step joins by existing, // which is what the hand-written list could not promise. Two floors make a // broken sweep fail rather than pass quietly — the roster must be non-empty, and -// it must find at least the three format gates the tree carries (ci.yml, -// release.yml, and the template both are checked against). +// it must find at least the two format gates the tree carries (ci.yml, and the +// template a managed repository's release.yml is rendered from; abcd's own +// release.yml runs none, reading the merge queue's check instead, +// iss-2612031238180751). // // A managed repo has no Makefile of ours to invoke, so "pinned" cannot mean // `make fmt-check` everywhere. What it means is the negative property the helper @@ -625,7 +627,7 @@ func TestNoShippedWorkflowRunsTheGofmtOnPATH(t *testing.T) { "its own declared toolchain resolves to.", rel, bare) } } - const minFormatGates = 3 // ci.yml, release.yml, release.yml.tmpl + const minFormatGates = 2 // ci.yml, release.yml.tmpl if gates < minFormatGates { t.Fatalf("found %d %q steps across %d shipped workflows and templates, want at least %d; "+ "the step-name parser or the step name itself changed, and a sweep that cannot see the "+ diff --git a/internal/core/lint/racelanebudget_test.go b/internal/core/lint/racelanebudget_test.go index c2a577f3a6..afb7fc71cd 100644 --- a/internal/core/lint/racelanebudget_test.go +++ b/internal/core/lint/racelanebudget_test.go @@ -20,17 +20,17 @@ import ( // macOS runner measured 417.9s, 472.0s and 567.9s on three passing runs, and // a merge-group run on a slow runner crossed 600s with no test hung and ejected // an unrelated pull request from the queue. The lane's ceiling was the default -// rather than a budget anyone had sized, so it is written down here, in four +// rather than a budget anyone had sized, so it is written down here, in three // places: the merge gate (ci.yml's race lane on ubuntu), the macOS suite (the -// race pass of macos-suite.yml's shards, nightly and on each release cut), the -// release gate (release.yml's verify job) and the local pre-push gate (make -// preflight). The merge gate, the macOS suite and the release gate each carry a -// longer budget than the local gate's, because a limit there only frees a stuck -// runner and does not judge speed (dcn-2611062201286033, dcn-2611062222587959). -// Each stays at or above the local gate's, so what the local gate passes has room -// in CI, and inside its job's clock, so a hang in a package that starts with the -// step still fails at its own timeout. The release gate's equals the merge gate's, -// so a package the merge gate passed does not then fail the cut. +// race pass of macos-suite.yml's shards, nightly and on each release cut) and +// the local pre-push gate (make preflight). The merge gate and the macOS suite +// each carry a longer budget than the local gate's, because a limit there only +// frees a stuck runner and does not judge speed (dcn-2611062201286033). Each +// stays at or above the local gate's, so what the local gate passes has room in +// CI, and inside its job's clock, so a hang in a package that starts with the +// step still fails at its own timeout. release.yml's verify job runs no Linux +// test: it reads the merge gate's check on the released commit instead +// (iss-2612031238180751, TestReleaseVerifyTrustsTheMergeQueueCheck). // // The enclosing ceilings are the other half, and they differ by job. // @@ -57,14 +57,6 @@ import ( // per-package default, so a slow package runs on rather than failing at ten // minutes. // -// release.yml's verify job is not a merge-queue job, so its own timeout-minutes -// is its ceiling. A package timeout that reaches past it never fires: the -// runner cancels the job first, and a cancellation carries no goroutine dump, -// so a real hang would read as a slow runner. verify therefore holds the -// package timeout plus the time its slowest package waits before it starts on a -// slow runner: the steps ahead of the race step, and the packages `go test` runs -// ahead of it inside the step. -// // The commands also name one package list, in one order. go test starts // packages in the order its arguments list them, a few at a time on a runner // with few cores, so the slowest packages are named ahead of the pattern and @@ -171,53 +163,8 @@ func TestRaceLaneBudgetIsDeclaredAndFitsItsJob(t *testing.T) { } } } - - // The slowest package here is internal/core/implement/loop, named seventh, so it - // waits inside the step as well as behind the steps before it. On the v0.16.2 - // cut (run 42201072965, ubuntu, uncached toolchain, one process) it started 25.0 - // minutes into the job: 18.7 before the race step and 6.3 inside it. Shards do - // not clearly move that: in the check job (three runs of 2026-11-06) it starts - // 7.1 to 9.1 minutes into the race step, against which the plain step should - // shorten, though no verify run has measured that yet. Twice 25 on a slow runner - // is 50, which leaves the job's clock five minutes past the package timeout. - const verifyHeadroom = 50 * time.Minute - if verify, pkg, ok := raceJob(".github/workflows/release.yml", "verify", checkPackageTimeoutMinutes*time.Minute); ok { - const where = ".github/workflows/release.yml job verify" - capMin := jobTimeoutMinutes(t, where, verify) - if need := pkg + verifyHeadroom; capMin < need { - t.Errorf("%s: timeout-minutes is %s, below the package timeout %s plus %s of headroom (%s); "+ - "the runner would cancel the job before go test could report a hang", - where, capMin, pkg, verifyHeadroom, need) - } - if capMin != verifyCeilingMinutes*time.Minute { - t.Errorf("%s: timeout-minutes is %s; want %dm", where, capMin, verifyCeilingMinutes) - } - // The plain step runs ahead of the race step in the same job, and each - // package in it gets the whole of this limit. - if step, ok := workflowStepBlock(verify, "Test"); !ok { - t.Errorf("%s: no `Test` step", where) - } else if m := regexp.MustCompile(`\bgo test\b.*\s-timeout[ =](\S+)`).FindStringSubmatch(step); m == nil { - t.Errorf("%s step Test sets no -timeout, so each package inherits go test's 10m default", where) - } else if d, err := time.ParseDuration(m[1]); err != nil { - t.Errorf("%s step Test: -timeout %q: %v", where, m[1], err) - } else if d != verifyPlainTimeoutMinutes*time.Minute { - t.Errorf("%s step Test runs under -timeout %s; want %dm", where, d, verifyPlainTimeoutMinutes) - } - } } -// verifyCeilingMinutes is the timeout-minutes of release.yml's verify job. It holds -// the limits that run in sequence, 40, 70 and the smoke step's 8, with three minutes -// for the untimed steps, 121 in all (TestEvalLaneBudgetIsDeclaredAndFitsItsJob), and -// about twice the job's 58.3 minutes on the v0.16.2 cut (dcn-2611062222587959). No -// caller holds a shorter limit. -const verifyCeilingMinutes = 125 - -// verifyPlainTimeoutMinutes is the -timeout of the verify job's plain Test step: -// twice its slowest package's 844 seconds on the v0.16.2 cut is about 28 minutes, -// and the margin is left for that package's growth (dcn-2611062222587959). -const verifyPlainTimeoutMinutes = 40 - // checkMacOSCeilingMinutes is the timeout-minutes of each shard of the macOS suite, // on the nightly run and on a release cut alike. The suite ran as one job until 2026-11-04, whose ceiling rose from // 45 to 85 as its runs grew (dcn-2610181756328249, dcn-2610282036219503) and which diff --git a/internal/core/lint/releasequeuegate_test.go b/internal/core/lint/releasequeuegate_test.go new file mode 100644 index 0000000000..42013ac9d0 --- /dev/null +++ b/internal/core/lint/releasequeuegate_test.go @@ -0,0 +1,326 @@ +package lint_test + +import ( + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" + "testing" + "time" +) + +// release.yml's verify job used to re-run the merge queue's tests (build, vet, +// the plain and race passes, smoke) on a commit the queue had already passed: +// 55 to 85 Linux minutes a release attempt, and the only verify failures in a +// month were flakes on trees the queue had passed (iss-2612031238180751). verify +// now runs only what is particular to a release, and in place of the tests it +// requires the queue's own Linux check on the released commit. That check is a +// trust boundary: a green check run is admitted only from GitHub Actions, on +// this repository, at the released sha, from a merge_group run of ci.yml, and +// only when its latest attempt completed with success. These tests hold the +// job's shape and execute the step's own script against a fake gh answering the +// one GraphQL read it makes. + +// queueGateStep is the name of verify's merge-queue step; the release-gate +// runbook lists it as a deterministic gate (gate_lockstep). +const queueGateStep = "Merge queue check passed on the released commit (fail-closed)" + +// verifyCeilingMinutes is the timeout-minutes of release.yml's verify job. It +// runs no test now: the gate's one API read, the record and docs lints, the +// reviews charter, the archive render and the tag check, each compiling on a +// runner with no cache. A limit here only frees a stuck runner. +const verifyCeilingMinutes = 20 + +// verifyRunsNoTest names what verify no longer runs, each proved by the queue's +// check (ubuntu-latest) on the same commit. +var verifyRunsNoTest = regexp.MustCompile(`(?m)^\s+run: .*\b(go test|go build|go vet|make smoke|make fmt-check|make evals-cold-reading)\b`) + +func TestReleaseVerifyTrustsTheMergeQueueCheck(t *testing.T) { + root := filepath.Join("..", "..", "..") + const file = ".github/workflows/release.yml" + verify, ok := workflowJobBlock(readRepoFile(t, root, file), "verify") + if !ok { + t.Fatalf("%s has no verify job", file) + } + const where = file + " job verify" + + if m := verifyRunsNoTest.FindString(verify); m != "" { + t.Errorf("%s still runs %q; the merge queue's check (ubuntu-latest) ran it on this commit, and verify reads that check instead", where, strings.TrimSpace(m)) + } + if got := jobTimeoutMinutes(t, where, verify); got != verifyCeilingMinutes*time.Minute { + t.Errorf("%s: timeout-minutes is %s; want %dm", where, got, verifyCeilingMinutes) + } + + // Least privilege: the checkout, and the two read scopes the GraphQL read + // of check suites and their workflow runs needs. Nothing writes. + perms := regexp.MustCompile(`(?m)^ permissions:\n((?: \S.*\n)+)`).FindStringSubmatch(verify + "\n") + if perms == nil { + t.Fatalf("%s declares no job-level permissions", where) + } + var scopes []string + for _, l := range strings.Split(strings.TrimSpace(perms[1]), "\n") { + scopes = append(scopes, strings.TrimSpace(strings.SplitN(l, "#", 2)[0])) + } + if want := []string{"contents: read", "checks: read", "actions: read"}; strings.Join(scopes, ",") != strings.Join(want, ",") { + t.Errorf("%s permissions are %q; want exactly %q", where, scopes, want) + } + + step, ok := workflowStepBlock(verify, queueGateStep) + if !ok { + t.Fatalf("%s has no %q step", where, queueGateStep) + } + // First, so nothing is checked out or compiled while the token is in scope + // and a refused commit costs no more than the read. + if first := regexp.MustCompile(`(?m)^ - name: (.+)$`).FindStringSubmatch(verify); first == nil || first[1] != queueGateStep { + t.Errorf("%s: %q must be the job's first step", where, queueGateStep) + } + for _, want := range []string{ + "GH_TOKEN: ${{ github.token }}", + // The commit verify gates and the tag job tags, resolved the same way. + "GATED_COMMIT: ${{ inputs.ref || github.sha }}", + } { + if !strings.Contains(step, "\n "+want+"\n") { + t.Errorf("%s step %q does not set %s in its env", where, queueGateStep, want) + } + } + if script := stepScript(t, findStep(t, verify, file, "GATED_COMMIT: ${{")); strings.Contains(script, "${{") { + t.Errorf("%s step %q interpolates an expression into its script; values arrive through env", where, queueGateStep) + } + + // A called workflow is capped by its caller's grants: without these the + // verify job's request fails the whole run before any job starts. + caller, ok := workflowJobBlock(readRepoFile(t, root, ".github/workflows/auto-release.yml"), "release") + if !ok { + t.Fatal("auto-release.yml has no release job") + } + for _, want := range []string{"checks: read", "actions: read"} { + if !regexp.MustCompile(`(?m)^ ` + regexp.QuoteMeta(want) + `\b`).MatchString(caller) { + t.Errorf("auto-release.yml job release does not grant %s, which release.yml's verify job asks for", want) + } + } +} + +// fakeQueueGH answers the two reads the step makes. `gh api graphql` is served +// from $FAKE_DIR/response.json, and refused unless it asks for the released +// commit in the repository the run belongs to. `gh api` of a run's latest jobs +// is served from $FAKE_DIR/jobs-.json, and records that it was read in +// $FAKE_DIR/jobs-read. Each applies the step's own --jq filter. +const fakeQueueGH = `set -euo pipefail +[ "$1" = api ] || { echo "fake gh: $1 is not faked" >&2; exit 99; } +shift +if [ "$1" != graphql ]; then + path="$1"; shift; expr="" + while [ $# -gt 0 ]; do + case "$1" in + --jq) expr="$2"; shift 2 ;; + --paginate) shift ;; + *) echo "fake gh: unexpected argument $1" >&2; exit 96 ;; + esac + done + case "$path" in + "repos/$GITHUB_REPOSITORY/actions/runs/"*"/jobs?filter=latest&per_page=100") ;; + *) echo "fake gh: unexpected path $path" >&2; exit 95 ;; + esac + run="${path#repos/$GITHUB_REPOSITORY/actions/runs/}"; run="${run%%/*}" + : >"$FAKE_DIR/jobs-read" + if [ -f "$FAKE_DIR/jobs-fail" ]; then echo "gh: HTTP 502: Server Error" >&2; exit 1; fi + [ -f "$FAKE_DIR/jobs-$run.json" ] || { echo "gh: HTTP 404: Not Found" >&2; exit 1; } + jq -r "$expr" "$FAKE_DIR/jobs-$run.json" + exit 0 +fi +shift +expr=""; owner=""; name=""; sha=""; query="" +while [ $# -gt 0 ]; do + case "$1" in + -f|-F) + case "$2" in + owner=*) owner="${2#owner=}" ;; + name=*) name="${2#name=}" ;; + sha=*) sha="${2#sha=}" ;; + query=*) query="${2#query=}" ;; + *) echo "fake gh: unexpected field $2" >&2; exit 96 ;; + esac + shift 2 ;; + --jq) expr="$2"; shift 2 ;; + *) echo "fake gh: unexpected argument $1" >&2; exit 96 ;; + esac +done +if [ "$owner/$name" != "$GITHUB_REPOSITORY" ] || [ "$sha" != "$GATED_COMMIT" ]; then + echo "fake gh: read not scoped to $GITHUB_REPOSITORY at $GATED_COMMIT (owner=$owner name=$name sha=$sha)" >&2; exit 97 +fi +case "$query" in + *'appId: 15368'*'checkName: "check (ubuntu-latest)"'*'checkType: LATEST'*) ;; + *) echo "fake gh: the query does not filter to GitHub Actions and the latest check (ubuntu-latest)" >&2; exit 98 ;; +esac +if [ -f "$FAKE_DIR/fails" ]; then echo "gh: Resource not accessible by integration" >&2; exit 1; fi +jq -r "$expr" "$FAKE_DIR/response.json" +` + +func TestReleaseQueueGateAdmitsOnlyTheQueuesOwnCheck(t *testing.T) { + if _, err := exec.LookPath("jq"); err != nil { + if os.Getenv("CI") != "" { + t.Fatal("jq is required to fake gh's --jq and is missing on a CI runner") + } + t.Skip("jq not on PATH; the fake gh needs it to apply the step's --jq filter") + } + root := filepath.Join("..", "..", "..") + const file = ".github/workflows/release.yml" + verify, ok := workflowJobBlock(readRepoFile(t, root, file), "verify") + if !ok { + t.Fatalf("%s has no verify job", file) + } + script := stepScript(t, findStep(t, verify, file, "GATED_COMMIT: ${{")) + + const ( + repo = "intentdriven/abcd" + sha = "0123456789abcdef0123456789abcdef01234567" + other = "89abcdef0123456789abcdef0123456789abcdef" + runID = "4709" // the merge_group run of ci.yml + jobID = "144199" // its check (ubuntu-latest) job, which is also that job's check run + apiID = "144777" // a check run made through the Checks API: no job of the run + ) + // suite is one check suite as the GraphQL read returns it, with the id of + // its workflow run and of the check run it holds. + type suite struct { + app, repo, oid, event, path, check, status, conclusion string + run, checkRun string + noRun bool // a suite no workflow run owns + } + good := suite{app: "15368", repo: repo, oid: sha, event: "merge_group", path: ".github/workflows/ci.yml", + check: "check (ubuntu-latest)", status: "COMPLETED", conclusion: "SUCCESS", run: runID, checkRun: jobID} + render := func(total string, suites []suite) string { + var nodes []string + for _, s := range suites { + run := `{"databaseId":` + s.run + `,"event":"` + s.event + `","file":{"path":"` + s.path + `"},"url":"https://example.invalid/run"}` + if s.noRun { + run = "null" + } + conclusion := `"` + s.conclusion + `"` + if s.conclusion == "" { + conclusion = "null" + } + nodes = append(nodes, `{"app":{"databaseId":`+s.app+`},"repository":{"nameWithOwner":"`+s.repo+ + `"},"commit":{"oid":"`+s.oid+`"},"workflowRun":`+run+ + `,"checkRuns":{"nodes":[{"databaseId":`+s.checkRun+`,"name":"`+s.check+`","status":"`+s.status+`","conclusion":`+conclusion+`}]}}`) + } + return `{"data":{"repository":{"object":{"checkSuites":{"totalCount":` + total + + `,"nodes":[` + strings.Join(nodes, ",") + `]}}}}}` + } + with := func(f func(*suite)) suite { s := good; f(&s); return s } + + // job is one entry of the run's latest jobs, as the Actions API lists it. + type job struct{ id, name, run, sha, status, conclusion, checkRunURL string } + goodJob := job{id: jobID, name: "check (ubuntu-latest)", run: runID, sha: sha, status: "completed", conclusion: "success", + checkRunURL: "https://api.github.com/repos/" + repo + "/check-runs/" + jobID} + withJob := func(f func(*job)) job { j := goodJob; f(&j); return j } + jobs := func(js ...job) string { + var out []string + for _, j := range js { + out = append(out, `{"id":`+j.id+`,"run_id":`+j.run+`,"name":"`+j.name+`","head_sha":"`+j.sha+ + `","status":"`+j.status+`","conclusion":"`+j.conclusion+`","check_run_url":"`+j.checkRunURL+`"}`) + } + return `{"total_count":` + strconv.Itoa(len(js)) + `,"jobs":[` + strings.Join(out, ",") + `]}` + } + ciJobs := jobs(job{id: "144198", name: "changes", run: runID, sha: sha, status: "completed", conclusion: "success", + checkRunURL: "https://api.github.com/repos/" + repo + "/check-runs/144198"}, goodJob) + // The forgery: a check run of the right name and outcome, made through the + // Checks API into the merge_group suite, while the run's own job failed. + forged := with(func(s *suite) { s.checkRun = apiID }) + failedJob := jobs(withJob(func(j *job) { j.conclusion = "failure" })) + + cases := []struct { + name string + response string // "" with fails set: the read errors + jobs string // the run's latest jobs; "" serves none (a 404) + commit string + fails bool + jobsFail bool + admit bool + readsJobs bool // the step must have read the run's jobs + }{ + {name: "the queue's check passed", response: render("2", []suite{with(func(s *suite) { s.event = "push" }), good}), jobs: ciJobs, admit: true, readsJobs: true}, + {name: "a job-matched check run is admitted", response: render("1", []suite{good}), jobs: jobs(goodJob), admit: true, readsJobs: true}, + {name: "an API-made check run with no matching job", response: render("1", []suite{forged}), jobs: failedJob, readsJobs: true}, + {name: "an API-made check run beside the job's own success", response: render("1", []suite{forged}), jobs: ciJobs, readsJobs: true}, + {name: "the run's job failed", response: render("1", []suite{good}), jobs: failedJob}, + {name: "the run's job is still running", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { j.status = "in_progress"; j.conclusion = "" }))}, + {name: "the run has no job of that name", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { j.name = "check (macos-latest)" }))}, + {name: "the job belongs to another run", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { j.run = "999" }))}, + {name: "the job ran on another commit", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { j.sha = other }))}, + {name: "the job names another check run", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { + j.checkRunURL = "https://api.github.com/repos/" + repo + "/check-runs/" + apiID + }))}, + {name: "the job's check run is another repository's", response: render("1", []suite{good}), jobs: jobs(withJob(func(j *job) { + j.checkRunURL = "https://api.github.com/repos/someone/abcd/check-runs/" + jobID + }))}, + {name: "the run's jobs cannot be read", response: render("1", []suite{good}), jobs: ciJobs, jobsFail: true}, + {name: "the run's jobs are not found", response: render("1", []suite{good})}, + {name: "no check suite at all (a commit the queue never tested)", response: render("0", nil)}, + {name: "the commit is not in the repository", response: `{"data":{"repository":{"object":null}}}`}, + {name: "the check came from a pull_request run", response: render("1", []suite{with(func(s *suite) { s.event = "pull_request" })}), jobs: ciJobs}, + {name: "the check came from a dispatched run", response: render("1", []suite{with(func(s *suite) { s.event = "workflow_dispatch" })}), jobs: ciJobs}, + {name: "the check came from another workflow file", response: render("1", []suite{with(func(s *suite) { s.path = ".github/workflows/other.yml" })}), jobs: ciJobs}, + {name: "the check came from another repository", response: render("1", []suite{with(func(s *suite) { s.repo = "someone/abcd" })}), jobs: ciJobs}, + {name: "the check ran on another commit", response: render("1", []suite{with(func(s *suite) { s.oid = other })}), jobs: ciJobs}, + {name: "the check came from another app", response: render("1", []suite{with(func(s *suite) { s.app = "99" })}), jobs: ciJobs}, + {name: "the suite belongs to no workflow run", response: render("1", []suite{with(func(s *suite) { s.noRun = true })}), jobs: ciJobs}, + {name: "another check of that suite", response: render("1", []suite{with(func(s *suite) { s.check = "check (macos-latest)" })}), jobs: ciJobs}, + {name: "the check failed", response: render("1", []suite{with(func(s *suite) { s.conclusion = "FAILURE" })}), jobs: ciJobs}, + {name: "the check was skipped", response: render("1", []suite{with(func(s *suite) { s.conclusion = "SKIPPED" })}), jobs: ciJobs}, + {name: "the check is still running", response: render("1", []suite{with(func(s *suite) { s.status = "IN_PROGRESS"; s.conclusion = "" })}), jobs: ciJobs}, + {name: "more suites than one read lists", response: render("101", []suite{good}), jobs: ciJobs}, + {name: "the read fails", fails: true}, + {name: "the released commit is not a full sha", commit: "0123456", response: render("1", []suite{good}), jobs: ciJobs}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + fake := t.TempDir() + write := func(name, body string) { + if err := os.WriteFile(filepath.Join(fake, name), []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + if c.fails { + write("fails", "") + } else { + write("response.json", c.response) + } + if c.jobs != "" { + write("jobs-"+runID+".json", c.jobs) + } + if c.jobsFail { + write("jobs-fail", "") + } + bin := t.TempDir() + fakeTool(t, bin, "gh", fakeQueueGH) + summary := filepath.Join(t.TempDir(), "summary") + commit := sha + if c.commit != "" { + commit = c.commit + } + out, code := runScript(t, script, t.TempDir(), bin, map[string]string{ + "FAKE_DIR": fake, "GH_TOKEN": "fake", "GITHUB_REPOSITORY": repo, "GITHUB_API_URL": "https://api.github.com", + "GATED_COMMIT": commit, "TAG": "v1.2.3", "GITHUB_STEP_SUMMARY": summary, + }) + if strings.Contains(out, "fake gh:") { + t.Fatalf("the step's read was not what the fake accepts:\n%s", out) + } + if _, err := os.Stat(filepath.Join(fake, "jobs-read")); c.readsJobs && err != nil { + t.Errorf("the step never read the run's jobs, so nothing tied the check run to a job of that run:\n%s", out) + } + if c.admit && code != 0 { + t.Fatalf("the step refused a commit the queue's check passed (exit %d):\n%s", code, out) + } + if !c.admit { + if code == 0 { + t.Fatalf("the step admitted it:\n%s", out) + } + if !strings.Contains(out, "refusing to release 'v1.2.3'") { + t.Errorf("the refusal does not name the release:\n%s", out) + } + } + }) + } +}