ci(spec): cut the eight-minute test jobs into two-minute shards

Merged
MI
1d ago
+162-43

What

spec runs its slow jobs as more, shorter jobs. On this pull request spec gate reported 206 s after the run started, where recent pull request runs take about 520 s. No leg ran tests for over two and a half minutes, where the longest job ran them for eight. It runs the same tests on the same Node.js versions and the same runners.

  • test is twelve legs per Node.js version, not two: eight vitest --shards of e2e's own suite, and the packages in four groups.
  • The testbed is a job of its own, testbed, in two parts on a pull request and three shards in the merge queue and on main.
  • electron is one job per suite, and electron-windows runs its testbed as two shards.
  • The crate checks (cargo fmt, clippy, cargo test) are a job of their own, crates, beside native.
  • The nightly release asks for spec gate by name.

Why

The merge queue waits for the slowest job of the slowest workflow. Over the last 98 finished queue entries (2026-11-28 to 2026-11-30) spec took a median of 466 s and was the slowest workflow in 57 of them. mobile was the slowest in the other 41.

Where the 466 s goes, from one typical queue run (46456156279) and one slow one (46473654329):

JobTypicalSlowWhat takes the time
test (*, runner)472 to 524 s544 to 617 s145 integration test files, 1216 s of them, three at a time
test (*, packages)387 to 417 s452 to 513 s20 packages one after another, 152 s of it one desktop test file
electron-windows262 s326 sabout 50 s of setup, then integration tests and the testbed in a row
check226 s314 sthe testbed, 178 s on one worker
electron180 s250 sintegration tests, then the testbed
native152 s184 sclippy, tests, and two release builds in a row, after about 30 s waiting for a Mac

No step is slow to start: install takes about a second and the build about five. The time is tests that run in a row on one machine.

How it works

  1. test keeps its Node.js matrix and gets twelve suites (.github/workflows/spec.yml, suite:). One case in the test step says what each runs. Each leg calls one or two root scripts in package.json (test:runner, test:web, test:desktop, test:mobile, test:packages; desktop and mobile runs two) with its --shard or -t, and pnpm test runs the same five in turn, so CI and pnpm test name the same packages.
  2. runner 1/8 to runner 8/8 run pnpm run test:runner --shard=n/8, which is vitest run --shard=n/8 in packages/e2e. Each machine still runs three integration files at a time, as vitest.config.ts sets, so the load on a runner is what it was. Vitest cuts by a hash of the file path, not by duration: at six shards the heaviest held 370 s of integration files, at eight it holds 270 s. More shards would shorten the slowest by little: one integration file takes 78 s by itself, and twelve shards would cut the heaviest by about an eighth.
  3. web runs @e2e-dev/web. packages runs every package no other leg names, by ! filters, so a new package is tested without a change to the workflow. @e2e-dev/core is one of them; the root test:runner used to run it before e2e. The script tests run after them.
  4. packages/desktop/tests/unit/surface.test.ts takes 152 s and Vitest shards whole files. 106 s of it is one describe, DesktopSurface: the launch wait, where ten of the 18 tests wait out the real ten second launch wait. desktop launch wait runs the tests whose full name starts with that title (-t "^$LAUNCH_WAIT"), and desktop and mobile runs every desktop test whose name does not (-t "^(?!$LAUNCH_WAIT)"), then the mobile package. The two patterns are complements, so each test runs in exactly one leg whatever it is called. If the group is renamed its leg runs nothing and the other leg runs it all, slower. Dropped alternative: shortening the wait in the tests. That needs the wait to be injectable in packages/desktop/src/launch-wait.ts, and several open pull requests edit that test file.
  5. testbed takes the testbed steps out of check. On a pull request part 1 is the run Jev filters (--changed-since) with scroll_to, and part 2 is the Playwright tests: the two runs check already made, with the same commands, side by side. Every other event runs every test, as e2e run --shard n/3. Only part 1 on a pull request gets the model key: the runner asks the test filter only with --changed-since, so the shards have no use for it.
  6. electron runs integration and testbed as two matrix legs. electron-windows runs integration, testbed 1/2, and testbed 2/2.
  7. crates takes cargo fmt, clippy, and cargo test out of native, which keeps the notices check, the two release builds, and the loads. Clippy, the tests, and the release builds share no compiled output.
  8. spec gate needs testbed and crates as well. Its name is unchanged, so the ruleset still finds it.
  9. release.yml asks the check runs API for check_name=spec%20gate. It read the first hundred check runs of the commit, and a commit on main has more: the gate was not among them on any of the four main commits under Verified, and four of the last eight nightlies stopped there with spec gate ... is pending, not publishing. Whether the gate is on the first page depends on when the nightly asks, and this change adds about 57 check runs per commit, which pushes it further off.

