Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quest.yml
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pr> --land <full-head-sha>` 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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion doc/setup/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
2 changes: 1 addition & 1 deletion infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion quest/m0/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 0 additions & 48 deletions quest/m0/ci/pr-check.md

This file was deleted.

41 changes: 27 additions & 14 deletions sh/gh/queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion sh/gh/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down