mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-30 20:04:15 +01:00
Landing a PR reuses an earlier CI run on the same merged code instead of starting another (GST-3634) (#4760)
When main has moved, `gstack-ship-queue land --pin` now reuses an earlier CI run on the same merged code: it lands at once on a green run, waits on one still queued and refuses on a red one, instead of starting a new run on every try. Why: GitHub's macOS runner queue has been slower than land's 45-minute wait, so lands kept timing out while the run they started finished green unused. Nothing to do. Rerunning a timed-out land now waits on the run it named. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/specialist-batched#2 reader=testing
This commit is contained in:
1 parent
78ee2966d3
commit
1cb381b048
8 files changed
+201
-34
No files matched your search
+19
-2
@@ -82,7 +82,7 @@ branch that changes the policy.
|
||||
| `docs` | `{ caps: [{ path, max_bytes }] }` or `null` | `null` | Documentation files with a byte cap. `/ship` Step 14.5 runs `gstack-ship-receipt docs-caps --base <base>` (the caps come from `origin/<base>`'s policy, never the branch's copy; `--policy <file>` is for a repository bootstrapping its policy) before the verification gate and prints one `DOCS_CAP: <path> <bytes>/<max> ok\|over` line per cap; any `over` (an absent file counts) exits 1 and blocks the ship until the file is trimmed or the cap raised on the base branch (`DOCS_AUDIT_BLOCKED`). At most 64 caps, each path contained. See [the ship receipt](#ship-receipt). Needs `min_gstack_version`. |
|
||||
| `train` | `{ gate_workflow, free_workflow, full_gate_check, record_artifact, max_size, fill_hours, screen_selection, trial_reservation_usd, land? }`, `{ gates, land, max_size, fill_hours }` or `null` | `null` | Turns on [merge trains](#run-a-merge-train), read from the base revision only. Every field is required and an unknown field is `POLICY_INVALID`: `max_size` 1 to 6, `fill_hours` above 0 and at most 24, `screen_selection` `gstack-paid` \| `none`, `trial_reservation_usd` above 0 and at most 100. A block with `gates` ([any repository](#train-gates)) takes `max_size` 1 to 5 and needs `min_gstack_version` at least `TRAIN_GATES_KEY_VERSION`. `null` keeps the per-PR queue exactly as it is. Needs `min_gstack_version`. |
|
||||
| `merge` | `train` \| `direct` | `train` | `direct` lands each READY PR at its own green head with [`land --pr <n> --pin <sha>`](#land-direct): no train and no stamp commit, and `train build` refuses. A PR then leaves VERSION, the `package.json` version and the CHANGELOG at its merge base, and the release sets them. Needs `changelog_fragments`, and the stamping `land --pr <n>` refuses under it. `train` keeps merge trains. Read from the base revision only. Needs `min_gstack_version`. |
|
||||
| `land` | `{ merged_checks?, docs_only_skip?, merge_commit_paths?, merged_ci? }` or `null` | `null` | Under `merge: direct`, the shell commands (1 to 16, one line of at most 512 characters each, 15 minutes each) [`land --pin`](#land-direct) runs on the pin merged onto the base tip when the base moved past the pin's merge base; it lands only when every one exits 0. They are repo commands, so land runs them only with `--allow-repo-commands`, never under `--dry-run`. `null` lands a stale base untested with a `STALE_BASE: warn` line. `docs_only_skip` lists `merged_checks` commands to skip for a docs-only pin ([pregate.md](pregate.md#docs-only)) and needs `min_gstack_version` at its own release (`LAND_DOCS_ONLY_SKIP_KEY_VERSION`), because older releases refuse it. `merge_commit_paths` (1 to 64 git glob pathspecs, no `..`) makes every land form keep a merge commit, with the plain subject and body, for a PR that changes a matching path, such as an eval results PR whose run records point to its own commits; with it, `merged_checks` may be left out, and it needs `min_gstack_version` at its own release (`LAND_MERGE_COMMIT_PATHS_KEY_VERSION`). `merged_ci` (`{ workflow, profile }`) dispatches that workflow on the merged commit after any `merged_checks` pass and lands only when its run passes the named run profile of `.gstack/pregate.json` ([land --pin](#land-direct)); with it, `merged_checks` may be left out, and an older gstack ignores it with a warning. Any other key under `land` is a warning, ignored. Read from the base revision only. Needs `min_gstack_version`. |
|
||||
| `land` | `{ merged_checks?, docs_only_skip?, merge_commit_paths?, merged_ci? }` or `null` | `null` | Under `merge: direct`, the shell commands (1 to 16, one line of at most 512 characters each, 15 minutes each) [`land --pin`](#land-direct) runs on the pin merged onto the base tip when the base moved past the pin's merge base; it lands only when every one exits 0. They are repo commands, so land runs them only with `--allow-repo-commands`, never under `--dry-run`. `null` lands a stale base untested with a `STALE_BASE: warn` line. `docs_only_skip` lists `merged_checks` commands to skip for a docs-only pin ([pregate.md](pregate.md#docs-only)) and needs `min_gstack_version` at its own release (`LAND_DOCS_ONLY_SKIP_KEY_VERSION`), because older releases refuse it. `merge_commit_paths` (1 to 64 git glob pathspecs, no `..`) makes every land form keep a merge commit, with the plain subject and body, for a PR that changes a matching path, such as an eval results PR whose run records point to its own commits; with it, `merged_checks` may be left out, and it needs `min_gstack_version` at its own release (`LAND_MERGE_COMMIT_PATHS_KEY_VERSION`). `merged_ci` (`{ workflow, profile }`) dispatches that workflow on the merged commit after any `merged_checks` pass, or waits on an earlier land's run of it on the same merged tree, and lands only when that run passes the named run profile of `.gstack/pregate.json` ([land --pin](#land-direct)); with it, `merged_checks` may be left out, and an older gstack ignores it with a warning. Any other key under `land` is a warning, ignored. Read from the base revision only. Needs `min_gstack_version`. |
|
||||
| `docs_only` | `{ allow, deny?, tests? }` or `null` | `null` | Human-docs paths beyond `README.md`, `docs/**.md` and `changelog.d/*.md` for the [docs-only class](pregate.md#repo-docs-paths) (`{ "allow": ["wiki/board/**.md"] }`). `allow` (1 to 16) takes narrow Markdown globs: each ends in `.md`, starts with a literal directory or file name, and passes through no hidden, code, test or agent directory; `**`, `*`, `*.md` and patterns naming agent files are `POLICY_INVALID` with an example of a narrow one. `deny` (up to 64 globs) removes paths, built-in ones included. `tests` (up to 16 test files) are the repository's checks for those directories: the docs lane runs them, and a non-prose file that reads an allowed directory refuses the class unless it is tied to one; a listed test missing from the branch refuses it too. The built-in deny list always wins. Any other key under `docs_only` is a warning, and the classifier then ignores `allow`. Read from the base revision only; a pull request that edits this file is never docs-only. Needs `min_gstack_version`. |
|
||||
| `release_gate` | `{ cadence_hours, gate_workflow, branch, stable_ref, check_name, on_red, bisect_spend_cap_usd }` or `null` | `null` | One full paid gate on main every `cadence_hours` (8 to 168) instead of the per-push main backstop, feeding the stable release; see [release_gate](#release-gate). Every field is required: `on_red` is `hold-release`, `bisect_spend_cap_usd` 0 to 500 (0 skips the bisect). `null` keeps the per-push backstop. Needs `min_gstack_version`. |
|
||||
| `bookkeeping` | glob list | `[]` | <a id="bookkeeping"></a>Root-anchored globs of bookkeeping tables a verify or ratchet step rewrites (size baselines, serial lists, limits), each ending in `.tsv`, `.csv` or `.txt` and never under `.gstack/` or `.github/` (`["scripts/*-baseline.tsv"]`). A matching file changed at most 20 lines after review binds, first touched or not, takes finish's [one scoped reader](review-policy.md#bounded-post-review-edits) instead of Steps 5–11.5; the reader still reads every changed row. Read from the base revision only. Needs `min_gstack_version`. |
|
||||
@@ -3105,10 +3105,27 @@ on the same merged tree: it pushes the merged commit to the scratch branch
|
||||
`gstack-land/<n>`, dispatches the workflow there, waits up to 45 minutes, and
|
||||
prints `MERGED_CI: pass <workflow> run <url> on the merged tree <tree> (profile
|
||||
<profile>)` only when `lib/run-evidence.ts` accepts the run under that run profile
|
||||
of the base's `.gstack/pregate.json`, with the merged commit as its head and the
|
||||
of the base's `.gstack/pregate.json`, with the run's head commit as its head and the
|
||||
merged tree as its tested tree. A red run refuses with
|
||||
`QUEUE_LAND_MERGED_CHECKS`; a run that can't be pushed, dispatched, finished in
|
||||
time or proved refuses with `QUEUE_NOT_READY`; the branch is deleted either way.
|
||||
|
||||
Every land builds a new merged commit, so before it dispatches, land looks for a
|
||||
run an earlier land already started on the same tree: a `workflow_dispatch` run
|
||||
of the workflow on `gstack-land/<n>` (GitHub keeps the run and its branch name
|
||||
after the branch is deleted) or at this merged commit, whose head commit has the
|
||||
merged tree. It matches on the tree, never the commit. The newest such run that
|
||||
wasn't cancelled decides: a finished green run lands with no new dispatch (the
|
||||
`MERGED_CI` line adds `run by an earlier land at <commit>, not dispatched
|
||||
again`), a run still queued or running is waited on for up to 45 minutes, and a
|
||||
red one refuses with `QUEUE_LAND_MERGED_CHECKS`. Only a finished green run that
|
||||
no longer proves the tree (its artifact expired, or it is past the profile's
|
||||
`max_age_hours`) is passed over for a fresh dispatch. So when GitHub's runner
|
||||
queue is slower than 45 minutes, the timeout's `QUEUE_NOT_READY` names the run,
|
||||
and rerunning the same `land` while main hasn't moved waits on that run, or lands
|
||||
at once when it has already passed, instead of joining the queue again. For a
|
||||
flaky red run, rerun the run once (`gh run rerun <id>`) and then land, which
|
||||
waits on its new attempt; rerunning land alone finds the same red run.
|
||||
The run is on CI runners, so it needs no `--allow-repo-commands`, and
|
||||
`--dry-run` dispatches nothing. gstack's own policy dispatches `free-tests.yml`
|
||||
under `ci-reuse/free-tests`, so the whole free suite has run on a stale-base tree
|
||||
|
||||
+15
-3
@@ -6287,7 +6287,11 @@ green, a name in `changelog_fragments.required_checks` is missing or not green
|
||||
there, the PR's base is no longer the train's base, the stamp push failed while
|
||||
the branch still read the pin, `gh pr merge` refused, or the merge is not yet
|
||||
visible on main. `land` also uses it when a land lock push to origin failed and
|
||||
origin's lock ref could not be read to tell whether the push landed.
|
||||
origin's lock ref could not be read to tell whether the push landed, and when
|
||||
the `land.merged_ci` run on the merged tree could not be pushed, dispatched,
|
||||
finished within 45 minutes or proved ([land --pin](ship-policy.md#land-direct)).
|
||||
A timeout names the run it was waiting on, which is often just sitting in
|
||||
GitHub's macOS runner queue.
|
||||
|
||||
**Fix.** Commit and push, wait for CI on that head, rerun
|
||||
`gstack-pregate run --allow-repo-commands` when the tree changed, then rerun
|
||||
@@ -6298,7 +6302,12 @@ trial-merge fetch timeout, fetch the named refs by hand
|
||||
(`git fetch origin <ref>`) or raise `GSTACK_TRIAL_FETCH_TIMEOUT_MS`, then
|
||||
rerun ready. For an
|
||||
unreadable land lock, rerun the same `land` command once origin answers; it
|
||||
resumes its own lock.
|
||||
resumes its own lock. For a `land.merged_ci` timeout, rerun the same `land`
|
||||
command whenever you like and don't cancel the named run: while `origin/main`
|
||||
hasn't moved, the merged tree is the same, so land waits on that run for up to
|
||||
45 more minutes, or lands at once when it has already passed, instead of
|
||||
dispatching a new run that waits in the same queue. Once main moves, the merged
|
||||
tree changes and land dispatches a run for the new one.
|
||||
|
||||
<a id="queue-base-unfetched"></a>
|
||||
### `QUEUE_BASE_UNFETCHED`
|
||||
@@ -6620,7 +6629,10 @@ added) before any git command in that checkout, then release the lock without
|
||||
running the checks with `gstack-ship-queue land --pr <n> --pin <sha>` (no
|
||||
`--allow-repo-commands`), and find out why the PR's checks wrote there before it
|
||||
lands. For a failed command or a red CI run, read the output or the failed job;
|
||||
a flaky case gets one rerun of land, and a real failure goes back to the lane,
|
||||
a flaky case gets one rerun (for a failed command, rerun land; for a red
|
||||
`land.merged_ci` run, rerun that run with `gh run rerun <id>` and then land,
|
||||
which waits on its new attempt, because land reuses the newest run on the same
|
||||
merged tree and would otherwise find the same red run), and a real failure goes back to the lane,
|
||||
which merges `origin/main` into the branch, fixes it, pushes, waits for the
|
||||
required checks, runs /ship and `ready` at the new head, and sends a new READY.
|
||||
|
||||
|
||||
Reference in new issue
Block a user