diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72605abe6..148135de0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -190,7 +190,7 @@ the new defaults. | Run one free test file while repairing | `bun test ` | Free, seconds | Never bare `bun test` for the suite | | Run full free acceptance before publishing | `bun run test` | Free, a few minutes | Bun 1.4.2 | | Run the full free suite from a small machine | `bun run test:ubicloud` | Free suite on a billed 16-vCPU VM, about 5 minutes | `UBICLOUD_API_KEY`, `UBI_OWNER` | -| Clear pregate's test tier on a machine under 8 cores from CI, the default on gstack ([CI carry](docs/pregate.md#ci-carry)) | push, `gstack-ci-carry wait --base main`, then `gstack-pregate --allow-repo-commands` (a branch behind main first runs `gh workflow run free-tests.yml --ref `) | Free; reuses the green Free Tests run at your pushed tree | Pushed branch, `gh` | +| Clear pregate's test tier on a machine under 8 cores from CI, the default on gstack ([CI carry](docs/pregate.md#ci-carry)) | push, `gstack-ci-carry wait --base main`, then `gstack-pregate --allow-repo-commands` (on a branch behind main, a green pull request run still counts when main changed none of your lines; when a `CARRY_DIAGNOSIS:` line says it doesn't, run `gh workflow run free-tests.yml --ref ` first) | Free; reuses the green Free Tests run at your pushed tree | Pushed branch, `gh` | | Clear pregate's test tier on a machine under 8 cores when no CI run covers your tree ([remote gate](docs/pregate.md#remote-gate), opt-in) | `gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands` (same command keyed or keyless) | Keyed: one billed 16-vCPU VM, about 7 minutes and $0.06 for the whole free tier, worst case $0.38; keyless: free, local parallel shards, practical for small selections only (98 files took 103 s on 4 cores) | Keyed: `UBICLOUD_API_KEY`, `UBI_OWNER`; keyless: nothing | | Run the curated Windows-safe subset | `bun run test:windows` (CI: eight `windows-latest` jobs, nightly on main; PRs run the shorter `windows-smoke` check, and a PR that touches path, file-name or process code also runs its changed Windows-safe test files in `Windows Scoped Tests`) | Free | Windows, Git Bash | | Rerun chosen Windows-safe test files on Windows CI | `gh workflow run windows-scoped-tests.yml --ref -f files=' '` (pick files from `bun run test:windows --list`) | Free CI runners | Pushed branch, `gh` with workflow rights | diff --git a/bin/gstack-ci-carry b/bin/gstack-ci-carry index 554ac3a9c..4146b4757 100755 --- a/bin/gstack-ci-carry +++ b/bin/gstack-ci-carry @@ -75,6 +75,7 @@ function find(): number { else out(v.ok ? `CI_CARRY: accepted ${v.receipt}` : `CI_CARRY: none (${v.reason}: ${v.detail})`); const from = v.ok && !argv.includes('--json') ? carriedFromLine(v.runs, head) : undefined; if (from) out(from); + if (!v.ok && !argv.includes('--json')) for (const d of v.diagnosis ?? []) out(`CARRY_DIAGNOSIS: ${d}`); return v.ok ? 0 : 1; } diff --git a/changelog.d/green-ci-run-counts-when-only-main-moved-gst-3567.md b/changelog.d/green-ci-run-counts-when-only-main-moved-gst-3567.md new file mode 100644 index 000000000..6f0c68e21 --- /dev/null +++ b/changelog.d/green-ci-run-counts-when-only-main-moved-gst-3567.md @@ -0,0 +1,4 @@ +--- +important: blocker +--- +**/ship's final CI check no longer makes you rerun CI just because main moved.** A green pull request run that tested your branch merged onto a newer main now counts for your branch when your own added and removed lines in that merge are byte-identical to your branch's, so main changed none of your lines and none next to them; before, `gstack-ship-release accept` refused it with `tree_mismatch` and busy repos never converged. It still refuses when main changed one of your lines or one next to it or the run tested another commit, and a `CARRY_DIAGNOSIS:` line says which. Landing still checks the merged tree with `land.merged_ci`; a repo whose `land` is `null` gets no merged-tree check. docs/ship-policy.md#ci-carry-base-moved (GST-3567) diff --git a/docs/pregate.md b/docs/pregate.md index 10fd2a53f..40b94002e 100644 --- a/docs/pregate.md +++ b/docs/pregate.md @@ -951,7 +951,8 @@ once: `tree.json` must name the head (`head_sha`) and the merge commit (`sha`), and the tree git computes for that merge commit must equal the head's tree: the head already contained its base, so the merge tested exactly the head tree - (`tree_mismatch` otherwise). The API answers with + (`tree_mismatch` otherwise), unless only the base moved + ([below](#base-moved-carry)). The API answers with the newest attempt, so an earlier green attempt under a newer red one is refused, and the run is read again after the evidence is collected: a new attempt meanwhile is `run_changed`. A newer run of the same workflow on the @@ -1259,8 +1260,18 @@ the Ubicloud VM (`gstack-pregate --stage tests --remote`) is an opt-in for when no such run exists. The order after a push: wait for Free Tests (`gstack-ci-carry wait --base main`), then `gstack-pregate --allow-repo-commands`. A `pull_request` run tests GitHub's merge commit, so on -a branch that does not contain the base tip it tested another tree and -`CI_CARRY` says `none (no_verified_run: … tree_mismatch)`: dispatch Free Tests +a branch that does not contain the base tip it tested another tree. +That run still carries for HEAD when only the base +moved (GST-3567): the merge commit is HEAD merged onto a commit of the base, and +the pull request's own added and removed lines in it are byte-identical to +HEAD's at the same places (`lib/pregate/run-check.ts` `onlyBaseMoved`, used by every lane carry and by +`clear --run`, never by land's merged-tree CI; why that is safe: +[ship-policy.md](ship-policy.md#ci-carry-base-moved)). The receipt adds +`base_moved=`. GitHub merges onto the base as it was when the run +started, so when that base commit is newer than your checkout's `origin/main`, +the check fetches main once before it refuses. Otherwise `CI_CARRY` says +`none (no_verified_run: … tree_mismatch)`, with a `CARRY_DIAGNOSIS:` line +when the rule refused: dispatch Free Tests on the branch (`gh workflow run free-tests.yml --ref `), which tests HEAD's own tree, and wait again. When the pull_request run tested that merge commit, the diff --git a/docs/ship-policy.md b/docs/ship-policy.md index 3181bdbf7..86dfb2d76 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -2955,9 +2955,35 @@ body plain: they become main's history. note each name a sha, so after any push, a merge of main included, land refuses until checks are green and `ready` has run at the new head (the receipt itself can [carry across a base merge](#carrying-a-receipt-across-a-base-merge-or-a-test-only-fix)). - A `pull_request` CI run tests GitHub's merge commit rather than your branch, - so on a branch behind main `gstack-ci-carry` reports `tree_mismatch`: - dispatch the workflow on the branch (`gh workflow run --ref `). + A `pull_request` CI run tests GitHub's merge commit rather than your branch: + your branch merged onto main as main was when the run started. +- **A green run carries across a base move + when only the base moved (GST-3567).** When main has moved past your + branch's fork point, that merge commit's tree is not your head's tree. The + lane carry (`gstack-ship-release accept`, `gstack-evidence record-ci`, + `gstack-ci-carry`, and pregate's own carry and `clear --run`) still counts + the green run for your head when the merge commit's parents are a commit on + main and then your pushed head, and your pull request's own added and + removed lines in that merge are byte-identical to your head's, at the same + places (the zero-context patch-id and hunk positions `lib/review-round-grant.ts` + `ownLinesSame` compares for a base-only merge of a reviewed head). Main may + have changed other files, or other parts of the files you changed, but no + line you changed and none next to one. The `CI_CARRY:` receipt + then adds `base_moved=
`. This is safe for two reasons. The run + tested exactly your pull request's changes, on a main newer than the one + your head forked from, so it tested no less than a run of your head's own + tree would have. And neither run tested the tree that lands: under + `merge: direct`, [`land --pin`](#land-direct) checks that tree itself with + `land.merged_ci` (CI on the pin merged onto the tip) and + `land.merged_checks`, and its verification never takes this rule + (`lib/land-merged-ci.ts` calls `verifyRun` without it). A repo whose `land` + is `null` lands a stale base unchecked (`STALE_BASE: warn`) either way. + The run still doesn't carry when main also changed a line your pull request + changes or one next to it, when the merge is of a commit other than your pushed head, or when + the run isn't green. A `CARRY_DIAGNOSIS:` line says which, and `tree_mismatch` + keeps its fix: dispatch the workflow on the branch + (`gh workflow run --ref `), which tests your head's own + tree, or, when it can't be dispatched, merge main and push. - **A carried run that passed only after a re-run is marked, not refused.** When only a run's failed jobs were re-run, its `tree.json` may list `rerun_files` (the files whose newest result came from a re-run attempt) and diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 44c9e7f61..c94dd3408 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -763,7 +763,16 @@ command `origin/`'s `.gstack/pregate.json` maps in `ship_lanes_from`, and no verified CI run carries it at this tree: the `CI_CARRY: none label=