Skip to content

ci: npm test runs as two shards, one hosted job each - #578

Merged
SSFSKIM merged 2 commits into
mainfrom
ci-opt/test-shards
Nov 24, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
ci-opt/test-shards

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

What this changes

The test gate becomes two gates, test-1 and test-2, each a hosted macOS job running half of the files npm test runs.

Why: over the 16 finished ci runs of 2026-11-23 22:51Z to 11-24 03:44Z the gate took 13.3 to 17.0 minutes on 13 of them (npm test alone 11.5 to 14.0 min) and 6.4 to 6.7 on the other 3. GitHub's macos-latest fleet has machines about 2.2x apart in speed on the same image (macos-26-arm64 20261117.0516), and which one a job gets is not ours to choose. On the slower machines the gate is the longest job of a run whenever sandbox-denials is not selected.

  • scripts/test-shard.mjs <index>/<total> reads the pattern from package.json's test script and runs node --test --test-shard=<index>/<total> <pattern>, so discovery and selection are Node's (602 files today). Its own glob is for the progress line and the empty-shard guard; a test runs every shard of a fixture and compares what ran with the script's own deal. It exits as node --test does; a shard that selects no file, a malformed shard, or a test script that is no longer node --test "<pattern>" exits 2.
  • scripts/repl-parity/coverage.mjs takes its reading of npm test from the same function (npmTestPattern), so the file it proves "runs under npm test" is a file the shards run.
  • .github/ci-kit.yml: test-1 runs shard 1/2; test-2 runs shard 2/2, then npm run test:linux-engine-diff (the harness suite through its cleanup check). Both keep CUA_ENGINE_UNITS_GATE. Neither has paths or on, so every run selects both and ci / verdict needs both.
  • test/test-shard.test.mjs: the shards of this repository's npm test run every file once and none is empty (1, 2, 3 and 5 shards); an empty shard fails; ci-kit.yml names every shard of one total, as test-<index>, with no paths or on, and no gate runs npm test whole beside them.
  • test/linux-engine-diff/leak-check.test.mjs: its reading of the gate follows (exactly one test shard runs the cleanup check).

package.json's test script is unchanged: npm test locally is what it was.

What a caller sees

ci-gate --gates test is now refused by name, with the known gates listed; the form is --gates test-1,test-2.

Durations

run job machine whole job of which node --test harness suite
45327655772 (this branch, 2bcce74) test-1 slower 6m57s 387 s (301 files, 3,649 tests) -
45327655772 (this branch, 2bcce74) test-2 faster 3m28s 118 s (301 files, 3,477 tests) 62 s
45313367589 (single job, 73f08f2) test slower 14m06s 689 s 126 s
45321524251 (single job, 324a710) test faster 6m39s 309 s 62 s

"Slower" and "faster" are read from the same CPU-bound tests' times inside each log. Both runs with engine-swift selected, so the Swift unit suite is skipped in the first three rows; the last row ran it (88 s).

The halves are not equal: shard 1 holds about 59% of the work (387 s on a slower machine is about 168 s on a faster one, against shard 2's 118 s). The harness suite on shard 2 evens it: on a slower machine each job comes to about 7 minutes, against 13 to 17 for the single job.

Review

One independent review (low): one finding, fixed in the second commit. The first commit passed its share as explicit arguments, and node --test reads each argument as a glob, so a file named with glob characters (widget-[ab].test.mjs) would have run in no shard, with exit 0.

Not verified

  • The guard is on files selected, not on tests: a shard whose files hold no test would pass as node --test passes it.
  • engine-linux failed once in this run on clipboard::tests::an_unconfirmed_paste_s_current_time_refusal_covers_the_next_paste_too, which tech-debt-tracker.md already lists; this branch touches no Rust. The job is rerun.
  • Which shard holds test/native-engine-units.test.mjs (shard 1 today) follows its place in the sorted list, so when engine-swift is not selected one shard carries that suite (87 to 206 s) and the balance moves with the file list.

Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)

The `test` gate took 13 to 17 minutes on GitHub's slower hosted macOS
machines (16 runs, 2026-11-23 and 24; `npm test` alone 11 to 14 of them),
and it is the longest job of a run whenever sandbox-denials is not
selected.

scripts/test-shard.mjs <index>/<total> reads the pattern from
package.json's `test` script, sorts the files and runs every <total>-th
with `node --test`. A shard that selects no file exits 2. coverage.mjs
takes its reading of `npm test` from the same function, so what it proves
"runs under npm test" is what the shards run.

.github/ci-kit.yml: `test` becomes `test-1` and `test-2`; test-2 also
runs the harness suite through its cleanup check. Neither has `paths` or
`on`, so every run selects both and the verdict needs both;
test/test-shard.test.mjs holds the file to that, and to naming every
shard of one total. `--gates test` is now refused by name, with the known
gates listed.

Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T04:33:22.341920Z fa0e457 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…characters runs

node --test reads every positional argument as a glob, so a file selected by
the script and passed by name, such as test/widget-[ab].test.mjs, matched as a
pattern: Node ran zero tests for it and exited 0, and a file npm test runs ran
in no shard. The script now passes package.json's own pattern with
--test-shard=<index>/<total>, so discovery and selection are Node's. Its own
glob stays for the progress line and the empty-shard guard; a test pins its
deal to Node's by running every shard of a fixture and comparing the files
that ran with the file list.

Sminos-Session: CI-opt#a45b97a3 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit 0d4c599 into main Nov 24, 2026
24 of 26 checks passed
@SSFSKIM
SSFSKIM deleted the ci-opt/test-shards branch November 24, 2026 05:52
SSFSKIM added a commit that referenced this pull request Nov 24, 2026
…at/117-m5 (refs #506)

Sminos-Session: cursor235#b93055dd (cua on macbook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant