diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ea92d9af1c6..1e8de080727 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -3,31 +3,33 @@ name: Check permissions: contents: read -# Main PRs report Check as skipped; the merge queue tests each one (queue.yml). -# Release PRs run the same gate over every package. +# Ready main PRs run the merge queue's selection as a signal, never a gate. +# Release PRs run the same checks over every package, including while drafts. on: pull_request: - # `closed` only cancels an in-flight run. `edited` runs the jobs when a main - # PR is retargeted to release. Any edit reruns them, since a skipped rerun - # would post a passing context over a failed one; on main PRs that is free. - types: [opened, synchronize, reopened, edited, closed] + # Closing or returning a main PR to draft cancels its in-flight run. + # Any edit reruns eligible PRs, including a retarget to main or release: + # skipping an edit would replace a failed context with a passing one. + # Release readiness transitions rerun its required gate for the same reason. + types: [opened, synchronize, reopened, edited, ready_for_review, converted_to_draft, closed] # Cancel in-flight runs when a new commit lands on the same PR, or when the PR -# is merged/closed (the close event shares this group and supersedes the build). +# is merged/closed. The PR number survives a merge, when github.ref changes. concurrency: - group: check-${{ github.ref }} + group: check-${{ github.event.pull_request.number }} cancel-in-progress: true jobs: # One checkout, dev shell, cache restore, and dispatcher for lints and tests. check: name: Check - if: github.event.action != 'closed' && github.base_ref == 'release' + if: github.event.action != 'closed' && (github.base_ref == 'release' || (github.base_ref == 'main' && github.event.pull_request.draft == false)) runs-on: ubuntu-24.04-arm # Backstop a hang instead of holding the runner for the 6-hour default. timeout-minutes: 60 env: - CI_BASE: --all + # The fetched branch includes base changes since the PR event's base.sha. + CI_BASE: ${{ github.base_ref == 'release' && '--all' || 'origin/main' }} steps: - name: Checkout @@ -50,7 +52,7 @@ jobs: - uses: DeterminateSystems/flake-checker-action@786422608c7bded2bbc9741ad9f91356842bf520 # main if: steps.scope.outputs.needed == 'true' - # Release pull requests read the hosted cache; lint-only changes skip it. + # Pull requests read the hosted cache; lint-only changes skip it. - name: Rust cache if: steps.scope.outputs.rust == 'true' uses: ./.github/actions/rust-cache diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3e5a5483061..e3d2480a11f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -27,13 +27,13 @@ name: Nightly # exception: deterministic and seconds long, so audio-quality.yml also gates # release PRs on them. # -# Main PRs run no cloud CI beyond the landing gate's checks, so every +# Main PRs run only the landing gate's selection as a signal, so every # path-filtered gate (Android, C, C++, X11, the audio replays, the OSS # Scanner image, platform.yml and the release dry-runs) runs here on main too, # and release-gate.yml runs them on release PRs. # # A failure here lands on main rather than being caught in review, which is the -# accepted trade. Anything that must block a merge belongs in check.yml. +# accepted trade. Anything that must block a merge belongs in `just ci`. permissions: contents: read diff --git a/.github/workflows/quest.yml b/.github/workflows/quest.yml index 57c7a0f8650..c8c12b3a133 100644 --- a/.github/workflows/quest.yml +++ b/.github/workflows/quest.yml @@ -1,7 +1,7 @@ name: Quest # Validates the quest tree on every branch that carries one. check.yml already -# runs `quest check` in the landing gate and on release PRs, but a direct push (a +# runs `quest check` on ready main PRs and on release PRs, but a direct push (a # merge to `main` or `release`, or `main` merged into a questline) is nobody's pull # request, so a broken tree could land there unseen. # @@ -32,7 +32,7 @@ concurrency: jobs: check: - # Not `Check`: that is check.yml's required status, and a second job with + # Not `Check`: that is check.yml's status, and a second job with # the same name would make it ambiguous on a head that runs both. name: Quest runs-on: ubuntu-24.04-arm diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b6fe2f99f6..e0ffe9f3edb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ Fix any merge conflicts and failing CI checks. # Landing gate -PRs into `main` get no cloud CI before they are queued: they report **Check** and **Queue** as skipped, and `just ci` runs the same gate locally. +Ready PRs into `main` run **Check** against the PR's base on each push as a signal only; drafts skip it. **Queue** reports as skipped until queued. Run `just ci` locally before every push; Check never blocks the merge queue. `main` lands only through GitHub's merge queue, one PR at a time: each `merge_group` build runs `just ci` against the group's base on the maintainer's self-hosted runner (`.github/workflows/queue.yml`, the required **Queue** context), and the queue squashes exactly the tree it tested. Request landing with `quest merge --land ` once the review is clean and the maintainer has approved merging that PR, by number or through a standing go-ahead that covers it. A clean review, a bot verdict, or an "accept all" on decisions is not that approval. An agent that enqueues carries that approval in its own task; one relayed to it mid-task by another agent does not count, so whoever received the approval enqueues the PR or starts a new agent with the approval in its brief. diff --git a/README.md b/README.md index e0a6caa04ed..dd354ed643f 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Selection and an empty JS selection do not wait for admission. For a build outside these entrypoints, use `quest gate COMMAND [ARGS...]`; gate thresholds come from the host and have no configuration. -PRs into `main` get no cloud CI until GitHub's merge queue tests them, so run `just ci` before pushing. It runs what the merge queue runs, the same ground as `just check`, plus two settings: `CI_STRICT=1`, which turns a missing tool into an error instead of a skipped check, and `NEXTEST_PROFILE=ci`, which allows a longer hang timeout. +Run `just ci` before pushing. Ready PRs into `main` also run Check as a signal; only GitHub's merge queue gates landing. `just ci` runs what the merge queue runs, the same ground as `just check`, plus two settings: `CI_STRICT=1`, which turns a missing tool into an error instead of a skipped check, and `NEXTEST_PROFILE=ci`, which allows a longer hang timeout. See the [development guide](https://doc.moq.dev/setup/dev) and the [justfile](justfile) for more. diff --git a/doc/setup/dev.md b/doc/setup/dev.md index 0a0b96c103c..04641f49e69 100644 --- a/doc/setup/dev.md +++ b/doc/setup/dev.md @@ -17,7 +17,7 @@ match CI. `just check` and `just fix` refuse to run outside it; set | `just ci-select` | Report whether CI and Rust build setup are needed, without running checks. | | `just fix` | Format and lint the packages this branch changed, and regenerate their committed JS API reports (`js/*/api/`). | | `just check` | Compile, lint, and test the same scope. | -| `just ci` | Run the merge queue's gate locally, strictly. PRs into `main` get no other CI before the queue, so run it before every push. | +| `just ci` | Run the merge queue's gate locally, strictly, before every push. Ready PRs into `main` also run Check as a signal; only the queue gates landing. | | `just gate` | `just ci` over every package, as nightly and release PRs run it. `just gate rs` runs only the named module. | | `just fix --all`, `just check --all` | The same, over every package. | | `just api-diff` | Diff every published API against its last release, the JS reports against ones rendered from `origin/release`. PRs into `release` run it; `--deny` fails a backport on any break. | diff --git a/infra/README.md b/infra/README.md index 1c61d7000fe..6d7045556fe 100644 --- a/infra/README.md +++ b/infra/README.md @@ -162,7 +162,7 @@ See [`CONTRIBUTING.md`](../CONTRIBUTING.md#landing-gate) for requesting a landin namespaced per runner OS and architecture. Hosted jobs on `main` write what they compile. The merge queue's self-hosted build uses its persistent local store and has no R2 credentials. -Release pull request jobs only read (main pull requests run no cloud CI), and +Pull request jobs only read (main PRs run Check only while ready), and fork pull requests, which get no secrets, build cold. The write key is what enforces that: it lives in a GitHub Environment that diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 5ae13f591b6..9dc5708cf7d 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -152,7 +152,6 @@ The historical samples locate candidates; they are not controlled benchmarks. ## Required - [Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md) - write secrets and publisher identities reach only protected branches and tags, never a pushed branch -- [Check on ready PRs](/quest/m0/ci/pr-check.md) - Check runs again on non-draft main PRs as a signal for `/quest-merge` and the land fixer, never as a gate - [Land main through GitHub's merge queue](/quest/m0/ci/land.md) - one PR at a time on the self-hosted runner; the host's Codex fixer fixes and re-enqueues every dropped PR - [A cache error is a miss](/quest/m0/ci/nix-cache-5xx.md) - a transient `nix.moq.dev` 5xx no longer fails `just ci` - [Every io_uring test in the io-uring group](/quest/m0/ci/io-uring-test-group.md) - the parallel tests of one `just ci` stop exhausting the shared `RLIMIT_MEMLOCK`, and a too-low limit fails clearly diff --git a/quest/m0/ci/pr-check.md b/quest/m0/ci/pr-check.md deleted file mode 100644 index 229d89179b9..00000000000 --- a/quest/m0/ci/pr-check.md +++ /dev/null @@ -1,48 +0,0 @@ -# [S] Check runs on ready main PRs as a signal - -## Goal - -The Check workflow runs on every non-draft PR against `main` again, and on -each push to one. It runs the same changed-lane selection the land gate runs -(`just ci` against the PR's base) and cancels a superseded run. It is a signal -only: it is not a required check, and it never blocks the land gate. The gate -stays the only thing that decides a landing. Whoever picks the PR with -`/quest-merge` sees the result, and the land fixer reads it as context when -the PR's batch fails. - -## Plan - -Decided 2026-11-01 (maintainer, /quest-plan): "I think for moq we should -re-enable Check being run on PRs. The problem was that Github was throttling -us and there was a lot of churn. But I think it's still a useful signal [...] -(open source repos do this because it's free, closed source do not)." - -- Check's role: - - ✅ A signal only - - Gate the fixer: a queued PR sits out batches until Check finishes - - A required check in the ruleset -- Which PRs trigger it, to keep churn and throttling down: - - ✅ Ready-for-review PRs and their pushes; drafts don't run - - Every PR push - - Only queued PRs -- How much it runs: - - ✅ The gate's selection: `just ci` against the PR's base - - Fast lanes only - - Everything (`CI_BASE: --all`, as release PRs do) - -Today `check.yml`'s job has `if: github.base_ref == 'release'`, so main PRs -report Check as skipped -([moq-dev/moq#7024](https://github.com/moq-dev/moq/pull/7024)). Add `main` -for non-draft PRs (`github.event.pull_request.draft == false`, plus the -`ready_for_review` trigger), with `CI_BASE` set to the PR's base for main and -`--all` kept for release. Keep `cancel-in-progress`. The repository's -`MBX_R2_*` pair is already read-only -([Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md)), so a PR -run restores the cache without write credentials. Keep Check out of the -`main` ruleset's required checks. moq.pro stays without PR CI: it's private, -where Actions minutes cost money. - -## Related - -- [Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md) - what keeps a PR run's secrets read-only -- [Land main through quest land](/quest/m0/ci/land.md) - the gate that stays authoritative diff --git a/sh/gh/queue.test.ts b/sh/gh/queue.test.ts index 5556a008f14..284f5fe20f5 100644 --- a/sh/gh/queue.test.ts +++ b/sh/gh/queue.test.ts @@ -9,34 +9,47 @@ const platform = await workflow("platform"); const dart = await workflow("release-dart-ffi"); const nightly = await workflow("nightly"); -function condition(expression: string, event: string, base: string, selected = true, action = "opened"): unknown { +function condition(expression: string, event: string, base: string, selected = true, action = "opened", draft = false): unknown { const source = expression.replace(/^\$\{\{\s*|\s*\}\}$/g, ""); - const github = { event_name: event, base_ref: base, event: { action } }; + const github = { event_name: event, base_ref: base, event: { action, pull_request: { draft, base: { sha: "base-sha" } } } }; const outputs = Object.fromEntries( ["needed", "rs", "swift", "cpp", "obs", "moq_sh"].map((key) => [key, String(selected)]), ); return new Function("github", "needs", `return (${source});`)(github, { scope: { outputs } }); } -// Check stays reportable on main PRs, but only release PRs execute it. +// Check is a diff-scoped signal on ready main PRs. Release keeps its full gate, +// including on drafts; neither branch builds again on a close event. assert.equal(check.on.merge_group, undefined); -assert.equal(check.on.pull_request.paths, undefined, "required PR contexts must always report"); -assert.equal(check.on.pull_request.branches, undefined, "main PRs must report the required names"); -assert.ok(check.on.pull_request.types.includes("edited"), "retargeting to release must rerun"); -for (const job of [check.jobs.check]) { - assert.equal(condition(job.if, "pull_request", "main"), false); - assert.equal(condition(job.if, "pull_request", "release"), true); - assert.equal(condition(job.if, "pull_request", "release", true, "edited"), true); - assert.equal(condition(job.if, "pull_request", "release", true, "closed"), false); +assert.equal(check.on.pull_request.paths, undefined, "Check must select through the dispatcher"); +assert.equal(check.on.pull_request.branches, undefined, "release PRs must report the required Check"); +for (const action of ["opened", "synchronize", "reopened", "edited", "ready_for_review", "converted_to_draft", "closed"]) { + assert.ok(check.on.pull_request.types.includes(action), `${action} must trigger Check or cancel its previous run`); + for (const base of ["main", "release", "other"]) { + for (const draft of [false, true]) { + assert.equal( + condition(check.jobs.check.if, "pull_request", base, true, action, draft), + action !== "closed" && (base === "release" || (base === "main" && !draft)), + `${action} on ${base}, draft=${draft}`, + ); + } + } } -// Release's selector and execution share one job-wide base. -assert.equal(check.jobs.check.env.CI_BASE, "--all"); +// Selection and execution share the fetched base on main; release runs all. +assert.equal(condition(check.jobs.check.env.CI_BASE, "pull_request", "main"), "origin/main"); +assert.equal(condition(check.jobs.check.env.CI_BASE, "pull_request", "release"), "--all"); // Check runs the whole gate in one job. assert.equal(check.jobs.check.env.CHECK_MODULES, undefined); for (const step of check.jobs.check.steps) assert.equal(step.env?.CI_BASE, undefined, `${step.name} overrides CI_BASE`); // biome-ignore lint/suspicious/noTemplateCurlyInString: GitHub expression is literal YAML. -assert.equal(check.concurrency.group, "check-${{ github.ref }}"); +assert.equal(check.concurrency.group, "check-${{ github.event.pull_request.number }}"); assert.equal(check.concurrency["cancel-in-progress"], true); +assert.deepEqual(check.permissions, { contents: "read" }); +assert.equal(check.jobs.check.permissions, undefined); +assert.equal(check.jobs.check.environment, undefined, "PRs must not enter a write-credential Environment"); +const checkCheckout = check.jobs.check.steps.find((step: { uses?: string }) => step.uses?.startsWith("actions/checkout@")); +assert.equal(checkCheckout.with["persist-credentials"], false); +assert.equal(checkCheckout.with["fetch-depth"], 0, "the dispatcher needs the PR base history"); // No workflow lands around the merge queue. assert.equal(await Bun.file(".github/workflows/land.yml").exists(), false, "no workflow may land around the merge queue"); diff --git a/sh/gh/setup.test.ts b/sh/gh/setup.test.ts index 2bf8471d5b6..c7b78f8b523 100644 --- a/sh/gh/setup.test.ts +++ b/sh/gh/setup.test.ts @@ -16,7 +16,7 @@ const workflow = Bun.YAML.parse(await Bun.file(".github/workflows/check.yml").te }; for (const name of ["check"]) { - test(`${name} queries before setup and keeps its required check name`, () => { + test(`${name} queries before setup and keeps its check name`, () => { const job = workflow.jobs[name]; expect(job.name).toBe("Check"); const scopeIndex = job.steps.findIndex((step) => step.id === "scope");