For maintainers:

  • Cost. A run goes from 19 jobs to 75 on a pull request and 76 in the queue, and each added job adds about half a minute of checkout, install, browser, and build. This run used 136 Linux runner minutes, where two recent pull request runs used 79 and 80 (170 against 87 when each job rounds up to a minute). Windows went from 5 minutes to 7.4, and Mac stayed at about 2.5. spec ran 399 times in the last 24 hours: 258 pull requests, 96 queue entries, 45 pushes. A cheaper cut is to shard only on merge_group and push and leave pull requests as they are.
  • It is not under three minutes yet. The gate waits for the slowest of 60 test legs, and the web leg ran its tests in 91 to 146 s from one runner to the next. Four legs finished past 180 s: runner 1/8, runner 4/8, web, and packages. A second leg each would shorten web and packages. The runner shards are bound by their longest files (78 s and 63 s), so those need the files shorter, not more shards.
  • Job start times were measured with one run of 75 jobs at a time. The queue builds up to five entries at once, so the first merge_group runs are where to compare them. Reverting this change puts the old jobs back.
  • setup-node looks up the newest release of each Node.js line (check-latest) in 60 legs per run, where it did in 10. One run cannot show whether that strains the token's hourly limit.
  • The alternative to shards is one larger runner per Node.js version with more integration workers. It needs no extra jobs, but it changes the load each machine carries, which AGENTS.md says not to do.
  • Shards do not fix a flaky test. 30 of the 98 queue runs of spec failed, 26 of them in one job, and 16 of the failed jobs were one test in test-step.test.ts (#2563).
  • mobile gate still takes about 13 minutes whenever a change reaches the runner or the mobile engine (41 of the 98 entries). This change does not touch it.
  • #2356 makes native run the whole desktop unit suite, the 152 s file included. After it merges native is likely the longest job again; no run has both changes yet.
  • #2341 edits the same needs: line of the gate, so whichever merges second resolves one line.

Issue

None.

Verified

Ran it locally: yes, what runs off CI. The workflow itself runs here, on this pull request.

  • The eight shards cover e2e's suite once: vitest list --filesOnly --shard=n/8 for n in 1 to 8 lists 404 files with none twice, the same 404 as the unsharded list. pnpm run test:runner --shard=8/8 runs its 50, and the root scripts pass --shard and -t through to Vitest (vitest run --shard=8/8, vitest run -t '^DesktopSurface: the launch wait ').
  • The package legs cover every package with a test script: the four named ones and the 18 the ! filters leave are all 22.
  • The two desktop legs cover the desktop suite once. vitest list names 18 tests in the launch wait group and 286 in the rest, 304 in all. Fewer run, because some tests skip by platform (driver.test.ts:122, surface.test.ts:188 and :2238): on macOS the rest ran 269 and skipped 19, and on Linux in CI (Node.js 24.8.0) the two legs ran 18 and 267 of 288.
  • The testbed as the queue runs it, pnpm --filter @e2e-dev/testbed test --shard n/3, with AI_GATEWAY_API_KEY unset on cf09e1654: the three shards ran 215, 213, and 214 tests, 642 in all, and each exited 0. A pull request never runs these three, nor the nightly's workflow_call, so this pull request's own run does not show them.
  • e2e list --shard n/2 on the Electron testbed lists each of its 101 tests in exactly one shard.
  • The nightly's lookup on four main commits, two of them nightlies that stopped as pending:
Commitcheck-runs?per_page=100check-runs?check_name=spec%20gate
ad564a886pendingsuccess
7c1b2b258pendingsuccess
ddebc946cpendingsuccess
aaf923188pendingsuccess

Timings, from this pull request's run on 738ced1e0 (46499745586, all 75 jobs green) beside two recent pull request runs near the median of the last 60 (46443106360, 46436712583). The run on the first commit reported at 202 s.

mainThis PR
spec gate reports, after the run is created518 s, 523 s206 s
Jobs1975
A Linux job starts, after the run is created (median)6 s8 s, at most 11 s
A Mac job starts31 s, 32 s28 s
Linux runner minutes79.4, 80.1136.1
Windows runner minutes4.8, 5.07.4
Mac runner minutes2.6, 2.82.4

When each job finished, after the run was created (the slowest Node.js version of each):

JobFinished
test (*, runner 1/8)197 s
test (*, runner 4/8)193 s
test (*, web)192 s
test (*, packages)186 s
test (*, runner 2/8)166 s
electron-windows (integration)164 s
electron-windows (testbed 2/2)160 s
test (*, desktop launch wait)154 s
testbed (2)146 s
native125 s
electron (testbed)122 s
crates73 s
check49 s

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

Summary by CodeRabbit

  • Chores
    • Automated checks now run in parallel across more test suites and platforms, including separate Rust and Electron test jobs.
    • The nightly release check can locate the required passing result even when it isn’t among the first 100 checks.
    • The main test command now covers runner, web, desktop, mobile, and package tests after building.
    • Test suites are organized into dedicated runs, with browser setup skipped for desktop suites.