ci(spec): cut the eight-minute test jobs into two-minute shards
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.
testis twelve legs per Node.js version, not two: eightvitest --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 onmain. electronis one job per suite, andelectron-windowsruns its testbed as two shards.- The crate checks (
cargo fmt, clippy,cargo test) are a job of their own,crates, besidenative. - The nightly release asks for
spec gateby 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):
| Job | Typical | Slow | What takes the time |
|---|---|---|---|
test (*, runner) | 472 to 524 s | 544 to 617 s | 145 integration test files, 1216 s of them, three at a time |
test (*, packages) | 387 to 417 s | 452 to 513 s | 20 packages one after another, 152 s of it one desktop test file |
electron-windows | 262 s | 326 s | about 50 s of setup, then integration tests and the testbed in a row |
check | 226 s | 314 s | the testbed, 178 s on one worker |
electron | 180 s | 250 s | integration tests, then the testbed |
native | 152 s | 184 s | clippy, 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
testkeeps its Node.js matrix and gets twelve suites (.github/workflows/spec.yml,suite:). Onecasein the test step says what each runs. Each leg calls one or two root scripts inpackage.json(test:runner,test:web,test:desktop,test:mobile,test:packages;desktop and mobileruns two) with its--shardor-t, andpnpm testruns the same five in turn, so CI andpnpm testname the same packages.runner 1/8torunner 8/8runpnpm run test:runner --shard=n/8, which isvitest run --shard=n/8inpackages/e2e. Each machine still runs three integration files at a time, asvitest.config.tssets, 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.webruns@e2e-dev/web.packagesruns every package no other leg names, by!filters, so a new package is tested without a change to the workflow.@e2e-dev/coreis one of them; the roottest:runnerused to run it before e2e. The script tests run after them.packages/desktop/tests/unit/surface.test.tstakes 152 s and Vitest shards whole files. 106 s of it is onedescribe,DesktopSurface: the launch wait, where ten of the 18 tests wait out the real ten second launch wait.desktop launch waitruns the tests whose full name starts with that title (-t "^$LAUNCH_WAIT"), anddesktop and mobileruns 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 inpackages/desktop/src/launch-wait.ts, and several open pull requests edit that test file.testbedtakes the testbed steps out ofcheck. On a pull request part 1 is the run Jev filters (--changed-since) withscroll_to, and part 2 is the Playwright tests: the two runscheckalready made, with the same commands, side by side. Every other event runs every test, ase2e 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.electronrunsintegrationandtestbedas two matrix legs.electron-windowsrunsintegration,testbed 1/2, andtestbed 2/2.cratestakescargo fmt, clippy, andcargo testout ofnative, which keeps the notices check, the two release builds, and the loads. Clippy, the tests, and the release builds share no compiled output.spec gateneedstestbedandcratesas well. Its name is unchanged, so the ruleset still finds it.release.ymlasks the check runs API forcheck_name=spec%20gate. It read the first hundred check runs of the commit, and a commit onmainhas more: the gate was not among them on any of the fourmaincommits under Verified, and four of the last eight nightlies stopped there withspec 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.
specran 399 times in the last 24 hours: 258 pull requests, 96 queue entries, 45 pushes. A cheaper cut is to shard only onmerge_groupandpushand 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
webleg 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, andpackages. A second leg each would shortenwebandpackages. 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_groupruns are where to compare them. Reverting this change puts the old jobs back. setup-nodelooks 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.mdsays not to do. - Shards do not fix a flaky test. 30 of the 98 queue runs of
specfailed, 26 of them in one job, and 16 of the failed jobs were one test intest-step.test.ts(#2563). mobile gatestill 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
nativerun the whole desktop unit suite, the 152 s file included. After it mergesnativeis 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/8for n in 1 to 8 lists 404 files with none twice, the same 404 as the unsharded list.pnpm run test:runner --shard=8/8runs its 50, and the root scripts pass--shardand-tthrough to Vitest (vitest run --shard=8/8,vitest run -t '^DesktopSurface: the launch wait '). - The package legs cover every package with a
testscript: the four named ones and the 18 the!filters leave are all 22. - The two desktop legs cover the desktop suite once.
vitest listnames 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:188and: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, withAI_GATEWAY_API_KEYunset oncf09e1654: 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'sworkflow_call, so this pull request's own run does not show them. e2e list --shard n/2on the Electron testbed lists each of its 101 tests in exactly one shard.- The nightly's lookup on four
maincommits, two of them nightlies that stopped aspending:
| Commit | check-runs?per_page=100 | check-runs?check_name=spec%20gate |
|---|---|---|
ad564a886 | pending | success |
7c1b2b258 | pending | success |
ddebc946c | pending | success |
aaf923188 | pending | success |
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.
main | This PR | |
|---|---|---|
spec gate reports, after the run is created | 518 s, 523 s | 206 s |
| Jobs | 19 | 75 |
| A Linux job starts, after the run is created (median) | 6 s | 8 s, at most 11 s |
| A Mac job starts | 31 s, 32 s | 28 s |
| Linux runner minutes | 79.4, 80.1 | 136.1 |
| Windows runner minutes | 4.8, 5.0 | 7.4 |
| Mac runner minutes | 2.6, 2.8 | 2.4 |
When each job finished, after the run was created (the slowest Node.js version of each):
| Job | Finished |
|---|---|
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 |
native | 125 s |
electron (testbed) | 122 s |
crates | 73 s |
check | 49 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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@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.