Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

ci: main runs Linux and one macOS job; Windows and macOS suites run nightly, by hand and in the release lane (#3824)

Milind Soni168ebfe8bd45
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e41b535760..1d21181592 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,24 +9,30 @@ on:
# lands, so a PR that is green alone but red together with what just
# merged is stopped in the queue instead of on main (that shape reddened
# main twice in Sep 2026). Turning the queue on is a branch-ruleset
- # setting; this trigger is what lets CI report on those runs.
+ # setting, which GitHub offers only once an organization owns the
+ # repository (docs/ci.md); this trigger is what lets CI report on those runs.
merge_group:
+ # The full lane every night on main's newest commit: every platform's shards
+ # and smokes, which pushes to main and merge groups leave out (docs/ci.md).
+ schedule:
+ - cron: "17 21 * * *"
# least privilege: CI only reads the checkout, it never writes back
permissions:
contents: read
concurrency:
- # A new PR push supersedes that PR's older checks. Main keeps one run going
- # and one waiting: each merge replaces the waiting run, so a burst of
- # merges costs two full runs, not one per merge (fifteen queued behind each
- # other in October 2026). The running one always finishes. A release runs
- # CI on its own commit in a release-ci/v<version> lane when main's run for
- # it was replaced (scripts/release-ci.mjs). Merge-queue runs stay on their
- # own refs. A PR's group is named by its number, never by github.ref: a
- # merged PR's closed event reports the base branch as github.ref, so a
- # ref-named group let every merge cancel main's run (ci-stop-closed.yml).
- group: ci-${{ github.event_name == 'merge_group' && github.event.merge_group.head_ref || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}
+ # A new PR push supersedes that PR's older checks. Main's pushes keep one run
+ # going and one waiting: each merge replaces the waiting run, so a burst of
+ # merges costs two runs, not one per merge (fifteen queued behind each other
+ # in October 2026). The running one always finishes. Every other run has a
+ # group no push can join: a merge group its own ref, the nightly run and each
+ # manual run (the release branch's, and the release-ci/v<version> lane that
+ # scripts/release-ci.mjs starts) their event and branch. A PR's group is
+ # named by its number, never by github.ref: a merged PR's closed event
+ # reports the base branch as github.ref, so a ref-named group let every merge
+ # cancel main's run (ci-stop-closed.yml).
+ group: ci-${{ github.event_name == 'merge_group' && github.event.merge_group.head_ref || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.event_name == 'push' && github.ref || format('{0}-{1}', github.event_name, github.ref) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
@@ -40,12 +46,14 @@ jobs:
timeout-minutes: 15
permissions:
contents: read
- # ci-scope reads whether the commit before a push got its own green run
+ # ci-scope reads whether the commit before a push got its own green run,
+ # and whether the pushed commit already passed the merge queue
actions: read
outputs:
jobs: ${{ steps.scope.outputs.jobs }}
vitest_os: ${{ steps.scope.outputs.vitest_os }}
vitest_matrix: ${{ steps.scope.outputs.vitest_matrix }}
+ packaged_server_os: ${{ steps.scope.outputs.packaged_server_os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
@@ -85,8 +93,9 @@ jobs:
needs: static
if: contains(needs.static.outputs.jobs, '"vitest"')
# scripts/ci-scope.mjs picks the platforms and their shards: PRs run Linux
- # and Windows (the account runs only five macOS jobs at a time); main
- # pushes, merge groups and manual runs add macOS. A pull request that
+ # and Windows (the account runs only five macOS jobs at a time), main
+ # pushes and merge groups Linux, and the full lane (nightly, manual runs,
+ # the release lane) all three. A pull request that
# cannot affect a platform's results leaves it out, and one that changes
# only translations runs the locale tests alone. Linux runs every file;
# Windows and macOS run every file but the e2e files that test only OMB's
@@ -195,12 +204,12 @@ jobs:
# `pnpm build:server`, then the bundle is copied out of the repo and run
# with no node_modules in reach: every bare import must be inlined. The
# macOS copy runs inside the macOS smokes job, so it takes no extra
- # macOS runner.
+ # macOS runner. The Windows copy runs where the Windows shards do.
name: packaged server smoke (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, windows-latest]
+ os: ${{ fromJSON(needs.static.outputs.packaged_server_os) }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
@@ -236,8 +245,9 @@ jobs:
if: contains(needs.static.outputs.jobs, '"electron-smokes"')
# Real Electron utility processes against disposable homes and fake CLIs.
# Never the live app. Each script prints its own evidence lines. Every
- # PR's macOS checks live in this one job: macOS runners are the scarce
- # ones, and each extra job pays its own queue wait and install.
+ # PR's, push's and merge group's macOS checks live in this one job: macOS
+ # runners are the scarce ones, and each extra job pays its own queue wait
+ # and install.
name: macOS smokes (packaged server + Electron)
runs-on: macos-latest
timeout-minutes: 25
@@ -579,9 +589,9 @@ jobs:
if: contains(needs.static.outputs.jobs, '"browser-driver"')
# Advisory, outside the CI gate until it has run green for a while: the
# omb-cdp S4 conformance suites and the new browser's checklist and viewer
- # suites on the runner's own Google Chrome (PRs run Linux and Windows;
- # main pushes, merge groups and manual runs add macOS, as for the vitest
- # shards), then on Linux inside the server image's runtime as a non-root
+ # suites on the runner's own Google Chrome (PRs run Linux and Windows, the
+ # full lane all three; pushes to main and merge groups leave it out), then
+ # on Linux inside the server image's runtime as a non-root
# user. Every S4 suite also fails when its trace holds Runtime.enable or
# another forbidden CDP method (docs/ci.md).
name: browser driver S4 (${{ matrix.os }})
diff --git a/docs/ci.md b/docs/ci.md
index ff8caa9c0b..30eb634913 100644
--- a/docs/ci.md
+++ b/docs/ci.md
@@ -29,7 +29,8 @@ areas run the union of their jobs. Why the mapping is what it is:
- The macOS smokes run the packaged server inside Electron (approval modes,
app frames, phone relay, login handoff), so a server change runs them.
- A renderer change runs no Windows or macOS shard: the renderer's tests read
- the platform from the desktop bridge, never the host. Main still runs both.
+ the platform from the desktop bridge, never the host. The full lane still
+ runs both.
- English (`en.json`) is the text every test reads, so it is web. Other
catalogs are read only by `src/` tests, the locale generator's test and an
Electron node test; `scripts/ci-scope.test.ts` fails if another test starts
@@ -38,8 +39,23 @@ areas run the union of their jobs. Why the mapping is what it is:
scripts and pinned downloads, so only `scripts/` and dependency changes run
them.
-Pushes to main, merge groups, manual runs (the release branch's CI, which
-`prepare-release.yml` starts, and the release lane) never use the areas:
+## Lanes: pull requests, main and the full lane
+
+Only pull requests use the areas. Every other event runs one of two fixed
+sets (`laneOf` in `scripts/ci-scope.mjs`):
+
+| Event | Lane | What runs |
+| --- | --- | --- |
+| `pull_request` | its areas | the table above, with Linux and Windows shards |
+| `push` to main, `merge_group` | main | static (typecheck, lint, the build), the eight Linux shards with the Electron node tests, the macOS smokes job, behavior evals, the Linux packaged server smoke, the open-source edition, the control plane, the renderer smoke and Linux browser identity |
+| `schedule` (nightly, 21:17 UTC), `workflow_dispatch` (manual runs, the release branch's CI that `prepare-release.yml` starts, and the release lane) | full | every job on every platform: also the Windows and macOS shards, the Windows packaged server and Windows CUA smokes, Windows and macOS browser identity, the browser driver on all three, the Linux package and the Linux ARM64 installer |
+
+The main lane keeps to runners that do not hold main up: Linux, and one macOS
+job. The Windows and macOS shards, and every smoke that needs a Windows or a
+second macOS runner, wait for the night or a release. A change that breaks
+only Windows or macOS shows up in its own PR (PRs still run the Windows shards
+wherever a change can affect them), in the nightly run, or in the release
+lane, which only an emergency `ship_without_ci` release skips.
- A push to main is scoped by its own commits (`before..after`): docs only
(root Markdown, Markdown under `docs/`, `.github/FUNDING.yml`), or a
@@ -47,16 +63,23 @@ Pushes to main, merge groups, manual runs (the release branch's CI, which
the runtime jobs. It does so only when the commit before the push has a green
CI run of its own. Main's waiting run is replaced by each push, so without
that check a replaced run's code would never be tested. Every other push runs
- everything.
-- Merge groups and manual runs always run all jobs. Empty or unreadable diffs,
- and a previous commit whose CI cannot be read, also fall back to all jobs.
+ the main lane.
+- A push whose commit already passed the `CI` gate in a merge group runs only
+ the control-plane job (the broker deploy needs it). The merge queue lands
+ its group's own commit, so the merge group's run tested exactly what the push
+ brings; `ci-scope.mjs` reads that run's gate job, which can pass before the
+ run's last job has finished.
+- Merge groups always run the main lane, whatever they change. Empty or
+ unreadable push diffs, and a commit whose CI cannot be read, fall back to the
+ main lane; a pull request whose diff cannot be read falls back to every job
+ on every platform.
The single `CI` gate keeps the existing required dependencies. `static`
outputs the selected job ids; the gate wants each required job to have passed
when it was selected and to have been skipped when it was not. Failures,
cancellations, a missing or malformed selection and unexpected runs or skips
fail the gate. Advisory jobs remain advisory. A new push to a PR cancels that
-PR's older run; main's concurrency is unchanged (see Main and releases).
+PR's older run (see Main and releases for every other group).
The separate shared-terminal smoke workflow is manual-only: its tests already
run in the Windows Vitest/Electron jobs.
@@ -65,8 +88,8 @@ run in the Windows Vitest/Electron jobs.
The suite runs one file at a time, so a shard takes as long as its files added
up, and the slowest shard sets how long a PR and a release wait. Linux and
-Windows run eight shards each, macOS four (main, merge groups and manual runs
-only); `scripts/ci-scope.mjs` builds the matrix.
+Windows run eight shards each, macOS four (the full lane only);
+`scripts/ci-scope.mjs` builds the matrix.
**Which files run where.** Linux runs every file. Most e2e files drive
OMB's own logic through a real server and fake engines, which is the same on
@@ -93,8 +116,8 @@ counts one second, or the median e2e time if it is an e2e file. Every file
still runs exactly once, and each shard job logs a `duration-sequencer:` line
with its share.
-Refresh the times from a few recent main runs (they have all three platforms)
-when shards drift apart:
+Refresh the times from a few recent nightly or manual runs (they have all
+three platforms) when shards drift apart:
```sh
node scripts/testing/update-shard-weights.mjs --run <run id> --run <run id> --run <run id>
@@ -120,11 +143,11 @@ seven (four Vitest shards, two smokes, the iOS job with its hour-long
simulator suite). With 25 open PRs the macOS jobs waited a median of six and a
half hours. Now:
-- A PR runs the Vitest shards on Ubuntu and Windows; main pushes, merge groups
- and manual runs add four macOS shards, which run the host e2e files only.
- Only a couple of test blocks are macOS-only.
-- Every PR's macOS checks are one job: the packaged-server smoke and the
- Electron smokes.
+- A PR runs the Vitest shards on Ubuntu and Windows, a push to main or a merge
+ group on Ubuntu; the full lane adds four macOS shards, which run the host e2e
+ files only. Only a couple of test blocks are macOS-only.
+- Every PR's, push's and merge group's macOS checks are one job: the
+ packaged-server smoke and the Electron smokes.
- `ci-stop-closed.yml` cancels a PR's CI run when the PR is merged or closed. PR runs share a group named by the PR number (`ci-pr-<n>`), never by `github.ref`: a merged PR's closed event reports the base branch as `github.ref`, which made every merge cancel main's CI (fixed Oct 3 2026).
## Browser driver (S4)
@@ -161,9 +184,9 @@ answered by an upload, a dropdown list drawn by the viewer, a download served
to it, the page's cursor and copied text).
- The job uses the runner's installed Google Chrome (`OMB_CDP_E2E=1`) on the
- same platforms as the vitest shards: Linux and Windows on PRs, plus macOS
- on main, merge groups and manual runs. Linux runs under Xvfb so the
- headed-identity case has a display.
+ same platforms as the vitest shards: Linux and Windows on PRs, all three in
+ the full lane. Pushes to main and merge groups leave it out. Linux runs
+ under Xvfb so the headed-identity case has a display.
- On Linux it then builds the server image's `runtime` stage and runs the
suites inside it as a non-root user against the image's Chrome for
Testing, with `OMB_BROWSER_SANDBOX=0` because the image has no setuid
@@ -191,32 +214,37 @@ to it, the page's cursor and copied text).
## Main and releases
-Main keeps one CI run going and one waiting. Each merge replaces the waiting
-run, and the running one always finishes, so a burst of merges costs two full
-runs instead of one per merge (fifteen queued behind each other in October
-2026, with the release waiting behind them).
+Main's pushes keep one CI run going and one waiting. Each merge replaces the
+waiting run, and the running one always finishes, so a burst of merges costs
+two runs instead of one per merge (fifteen queued behind each other in October
+2026, with the release waiting behind them). Every other run has a group no
+push can join, so nothing a merge does cancels it: a merge group is named by
+its own ref, and the nightly run and each manual run (the release branch's CI
+and the release lane among them) by their event and branch.
`release.yml` ships only a commit whose code passed CI
(`scripts/release-ci.mjs`, overlapping the platform builds). A run counts only
-when its `CI` gate passed and every vitest job actually ran and passed, so a
-scoped run (docs- or version-only, vitest skipped) is never proof. The script
-accepts, in order:
-
-1. a finished run on the release commit itself;
-2. a finished push, merge-queue or manual run on any commit with the same git
- tree. This is the all-OS manual run `prepare-release.yml` starts on the
- `release/v<version>` branch, whenever main did not move before the merge;
+when its `CI` gate passed and every platform's every vitest shard ran and
+passed. A scoped run (docs- or version-only, vitest skipped) is never proof,
+and neither is a partial one: a push to main or a merge group runs Linux's
+shards only. The script accepts, in order:
+
+1. a finished full run on the release commit itself;
+2. a finished full run on any commit with the same git tree: the all-OS manual
+ run `prepare-release.yml` starts on the `release/v<version>` branch,
+ whenever main did not move before the merge, or a nightly run;
3. when the release commit's only change from its parent is `package.json`'s
- `"version"` (all the bump touches), the parent's proof by 1 or 2. A parent
- run still going is waited for; a red parent, or one that skipped its
- tests, never counts.
-
-If none of these exists and main's run for the commit was replaced, never ran
-or skipped the tests, the script starts CI on the commit in its own lane: a
-`release-ci/v<version>` branch that no merge can touch, deleted afterwards. A
-red verdict stops the release; re-run the failed CI jobs
-(`gh run rerun <id> --failed`), and the waiting release picks up the new
-attempt. A red where every failed job never started a step (a macOS runner
+ `"version"` (all the bump touches), the parent's proof by 1 or 2. A parent's
+ nightly or manual run still going is waited for; a red parent, or one that
+ skipped its tests or ran only some platforms, never counts.
+
+Otherwise the script starts CI on the commit in its own lane: a
+`release-ci/v<version>` branch that no merge can touch, run as a manual run of
+every job on every platform, and deleted afterwards. It does not wait for the
+commit's push or merge-group run first, which could only come back partial,
+but a red one that has finished stops the release. A red verdict stops the
+release; re-run the failed CI jobs (`gh run rerun <id> --failed`), and the
+waiting release picks up the new attempt. A red where every failed job never started a step (a macOS runner
"failed to be acquired") is not a verdict. On the release lane's own run the
script re-runs the failed jobs once itself
(`POST /actions/runs/<id>/rerun-failed-jobs`, which the job's
@@ -261,3 +289,70 @@ reserves failed with `listen EACCES 127.0.0.1:497xx`.
The `main-ci-gate` ruleset requires the single `CI` check (it replaced the
three legacy `typecheck + test (<os>)` names in September 2026). Renaming the
`gate` job needs the ruleset updated first, or every PR waits forever.
+
+## Merge queue
+
+Two PRs that were each green have broken main together. A merge queue tests
+each PR on top of what lands before it: GitHub builds a merge group (the PR
+squashed onto main and the groups ahead of it), CI runs the main lane on it as
+a `merge_group` event, and the group's commit lands only when its `CI` check
+passes. The workflow is ready: the `merge_group` trigger, a concurrency group
+per merge group, the main lane, and the same `CI` check name.
+
+GitHub offers the queue only to repositories an organization owns ("Pull
+request merge queues are available in any public repository owned by an
+organization", GitHub's docs, October 2026). `milind-soni/OpenMausBot` is
+owned by a user account, so the rule below appears only after the repository
+moves to an organization (such as `SupaMaus`). The move changes the URL the
+desktop updater reads (see Updater migration invariant in `releasing.md`), so
+it is the owner's decision. Then:
+
+**Settings → Rules → Rulesets → `main-ci-gate` → Edit** (it targets the
+default branch):
+
+1. Keep **Require status checks to pass** with the one check `CI` (source:
+ GitHub Actions). The same rule applies to the PR before it can join the
+ queue and to the merge group in it. **Require branches to be up to date
+ before merging** stays off: the queue brings each PR up to date itself.
+2. Add **Require merge queue** with:
+ - **Merge method:** Squash.
+ - **Build concurrency:** 3. Each group's run is 17 jobs, one of them on
+ macOS; an organization on the Team plan runs 60 jobs and 5 macOS jobs at
+ once, shared with every PR's run.
+ - **Minimum group size:** 1, **maximum group size:** 5, **wait time to meet
+ the minimum group size:** 0 minutes, so a PR alone starts at once.
+ - **Require all queue entries to pass required checks** (Only merge
+ non-failing pull requests): on. Every PR's own group must pass, not only
+ the last of the PRs merged together, so every commit the queue lands on
+ main was tested.
+ - **Status check timeout:** 60 minutes (a main-lane run takes about 25).
+3. Save. PRs then show **Merge when ready** instead of the merge button;
+ `gh pr merge --squash` adds a PR to the queue, or turns on auto-merge when
+ its checks have not passed yet.
+
+The same rule through the API, keeping the ruleset's existing check:
+
+```sh
+gh api -X PUT repos/<org>/OpenMausBot/rulesets/<main-ci-gate id> --input - <<'JSON'
+{"rules": [
+ {"type": "required_status_checks", "parameters": {"required_status_checks": [{"context": "CI", "integration_id": 15368}],
+ "strict_required_status_checks_policy": false, "do_not_enforce_on_create": false}},
+ {"type": "merge_queue", "parameters": {"merge_method": "SQUASH", "max_entries_to_build": 3, "min_entries_to_merge": 1,
+ "max_entries_to_merge": 5, "min_entries_to_merge_wait_minutes": 0, "grouping_strategy": "ALLGREEN",
+ "check_response_timeout_minutes": 60}}
+]}
+JSON
+```
+
+`ci-stop-closed.yml` only cancels a closed PR's own group (`ci-pr-<n>`), so it
+never touches a merge group's run. The push that lands a group's commit runs
+only the control-plane job and the broker deploy, because the merge group
+already tested that exact commit. To turn the queue off, remove the **Require
+merge queue** rule; nothing in the workflow needs to change.
+
+While the repository stays user-owned, the one setting that stops two green PRs
+from landing red together is **Require branches to be up to date before
+merging** on the same ruleset: a PR merges only after CI passed on it with
+main's newest commit in it. Every merge then makes the other open PRs update
+their branch and run CI again before they can merge, so it trades merge
+throughput for that guarantee.
diff --git a/docs/releasing.md b/docs/releasing.md
index 628cbf55b3..70485641d9 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -22,14 +22,18 @@ published release** workflow
verifies and publishes its legacy mirror automatically. Never publish only the
legacy draft.
-The release commit must have passed CI: the **CI passed on the release commit**
-job waits (while the platforms build) for ci.yml's `CI` check on the pinned
-commit and stops the release before any draft if it failed. If that commit
-has no CI run, or a newer merge replaced it, the job runs CI on the commit
-itself on a temporary `release-ci/v<version>` branch. After a flaky failure,
-re-run the failed CI jobs; a release still waiting picks up the new attempt,
-and a release that already stopped needs only `gh run rerun <id> --failed`.
-`ship_without_ci` skips the wait, for emergencies only.
+The release commit must have passed CI on every platform: the **CI passed on
+the release commit** job waits (while the platforms build) for a ci.yml run
+whose `CI` check passed with every Linux, Windows and macOS shard, on the
+pinned commit or a commit with the same tree, and stops the release before any
+draft if the commit's CI failed. A push to main runs the Linux shards only, so
+unless the release branch's own CI (started by **Prepare next release**) or a
+nightly run covered the same tree, the job runs the full CI on the commit
+itself on a temporary `release-ci/v<version>` branch, which takes about as
+long as the platform builds. After a flaky failure, re-run the failed CI jobs;
+a release still waiting picks up the new attempt, and a release that already
+stopped needs only `gh run rerun <id> --failed`. `ship_without_ci` skips the
+wait, for emergencies only. See [CI job selection](ci.md#main-and-releases).
The workflow refuses to overwrite an already-published version. Manual Release
runs still require `package.json`'s version to be bumped on the selected ref.
diff --git a/scripts/ci-scope.mjs b/scripts/ci-scope.mjs
index cdd9bd72ec..245dad7f26 100644
--- a/scripts/ci-scope.mjs
+++ b/scripts/ci-scope.mjs
@@ -83,6 +83,17 @@ export function areaOf(file) {
export const FULL_SCOPE = { areas: ["everything"], checks: [...EVERY_CHECK].sort() };
+/** A push to main and a merge group: the build, every test file on Linux, the macOS smokes and the Linux checks no
+ * longer than a shard. The Windows and macOS shards and smokes, the Linux package, the browser driver and the ARM
+ * installer run in the full lane only: nightly, manual runs and the release lane. */
+export const MAIN_SCOPE = {
+ areas: ["main"],
+ checks: ["behavior-evals", "browser-identity", "build", "control-plane", "electron-smokes", "foss", "linux-tests", "packaged-server", "ui-smoke"],
+};
+
+/** A push whose commit already passed the CI gate in the merge queue: only the control-plane checks the broker deploy needs. */
+export const QUEUED_SCOPE = { areas: ["tested in the merge queue"], checks: ["control-plane"] };
+
/** A pull request's areas and the checks they select, from its changed files. */
export function selectCiScope(files) {
const areas = Array.isArray(files) && files.length > 0 ? [...new Set(files.map(areaOf))].sort() : ["everything"];
@@ -124,10 +135,21 @@ export function selectPushScope(files, show) {
// macOS runners are the scarce ones (five at a time for the whole account),
// and only a couple of test blocks are macOS-only, so a PR runs the suite on
-// Linux and Windows. Main pushes, merge groups and manual runs add macOS; a PR
-// that can affect the macOS smokes still runs them.
-const ALL_OS = ["macos-latest", "ubuntu-latest", "windows-latest"];
+// Linux and Windows, and a push to main or a merge group on Linux. The full lane
+// adds macOS. A PR that can affect the macOS smokes still runs them.
+export const ALL_OS = ["macos-latest", "ubuntu-latest", "windows-latest"];
const PR_OS = ["ubuntu-latest", "windows-latest"];
+const MAIN_OS = ["ubuntu-latest"];
+
+/** Events whose runs test every platform: the nightly run, manual runs and the release lane (a manual run). */
+export const FULL_LANE_EVENTS = ["schedule", "workflow_dispatch"];
+
+/** Which lane an event's run is: a pull request's own areas, main's, or every check on every platform. */
+export function laneOf(event) {
+ if (event === "pull_request") return "pr";
+ if (event === "push" || event === "merge_group") return "main";
+ return "full";
+}
// A shard runs its files one at a time, so the slowest shard sets the run's length. Windows and macOS run only the e2e
// files that depend on their OS, so their shards stay as short as Linux's, and macOS keeps four: the account runs five
@@ -163,6 +185,8 @@ export function ciOutputs({ checks }, oses) {
build: checks.includes("build"),
jobs,
vitest_os: oses,
+ // macOS's packaged server smoke runs in the macOS smokes job.
+ packaged_server_os: oses.filter((os) => os !== "macos-latest"),
// GitHub refuses an empty matrix, so a vitest job its `if` skips keeps the full one.
vitest_matrix: include.length > 0 ? { include } : vitestMatrix(oses),
};
@@ -179,27 +203,43 @@ function changedFiles(range) {
return diff.slice(0, -1).split("\0");
}
-/** Did the commit before this push get a green CI run of its own? Main keeps
- * one run going and one waiting, and a push replaces the waiting run: if the
- * previous commit's run was replaced, its changes were never tested, so this
- * push must run everything even when its own diff is docs or a version. */
-async function previousCommitGreen(sha) {
+async function github(path) {
const { GH_TOKEN, GITHUB_REPOSITORY, GITHUB_API_URL = "https://api.github.com" } = process.env;
- if (!GH_TOKEN || !GITHUB_REPOSITORY) throw new Error("GH_TOKEN and GITHUB_REPOSITORY are needed to read the previous commit's CI");
- const response = await fetch(`${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/runs?head_sha=${sha}&per_page=100`, {
+ if (!GH_TOKEN || !GITHUB_REPOSITORY) throw new Error("GH_TOKEN and GITHUB_REPOSITORY are needed to read CI runs");
+ const response = await fetch(`${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}${path}`, {
headers: { authorization: `Bearer ${GH_TOKEN}`, accept: "application/vnd.github+json", "x-github-api-version": "2022-11-28" },
signal: AbortSignal.timeout(30_000),
});
- if (!response.ok) throw new Error(`HTTP ${response.status} reading CI runs`);
- const { workflow_runs: runs } = await response.json();
- return runs.some((run) => ["push", "merge_group", "workflow_dispatch"].includes(run.event)
+ if (!response.ok) throw new Error(`HTTP ${response.status} reading ${path.split("?")[0]}`);
+ return response.json();
+}
+
+const ciRuns = async (sha) => (await github(`/actions/workflows/ci.yml/runs?head_sha=${sha}&per_page=100`)).workflow_runs;
+
+/** Did the commit before this push get a green CI run of its own? Main keeps
+ * one run going and one waiting, and a push replaces the waiting run: if the
+ * previous commit's run was replaced, its changes were never tested, so this
+ * push must run main's checks even when its own diff is docs or a version. */
+async function previousCommitGreen(sha) {
+ return (await ciRuns(sha)).some((run) => ["push", "merge_group", ...FULL_LANE_EVENTS].includes(run.event)
&& run.status === "completed" && run.conclusion === "success");
}
+/** Did this exact commit pass the CI gate in the merge queue? The queue lands a merge group's own commit, so its run
+ * already tested what this push brings; the gate job is read because the push can come before the run has finished. */
+async function passedMergeQueue(sha) {
+ for (const run of (await ciRuns(sha)).filter((candidate) => candidate.event === "merge_group")) {
+ const { jobs } = await github(`/actions/runs/${run.id}/jobs?per_page=100`);
+ if (jobs.some((job) => job.name === "CI" && job.conclusion === "success")) return true;
+ }
+ return false;
+}
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
- let scope = FULL_SCOPE;
- let vitestOs = ALL_OS;
- if (process.env.GITHUB_EVENT_NAME === "pull_request") {
+ const lane = laneOf(process.env.GITHUB_EVENT_NAME);
+ let scope = lane === "main" ? MAIN_SCOPE : FULL_SCOPE;
+ let vitestOs = lane === "main" ? MAIN_OS : ALL_OS;
+ if (lane === "pr") {
try {
const { pull_request: pr } = JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
const base = pr?.base?.sha;
@@ -213,8 +253,8 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
console.warn(`CI scope: using all checks because the pull request diff is unavailable: ${error.message}`);
}
} else if (process.env.GITHUB_EVENT_NAME === "push") {
- // A push to main is scoped by its own commits; the release gate never
- // counts a run that skipped the runtime jobs as tested.
+ // A push to main is scoped by its own commits; the release gate counts only
+ // a run of every platform's shards as tested.
try {
const { before, after } = JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
if (![before, after].every((sha) => typeof sha === "string" && SHA.test(sha)) || /^0+$/.test(before)) {
@@ -222,13 +262,15 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
}
const revs = { before, after };
const selected = selectPushScope(changedFiles(`${before}..${after}`), (rev, path) => git(["show", `${revs[rev]}:${path}`]));
- if (!selected.runtime && !(await previousCommitGreen(before))) {
- console.warn(`CI scope: using all checks because ${before} has no green CI run of its own`);
+ if (await passedMergeQueue(after)) {
+ scope = QUEUED_SCOPE;
+ } else if (!selected.runtime && !(await previousCommitGreen(before))) {
+ console.warn(`CI scope: using main's checks because ${before} has no green CI run of its own`);
} else if (!selected.runtime) {
scope = { areas: ["docs or version only"], checks: ["build"] };
}
} catch (error) {
- console.warn(`CI scope: using all checks because the push diff is unavailable: ${error.message}`);
+ console.warn(`CI scope: using main's checks because the push diff or its CI is unavailable: ${error.message}`);
}
}
const outputs = ciOutputs(scope, vitestOs);
diff --git a/scripts/ci-scope.test.ts b/scripts/ci-scope.test.ts
index a4e448bfad..0f7a7750d0 100644
--- a/scripts/ci-scope.test.ts
+++ b/scripts/ci-scope.test.ts
@@ -8,14 +8,15 @@ import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import { parse } from "yaml";
import {
- AREA_CHECKS, ciOutputs, FULL_SCOPE, SELECTABLE_JOBS, selectCiScope, selectPushScope, SRC_OUTSIDE_RENDERER,
- versionOnlyPackageJson, VITEST_SUBSETS, vitestMatrix,
+ ALL_OS, AREA_CHECKS, ciOutputs, FULL_LANE_EVENTS, FULL_SCOPE, laneOf, MAIN_SCOPE, QUEUED_SCOPE, SELECTABLE_JOBS, selectCiScope,
+ selectPushScope, SRC_OUTSIDE_RENDERER, versionOnlyPackageJson, VITEST_SUBSETS, vitestMatrix,
} from "./ci-scope.mjs";
const ROOT = fileURLToPath(new URL("..", import.meta.url));
const script = fileURLToPath(new URL("./ci-scope.mjs", import.meta.url));
const ALL = ["macos-latest", "ubuntu-latest", "windows-latest"];
const PR = ["ubuntu-latest", "windows-latest"];
+const MAIN = ["ubuntu-latest"];
const SERVER_JOBS = ["vitest", "behavior-evals", "packaged-server", "electron-smokes", "foss", "ui-smoke", "browser-identity", "package-linux", "browser-driver"];
const temporaryDirectories: string[] = [];
afterEach(() => {
@@ -61,8 +62,12 @@ function outputs(text: string) {
}));
}
-const everything = (oses: string[]) => ({ build: true, jobs: SELECTABLE_JOBS, vitest_os: oses, vitest_matrix: vitestMatrix(oses) });
-const staticOnly = (oses: string[], build: boolean) => ({ build, jobs: [], vitest_os: oses, vitest_matrix: vitestMatrix(oses) });
+const packaged = (oses: string[]) => oses.filter((os) => os !== "macos-latest");
+const everything = (oses: string[]) => ({ build: true, jobs: SELECTABLE_JOBS, vitest_os: oses, packaged_server_os: packaged(oses), vitest_matrix: vitestMatrix(oses) });
+const staticOnly = (oses: string[], build: boolean) => ({ build, jobs: [], vitest_os: oses, packaged_server_os: packaged(oses), vitest_matrix: vitestMatrix(oses) });
+/** What a push to main and a merge group run: Linux's shards, the macOS smokes and the short Linux checks. */
+const MAIN_JOBS = ["vitest", "behavior-evals", "packaged-server", "electron-smokes", "foss", "control-plane", "ui-smoke", "browser-identity"];
+const mainLane = () => ({ build: true, jobs: MAIN_JOBS, vitest_os: MAIN, packaged_server_os: MAIN, vitest_matrix: vitestMatrix(MAIN) });
describe("vitest matrix", () => {
it("gives Linux and Windows eight shards each and macOS four, and only Linux every e2e file", () => {
@@ -152,11 +157,11 @@ describe("CI path scope", () => {
describe("CI outputs", () => {
it("runs a renderer change's tests on Linux only", () => {
const out = ciOutputs(selectCiScope(["src/App.tsx"]), PR);
- expect(out).toEqual({ build: true, jobs: ["vitest", "ui-smoke"], vitest_os: PR, vitest_matrix: vitestMatrix(["ubuntu-latest"]) });
+ expect(out).toEqual({ build: true, jobs: ["vitest", "ui-smoke"], vitest_os: PR, packaged_server_os: PR, vitest_matrix: vitestMatrix(["ubuntu-latest"]) });
});
it("runs a server change's tests on Linux and Windows, and its other checks", () => {
- expect(ciOutputs(selectCiScope(["server/index.ts"]), PR)).toEqual({ build: true, jobs: SERVER_JOBS, vitest_os: PR, vitest_matrix: vitestMatrix(PR) });
+ expect(ciOutputs(selectCiScope(["server/index.ts"]), PR)).toEqual({ build: true, jobs: SERVER_JOBS, vitest_os: PR, packaged_server_os: PR, vitest_matrix: vitestMatrix(PR) });
});
it("runs the locale tests in their own shards, with the Electron node tests, when no full Linux run covers them", () => {
@@ -192,6 +197,28 @@ describe("CI outputs", () => {
const windows = ciOutputs({ checks: ["host-tests"] }, ALL).vitest_matrix.include;
expect(new Set(windows.map((entry: { os: string }) => entry.os))).toEqual(new Set(["macos-latest", "windows-latest"]));
});
+
+ it("runs Linux's every shard, the macOS smokes and the short Linux checks for main, and nothing on Windows", () => {
+ const out = ciOutputs(MAIN_SCOPE, MAIN);
+ expect(out).toEqual(mainLane());
+ expect(out.vitest_matrix.include).toHaveLength(8);
+ expect(out.jobs).not.toEqual(expect.arrayContaining(["windows-cua"]));
+ for (const job of ["windows-cua", "package-linux", "browser-driver", "cloudflared-linux-arm64"]) expect(out.jobs, job).not.toContain(job);
+ expect(MAIN_SCOPE.checks.every((check) => FULL_SCOPE.checks.includes(check))).toBe(true);
+ });
+
+ it("runs only the broker's control-plane checks for a commit the merge queue already tested", () => {
+ expect(ciOutputs(QUEUED_SCOPE, MAIN)).toEqual({ ...staticOnly(MAIN, false), jobs: ["control-plane"] });
+ });
+
+ it("names each event's lane: a pull request its areas, main and the merge queue Linux, the rest every platform", () => {
+ expect(laneOf("pull_request")).toBe("pr");
+ expect(laneOf("push")).toBe("main");
+ expect(laneOf("merge_group")).toBe("main");
+ for (const event of FULL_LANE_EVENTS) expect(laneOf(event), event).toBe("full");
+ expect(FULL_LANE_EVENTS).toEqual(["schedule", "workflow_dispatch"]);
+ expect(ALL_OS).toEqual(ALL);
+ });
});
/** Relative imports, `@/` included, that load code when run; `import type` loads nothing. */
@@ -335,7 +362,7 @@ describe("CI scope CLI", () => {
const { output, stderr } = run(directory, "pull_request", {
pull_request: { base: { sha: base }, head: { sha: git("rev-parse", "HEAD") } },
});
- expect(output).toEqual({ build: true, jobs: SERVER_JOBS, vitest_os: PR, vitest_matrix: vitestMatrix(PR) });
+ expect(output).toEqual({ build: true, jobs: SERVER_JOBS, vitest_os: PR, packaged_server_os: PR, vitest_matrix: vitestMatrix(PR) });
expect(stderr).toBe("");
});
@@ -376,10 +403,15 @@ describe("CI scope CLI", () => {
expect(stderr).toContain("using all checks");
});
- it.each(["merge_group", "workflow_dispatch"])("runs everything for %s", (event) => {
+ it.each(["schedule", "workflow_dispatch"])("runs everything on every platform for %s", (event) => {
const { directory } = fixture("docs/guide.md");
expect(run(directory, event, {}).output).toEqual(everything(ALL));
});
+
+ it("runs main's checks for a merge group, whatever it changes", () => {
+ const { directory } = fixture("docs/guide.md");
+ expect(run(directory, "merge_group", { merge_group: { head_sha: "f".repeat(40) } }).output).toEqual(mainLane());
+ });
});
const pkg = (version: string, extra: Record<string, unknown> = {}) =>
@@ -425,15 +457,19 @@ describe("version-only package.json", () => {
});
});
-/** A GitHub that answers the CI runs of one commit; the script under test
- * runs asynchronously so this server can answer it. */
-async function fakeRunsApi(runs: Record<string, Array<{ event: string; status: string; conclusion: string | null }>>) {
+type FakeRun = { id?: number; event: string; status: string; conclusion: string | null };
+
+/** A GitHub that answers the CI runs of one commit and the jobs of one run; the
+ * script under test runs asynchronously so this server can answer it. */
+async function fakeRunsApi(runs: Record<string, FakeRun[]>, jobs: Record<number, Array<{ name: string; conclusion: string | null }>> = {}) {
const requests: string[] = [];
const server = createServer((request, response) => {
requests.push(`${request.method} ${request.url} ${request.headers.authorization}`);
- const sha = new URL(request.url!, "http://x").searchParams.get("head_sha") ?? "";
+ const url = new URL(request.url!, "http://x");
+ const sha = url.searchParams.get("head_sha") ?? "";
+ const runId = /^\/repos\/o\/r\/actions\/runs\/(\d+)\/jobs$/.exec(url.pathname)?.[1];
response.setHeader("content-type", "application/json");
- response.end(JSON.stringify({ workflow_runs: runs[sha] ?? [] }));
+ response.end(JSON.stringify(runId ? { jobs: jobs[Number(runId)] ?? [] } : { workflow_runs: runs[sha] ?? [] }));
});
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
@@ -467,16 +503,50 @@ describe("CI scope CLI on a push to main", () => {
}
const bump = (directory: string) => writeFileSync(join(directory, "package.json"), pkg("0.1.101"));
const docs = (directory: string) => writeFileSync(join(directory, "docs/guide.md"), "guide\n");
+ const code = (directory: string) => writeFileSync(join(directory, "server/index.ts"), "changed\n");
const green = [{ event: "push", status: "completed", conclusion: "success" }];
+ const runsOf = (sha: string) => `GET /repos/o/r/actions/workflows/ci.yml/runs?head_sha=${sha}&per_page=100 Bearer t`;
+ const github = (api: { url: string }) => ({ GITHUB_API_URL: api.url, GH_TOKEN: "t", GITHUB_REPOSITORY: "o/r" });
it.each([["the version bump", bump], ["a docs-only merge", docs]])("skips the runtime jobs for %s after a green commit", async (_, change) => {
const { directory, before, after } = pushFixture(change);
const api = await fakeRunsApi({ [before]: [{ event: "pull_request", status: "completed", conclusion: "failure" }, ...green] });
try {
- const { output, stderr } = await runPush(directory, { before, after }, { GITHUB_API_URL: api.url, GH_TOKEN: "t", GITHUB_REPOSITORY: "o/r" });
- expect(output).toEqual(staticOnly(ALL, true));
+ const { output, stderr } = await runPush(directory, { before, after }, github(api));
+ expect(output).toEqual(staticOnly(MAIN, true));
+ expect(stderr).toBe("");
+ expect(api.requests).toEqual([runsOf(after), runsOf(before)]);
+ } finally {
+ await api.close();
+ }
+ });
+
+ it.each([["a code change", code], ["the version bump", bump]])("runs only the control-plane checks for %s the merge queue already passed", async (_, change) => {
+ const { directory, before, after } = pushFixture(change);
+ // The queue lands its group's commit once the gate passes, before the run's last job has finished.
+ const api = await fakeRunsApi({ [after]: [{ id: 77, event: "merge_group", status: "in_progress", conclusion: null }] }, {
+ 77: [{ name: "vitest (ubuntu-latest, shard 1/8)", conclusion: "success" }, { name: "CI", conclusion: "success" }],
+ });
+ try {
+ const { output, stderr } = await runPush(directory, { before, after }, github(api));
+ expect(output).toEqual(ciOutputs(QUEUED_SCOPE, MAIN));
expect(stderr).toBe("");
- expect(api.requests).toEqual([`GET /repos/o/r/actions/workflows/ci.yml/runs?head_sha=${before}&per_page=100 Bearer t`]);
+ } finally {
+ await api.close();
+ }
+ });
+
+ it.each([
+ ["failed its gate", [{ name: "CI", conclusion: "failure" }]],
+ ["has not passed its gate yet", [{ name: "CI", conclusion: null }]],
+ ])("runs main's checks for a commit whose merge-group run %s", async (_, gateJobs) => {
+ const { directory, before, after } = pushFixture(code);
+ const api = await fakeRunsApi({ [after]: [{ id: 78, event: "merge_group", status: "completed", conclusion: "failure" }] }, { 78: gateJobs });
+ try {
+ const { output, stderr } = await runPush(directory, { before, after }, github(api));
+ expect(output).toEqual(mainLane());
+ expect(stderr).toBe("");
+ expect(api.requests).toEqual([runsOf(after), "GET /repos/o/r/actions/runs/78/jobs?per_page=100 Bearer t"]);
} finally {
await api.close();
}
@@ -487,37 +557,37 @@ describe("CI scope CLI on a push to main", () => {
["failed", [{ event: "push", status: "completed", conclusion: "failure" }]],
["never ran", []],
["only passed as a pull request", [{ event: "pull_request", status: "completed", conclusion: "success" }]],
- ])("runs everything for a version bump when the commit before it %s", async (_, runs) => {
+ ])("runs main's checks for a version bump when the commit before it %s", async (_, runs) => {
const { directory, before, after } = pushFixture(bump);
const api = await fakeRunsApi({ [before]: runs });
try {
- const { output, stderr } = await runPush(directory, { before, after }, { GITHUB_API_URL: api.url, GH_TOKEN: "t", GITHUB_REPOSITORY: "o/r" });
- expect(output).toEqual(everything(ALL));
+ const { output, stderr } = await runPush(directory, { before, after }, github(api));
+ expect(output).toEqual(mainLane());
expect(stderr).toContain("has no green CI run of its own");
} finally {
await api.close();
}
});
- it("runs everything when the previous commit's CI cannot be read", async () => {
+ it("runs main's checks when the pushed commit's CI cannot be read", async () => {
const { directory, before, after } = pushFixture(bump);
const { output, stderr } = await runPush(directory, { before, after }, { GH_TOKEN: undefined, GITHUB_REPOSITORY: undefined });
- expect(output).toEqual(everything(ALL));
- expect(stderr).toContain("using all checks");
+ expect(output).toEqual(mainLane());
+ expect(stderr).toContain("using main's checks");
});
it.each([
- ["a code change", (directory: string) => writeFileSync(join(directory, "server/index.ts"), "changed\n")],
+ ["a code change", code],
["a version bump with a dependency", (directory: string) => writeFileSync(join(directory, "package.json"), pkg("0.1.101", { dependencies: { zod: "4" } }))],
- ["a version bump with code", (directory: string) => { bump(directory); writeFileSync(join(directory, "server/index.ts"), "changed\n"); }],
- ])("runs everything for %s without asking GitHub", async (_, change) => {
+ ["a version bump with code", (directory: string) => { bump(directory); code(directory); }],
+ ])("runs main's checks for %s, asking GitHub only about the merge queue", async (_, change) => {
const { directory, before, after } = pushFixture(change);
const api = await fakeRunsApi({ [before]: green });
try {
- const { output, stderr } = await runPush(directory, { before, after }, { GITHUB_API_URL: api.url, GH_TOKEN: "t", GITHUB_REPOSITORY: "o/r" });
- expect(output).toEqual(everything(ALL));
+ const { output, stderr } = await runPush(directory, { before, after }, github(api));
+ expect(output).toEqual(mainLane());
expect(stderr).toBe("");
- expect(api.requests).toEqual([]);
+ expect(api.requests).toEqual([runsOf(after)]);
} finally {
await api.close();
}
@@ -527,10 +597,10 @@ describe("CI scope CLI on a push to main", () => {
["a missing payload", {}],
["a new branch", { before: "0".repeat(40), after: "f".repeat(40) }],
["an unknown commit", { before: "f".repeat(40), after: "e".repeat(40) }],
- ])("falls back loudly for %s", async (_, payload) => {
+ ])("falls back loudly to main's checks for %s", async (_, payload) => {
const { directory } = fixture();
const { output, stderr } = await runPush(directory, payload, {});
- expect(output).toEqual(everything(ALL));
- expect(stderr).toContain("using all checks");
+ expect(output).toEqual(mainLane());
+ expect(stderr).toContain("using main's checks");
});
});
diff --git a/scripts/ci-workflow.test.ts b/scripts/ci-workflow.test.ts
index 0342ca0cdf..4640a30689 100644
--- a/scripts/ci-workflow.test.ts
+++ b/scripts/ci-workflow.test.ts
@@ -36,14 +36,21 @@ describe("CI concurrency", () => {
expect(workflow.concurrency["cancel-in-progress"]).toBe("${{ github.event_name == 'pull_request' }}");
});
- it("keeps main to one running and one waiting run, apart from PR and merge-queue groups", () => {
+ it("keeps main's pushes to one running and one waiting run, and gives every other run a group no push joins", () => {
// One group for every main push: GitHub keeps the running run and only
- // the newest waiting one, so a burst of merges cannot pile up full runs.
+ // the newest waiting one, so a burst of merges cannot pile up runs. A
+ // merge group has its own ref; the nightly run and each manual run (the
+ // release lane among them) are named by event and branch, so a push
+ // never replaces one that is waiting.
expect(workflow.concurrency.group).toBe(
- "ci-${{ github.event_name == 'merge_group' && github.event.merge_group.head_ref || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}",
+ "ci-${{ github.event_name == 'merge_group' && github.event.merge_group.head_ref || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.event_name == 'push' && github.ref || format('{0}-{1}', github.event_name, github.ref) }}",
);
});
+ it("runs the full lane every night", () => {
+ expect(workflow.on.schedule).toEqual([{ cron: expect.stringMatching(/^\d+ \d+ \* \* \*$/) }]);
+ });
+
it("stops a closed PR's run by joining ci.yml's PR group", () => {
const stop = parse(readFileSync(new URL("../.github/workflows/ci-stop-closed.yml", import.meta.url), "utf8"));
expect(stop.on).toEqual({ pull_request: { types: ["closed"] } });
@@ -92,8 +99,10 @@ describe("CI concurrency", () => {
expect(units["timeout-minutes"]).toBe(5);
// Once per platform's full run, and beside the locale tests, never once per shard.
expect(units.if).toBe("matrix.node_tests");
- // Browser jobs keep one job per platform.
+ // Browser jobs keep one job per platform, and the packaged server one per platform without the macOS smokes.
expect(workflow.jobs["browser-identity"].strategy.matrix.os).toBe("${{ fromJSON(needs.static.outputs.vitest_os) }}");
+ expect(workflow.jobs["browser-driver"].strategy.matrix.os).toBe("${{ fromJSON(needs.static.outputs.vitest_os) }}");
+ expect(workflow.jobs["packaged-server"].strategy.matrix.os).toBe("${{ fromJSON(needs.static.outputs.packaged_server_os) }}");
});
it("keeps each PR to one macOS job", () => {
@@ -212,6 +221,7 @@ describe("CI concurrency", () => {
jobs: "${{ steps.scope.outputs.jobs }}",
vitest_os: "${{ steps.scope.outputs.vitest_os }}",
vitest_matrix: "${{ steps.scope.outputs.vitest_matrix }}",
+ packaged_server_os: "${{ steps.scope.outputs.packaged_server_os }}",
});
// Only these three static steps depend on the scope's build flag; the rest always run.
const built = (workflow.jobs.static.steps as { if?: string; run?: string }[]).filter((step) => step.if !== undefined);
diff --git a/scripts/release-ci.mjs b/scripts/release-ci.mjs
index a261a5f4ba..be4e620c00 100644
--- a/scripts/release-ci.mjs
+++ b/scripts/release-ci.mjs
@@ -1,16 +1,19 @@
// The release's CI gate: ship only a commit whose code passed CI with every
-// vitest job run, on the commit itself, on a commit with the same tree, or (for
-// a version-only bump) on its parent.
+// platform's vitest shards run, on the commit itself, on a commit with the same
+// tree, or (for a version-only bump) on its parent.
//
-// Main's concurrency group keeps one run going and one waiting, so the release
-// commit's own push run can be skipped; CI then starts on a
-// `release-ci/v<version>` branch no merge on main can touch. A main run is never
-// re-run in place: the re-run would join main's group and cancel the newest
-// merge's waiting run.
+// A push to main or a merge group runs Linux's shards only, so the release
+// commit's own run proves nothing; CI then starts on a `release-ci/v<version>`
+// branch no merge on main can touch, as a manual run of every platform. A main
+// run is never re-run in place: the re-run would join main's group and cancel
+// the newest merge's waiting run.
import { pathToFileURL } from "node:url";
-import { versionOnlyPackageJson } from "./ci-scope.mjs";
+import { FULL_LANE_EVENTS, VITEST_SHARDS, versionOnlyPackageJson } from "./ci-scope.mjs";
-const RELEASE_EVENTS = new Set(["push", "merge_group", "workflow_dispatch"]);
+const RELEASE_EVENTS = new Set(["push", "merge_group", ...FULL_LANE_EVENTS]);
+/** Every platform's every shard, by job name. */
+const FULL_MATRIX = Object.entries(VITEST_SHARDS)
+ .flatMap(([os, shards]) => Array.from({ length: shards }, (_, i) => `vitest (${os}, shard ${i + 1}/${shards})`));
export const POLL_MS = 60_000;
export const MAX_WAIT_MS = 170 * 60_000;
@@ -23,7 +26,9 @@ const neverStarted = (job) => !(job.steps ?? []).some((step) => step.conclusion
/**
* What one finished CI run proves.
- * - "green": the gate passed and every vitest job ran and passed.
+ * - "green": the gate passed and every platform's every vitest shard ran and passed.
+ * - "partial": the gate passed and every vitest job that ran passed, but not every platform's shards ran (a push to
+ * main or a merge group runs Linux's only).
* - "scoped": the gate passed but vitest did not run (docs- or version-only).
* - "runner-lost": the gate failed, and every other failed job never started.
* - "red": the gate failed for any other reason.
@@ -35,7 +40,8 @@ export function judgeRun(jobs) {
if (!gate) return "no gate job";
if (gate.conclusion === "success") {
const vitest = jobs.filter(isVitestJob);
- return vitest.length > 0 && vitest.every((job) => job.conclusion === "success") ? "green" : "scoped";
+ if (vitest.length === 0 || !vitest.every((job) => job.conclusion === "success")) return "scoped";
+ return FULL_MATRIX.every((name) => vitest.some((job) => job.name === name)) ? "green" : "partial";
}
if (gate.conclusion === "failure") {
const failed = jobs.filter((job) => job !== gate && !["success", "skipped", "neutral"].includes(job.conclusion ?? ""));
@@ -164,8 +170,10 @@ export async function waitForReleaseCi({ api, sha, version, sleep = (ms) => new
else if (result === "red" || (result === "runner-lost" && inLane(run))) return { ok: false, reason: `The CI check on ${sha} failed: run ${run.id}` };
else if (result === "runner-lost") log(`CI run ${run.id} on ${sha} failed only because jobs never got a runner; it is not re-run in ${run.head_branch}'s queue.`);
}
- const live = runs.find((run) => run.status !== "completed");
- const parentLive = parent && (await runsFor(parent.sha)).find((run) => run.status !== "completed");
+ // Only a run of every platform can prove the commit, so a push's or merge group's run still going is not waited for.
+ const provable = (run) => run.status !== "completed" && FULL_LANE_EVENTS.includes(run.event);
+ const live = runs.find(provable);
+ const parentLive = parent && (await runsFor(parent.sha)).find(provable);
if (live || rerunning) {
log(`CI on ${sha} is ${live ? `${live.status} (run ${live.id})` : "re-running"}; waiting.`);
} else if (parentLive) {
diff --git a/scripts/release-ci.test.ts b/scripts/release-ci.test.ts
index 135ec1f6f7..962502ea7a 100644
--- a/scripts/release-ci.test.ts
+++ b/scripts/release-ci.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
+import { VITEST_SHARDS } from "./ci-scope.mjs";
import { githubApi, judgeRun, waitForReleaseCi } from "./release-ci.mjs";
const SHA = "a".repeat(40);
@@ -17,10 +18,15 @@ type Run = {
type Commit = { tree: string; parents: string[]; files: string[] };
const started: Step[] = [{ status: "completed", conclusion: "success" }];
-const vitest = (os: string, conclusion: string | null, steps: Step[] = started): Job => ({ name: `vitest (${os}, shard 1/4)`, conclusion, steps });
+const vitest = (os: string, conclusion: string | null, steps: Step[] = started, shard = 1): Job =>
+ ({ name: `vitest (${os}, shard ${shard}/${VITEST_SHARDS[os as keyof typeof VITEST_SHARDS]})`, conclusion, steps });
+const shards = (os: string): Job[] =>
+ Array.from({ length: VITEST_SHARDS[os as keyof typeof VITEST_SHARDS] }, (_, i) => vitest(os, "success", started, i + 1));
const gate = (conclusion: string | null): Job => ({ name: "CI", conclusion, steps: started });
-/** Every vitest shard ran and passed, and so did the gate. */
-const green = (): Job[] => [gate("success"), vitest("ubuntu-latest", "success"), vitest("macos-latest", "success")];
+/** Every platform's every vitest shard ran and passed, and so did the gate: the full lane. */
+const green = (): Job[] => [gate("success"), ...Object.keys(VITEST_SHARDS).flatMap(shards)];
+/** A push to main or a merge group: the gate and every Linux shard passed, nothing else ran. */
+const mainLane = (): Job[] => [gate("success"), ...shards("ubuntu-latest")];
/** A docs- or version-only run: the gate passes with vitest skipped. */
const scoped = (): Job[] => [gate("success"), { name: "vitest (${{ matrix.os }}, shard ${{ matrix.shard }}/4)", conclusion: "skipped", steps: [] }];
/** A real test failure: the shard started and failed. */
@@ -80,13 +86,19 @@ const versionBump = {
};
describe("what a CI run proves", () => {
- it("is green only when the gate passed and every vitest job ran and passed", () => {
+ it("is green only when the gate passed and every platform's every vitest shard ran and passed", () => {
expect(judgeRun(green())).toBe("green");
expect(judgeRun(scoped())).toBe("scoped");
expect(judgeRun([gate("success")])).toBe("scoped");
expect(judgeRun([gate("success"), vitest("ubuntu-latest", "success"), vitest("windows-latest", "skipped")])).toBe("scoped");
});
+ it("is partial when only some platforms' shards ran, as on a push to main or in a merge group", () => {
+ expect(judgeRun(mainLane())).toBe("partial");
+ expect(judgeRun(green().filter((job) => job.name !== "vitest (macos-latest, shard 4/4)"))).toBe("partial");
+ expect(judgeRun([...mainLane(), ...shards("windows-latest")])).toBe("partial");
+ });
+
it("tells a runner that never came from a test that failed", () => {
expect(judgeRun(runnerLost())).toBe("runner-lost");
expect(judgeRun(red())).toBe("red");
@@ -112,22 +124,23 @@ describe("release CI gate", () => {
expect(calls).toEqual([]);
});
- it("waits for a run that is still going, then passes", async () => {
+ it.each(["workflow_dispatch", "schedule"])("waits for a %s run that is still going, then passes", async (event) => {
const { calls, options } = fakeGitHub([
- { runs: [run(1, "push", "queued")] },
- { runs: [run(1, "push", "in_progress")] },
- { runs: [run(1, "push", "completed")], jobs: { 1: green() } },
+ { runs: [run(1, event, "queued")] },
+ { runs: [run(1, event, "in_progress")] },
+ { runs: [run(1, event, "completed")], jobs: { 1: green() } },
]);
expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 1, via: "commit" });
expect(calls).toEqual([]);
});
it("counts a re-run that passed after a failed first attempt", async () => {
- const { options } = fakeGitHub([
- { runs: [run(1, "push", "in_progress", "main", 0, { run_attempt: 2 })] },
- { runs: [run(1, "push", "completed", "main", 0, { run_attempt: 2 })], jobs: { 1: green() } },
+ const { calls, options } = fakeGitHub([
+ { runs: [run(1, "workflow_dispatch", "in_progress", "main", 0, { run_attempt: 2 })] },
+ { runs: [run(1, "workflow_dispatch", "completed", "main", 0, { run_attempt: 2 })], jobs: { 1: green() } },
]);
- expect(await waitForReleaseCi(options)).toMatchObject({ ok: true });
+ expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 1, via: "commit" });
+ expect(calls).toEqual([]);
});
it("stops on a red gate instead of retrying it", async () => {
@@ -168,12 +181,60 @@ describe("release CI gate", () => {
});
it("gives up after the wait limit with no verdict", async () => {
- const { calls, options } = fakeGitHub([{ runs: [run(1, "push", "in_progress")] }]);
+ const { calls, options } = fakeGitHub([{ runs: [run(1, "workflow_dispatch", "in_progress")] }]);
expect(await waitForReleaseCi(options)).toMatchObject({ ok: false, reason: expect.stringContaining("within 10 minutes") });
expect(calls).toEqual([]);
});
});
+describe("a run of Linux's shards alone is no proof", () => {
+ it.each(["push", "merge_group"])("starts CI in the lane after the commit's green %s run", async (event) => {
+ const { calls, options } = fakeGitHub([
+ { runs: [run(1, event, "completed")], jobs: { 1: mainLane() } },
+ { runs: [run(1, event, "completed"), run(2, "workflow_dispatch", "completed", "release-ci/v0.1.94", 5)], jobs: { 1: mainLane(), 2: green() } },
+ ]);
+ expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 2, via: "commit" });
+ expect(calls).toEqual(LANE);
+ });
+
+ it("starts the lane at once instead of waiting for a push's run that is still going", async () => {
+ const { calls, options } = fakeGitHub([
+ { runs: [run(1, "push", "in_progress")] },
+ { runs: [run(1, "push", "in_progress"), run(2, "workflow_dispatch", "in_progress", "release-ci/v0.1.94", 5)] },
+ { runs: [run(1, "push", "completed"), run(2, "workflow_dispatch", "completed", "release-ci/v0.1.94", 5)], jobs: { 1: mainLane(), 2: green() } },
+ ]);
+ expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 2, via: "commit" });
+ expect(calls).toEqual(LANE);
+ });
+
+ it("still stops on the commit's red push run", async () => {
+ const { calls, options } = fakeGitHub([{ runs: [run(1, "push", "completed")], jobs: { 1: red() } }]);
+ expect(await waitForReleaseCi(options)).toMatchObject({ ok: false, reason: expect.stringContaining("failed: run 1") });
+ expect(calls).toEqual([]);
+ });
+
+ it("fails the release when its own lane ran only some platforms", async () => {
+ const { calls, options } = fakeGitHub([
+ { runs: [] },
+ { runs: [run(2, "workflow_dispatch", "completed", "release-ci/v0.1.94")], jobs: { 2: mainLane() } },
+ ]);
+ expect(await waitForReleaseCi(options)).toMatchObject({ ok: false, reason: expect.stringContaining("release lane did not pass (partial)") });
+ expect(calls).toEqual(LANE);
+ });
+
+ it("passes on the nightly run of a commit with the same tree", async () => {
+ const { calls, options } = fakeGitHub([{
+ runs: [
+ run(1, "push", "completed"),
+ run(8, "schedule", "completed", "main", 0, { head_sha: OTHER, head_commit: { tree_id: TREE } }),
+ ],
+ jobs: { 1: mainLane(), 8: green() },
+ }]);
+ expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 8, via: "tree" });
+ expect(calls).toEqual([]);
+ });
+});
+
describe("a run that skipped the tests is no proof", () => {
it("does not pass on the commit's own run whose vitest was skipped, and runs CI in the lane", async () => {
const { calls, options } = fakeGitHub([
@@ -241,8 +302,8 @@ describe("a version-only bump reuses its parent's CI", () => {
expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 6, via: "parent" });
});
- it("waits for the parent's run that is still going", async () => {
- const parentRun = (status: string) => run(5, "push", status, "main", 0, { head_sha: PARENT });
+ it("waits for the parent's nightly run that is still going", async () => {
+ const parentRun = (status: string) => run(5, "schedule", status, "main", 0, { head_sha: PARENT });
const { calls, options } = fakeGitHub([
{ runs: [run(1, "push", "completed"), parentRun("in_progress")], jobs: { 1: scoped() } },
{ runs: [run(1, "push", "completed"), parentRun("in_progress")], jobs: { 1: scoped() } },
@@ -264,6 +325,15 @@ describe("a version-only bump reuses its parent's CI", () => {
expect(calls).toEqual(LANE);
});
+ it("never passes on a parent's run of Linux's shards alone", async () => {
+ const { calls, options } = fakeGitHub([
+ { runs: [run(5, "push", "completed", "main", 0, { head_sha: PARENT })], jobs: { 5: mainLane() } },
+ { runs: [run(5, "push", "completed", "main", 0, { head_sha: PARENT }), run(2, "workflow_dispatch", "completed", "release-ci/v0.1.94", 5)], jobs: { 5: mainLane(), 2: green() } },
+ ], versionBump);
+ expect(await waitForReleaseCi(options)).toEqual({ ok: true, runId: 2, via: "commit" });
+ expect(calls).toEqual(LANE);
+ });
+
it("never passes on a parent run that skipped its tests", async () => {
const { calls, options } = fakeGitHub([
{ runs: [run(5, "push", "completed", "main", 0, { head_sha: PARENT })], jobs: { 5: scoped() } },
@@ -350,7 +420,7 @@ describe("a runner that never came", () => {
expect(calls).toEqual(LANE);
});
- it("waits for another run on the commit before starting the lane", async () => {
+ it("waits for another manual run on the commit before starting the lane", async () => {
const lost = run(1, "push", "completed");
const { calls, options } = fakeGitHub([
{ runs: [lost, run(3, "workflow_dispatch", "in_progress", "main", 2)], jobs: { 1: runnerLost() } },
@@ -402,13 +472,14 @@ describe("GitHub calls", () => {
const api = githubApi({ token: "t", repository: "o/r", fetchImpl: fetchImpl as typeof fetch });
expect(await api.commit(SHA)).toEqual({ tree: TREE, parents: [PARENT], files: ["package.json"] });
expect(JSON.parse((await api.fileAt("package.json", SHA))!).version).toBe("0.1.94");
- expect(await api.recentRuns()).toHaveLength(3);
+ expect(await api.recentRuns()).toHaveLength(4);
await api.rerunFailedJobs(42);
expect(requests).toEqual([
`GET /commits/${SHA}`,
`GET /contents/package.json?ref=${SHA}`,
"GET /actions/workflows/ci.yml/runs?status=completed&event=push&per_page=100",
"GET /actions/workflows/ci.yml/runs?status=completed&event=merge_group&per_page=100",
+ "GET /actions/workflows/ci.yml/runs?status=completed&event=schedule&per_page=100",
"GET /actions/workflows/ci.yml/runs?status=completed&event=workflow_dispatch&per_page=100",
"POST /actions/runs/42/rerun-failed-jobs",
]);