Repository navigation
ci: split the PR test job by vitest project, sharding only the ui half - #4103
sangwook-dev wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
1569b12 to
83aa6ea
Compare
83aa6ea to
5744072
Compare
5744072 to
3827985
Compare
3827985 to
ee04162
Compare
ee04162 to
b014e5c
Compare
|
@cixzhang Rebased onto latest main and reworked the split; the measurements behind it are in the description. Would appreciate a review when you have a moment. |
The single test job is already the CI bottleneck everywhere except a cold first
push: warm-cache re-pushes drop build-sandbox to ~3m30s, and merge_group runs
never build the sandbox at all. Split pnpm test into a matrix with a join job
preserving the historical `test` check name, mirroring the existing `build`
join gate.
Split on the project boundary first, and by file hash only inside `ui`. Only
the `node` project's globalSetup builds core, so keeping node to one job pays
that build once instead of once per shard, and `--project=ui` skips the
globalSetup entirely.
Measured on 2-core-ubuntu-arm, cold pushes, as the `test` check:
- hashing all 499 files three ways: 329s. Shards ran 198s/284s/215s of pnpm
test. They are even by file count (167/166/166) but the hash is blind to
duration — shards 1 and 3 had near-identical project mixes yet differed by
17s.
- splitting by project alone: 497s. ui is 439s against node's 173s, holding
77% of the work and parallelizing badly on two cores (its per-file total is
214.5s, which a 10-core box compresses to 55.5s and this runner does not).
- this shape: 296s, from 271s/292s/224s.
Solving the first two runs for the shared core build puts it at ~42s. Sharding
ui is not free either: two ui shards cost 476s of pnpm test against 439s
unsharded, because each shard re-pays vitest startup and the shared StyleX
transform. A third ui shard is worth much less than 439s/3 would suggest, and
node's 224s is a floor underneath it, so this stops at two.
Repo-sync checks run once, on the node job — the shortest of the three.
fail-fast is off so one red job does not cancel the others' report.
� Conflicts:
� .github/workflows/ci.yml
b014e5c to
a3bb9e9
Compare
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the measurements make the case, and the join gate matches build's. Would merge as is. Nit: vitest.config.ts's SYNC line should list ci.yml now.
[Reviewed by Robohands]
|
Thanks @Han5991 — the diagnosis is right and the shape is sensible: splitting I'm going to close it anyway, and I owe you a straight reason. We approved this a few hours ago in a backlog sweep without weighing whether it was worth landing, which wasn't a real review. Looking at it properly: Nothing here was wrong. If CI time becomes a real problem this is the first thing I'd reach for, and I'd rather come back to you then than have it sit open another month. Reopening is welcome any time — merge main in first, since the branch has aged. Discord if you'd rather talk it through with a person. [Reviewed by Robohands] |
|
Thanks for writing this out — that's a much clearer explanation than most closes get, and I appreciate the honesty about the backlog sweep. Your reasoning makes sense to me. Rebasing onto a ci.yml that's moved twelve times is real work, and if CI wall-clock isn't a constraint you're feeling right now, I agree the trade doesn't justify it today. I've gone ahead and deleted the branch. Given how much ci.yml has moved, I think it'd be cleaner to discuss the approach first and write it fresh at that point rather than resurrect an aged branch. If CI time becomes a real bottleneck, ping me and I'm happy to pick it up again. Thanks again. |
Why
The single
testjob is the CI critical path in every context except a cold first push:test: the per-PR Next cache dropsbuild-sandboxto ~3m30s whiletestdoes not move.merge_group) never runsbuild-sandbox, sotestis the critical path there outright.What
Split
pnpm testinto a matrix with a join job that keeps the historicaltestcheck name — the same pattern thebuildjoin gate already uses for build-storybook/build-sandbox. Branch protection and anything keyed ontestkeeps working; docsite-only PRs skip the matrix and the gate exactly as the old single job did.The split is on the vitest project boundary first, and by file hash only inside
ui:test (ui 1/2)pnpm test --project=ui --shard=1/2test (ui 2/2)pnpm test --project=ui --shard=2/2test (node)pnpm test --project=node --shard=1/1Only the
nodeproject has aglobalSetupthat builds@astryxdesign/core;--project=uiskips it entirely. Keepingnodeto a single job pays that build once instead of once per shard.Repo-sync checks (copyright headers, exports sync, CLI
./apitypes, token docs) run once, on thenodejob — the shortest of the three.fail-fastis off so one red job does not cancel the others' report.Why this shape
Three shapes were measured end-to-end on
2-core-ubuntu-arm, cold pushes, as thetestcheck:testcheckui|node)ui×2 +node(this PR)Three things those runs settled:
1.
--shardis blind to duration. It partitions on sha1 of the file path. The three-way split was perfectly even by file count (167/166/166) yet ran 198s/284s/215s ofpnpm test— and shards 1 and 3 had near-identical project mixes while still differing by 17s.2.
uiandnodeare not interchangeable halves. Run alone,uiis 439s againstnode's 173s.uiholds 77% of the work and parallelizes badly on two cores: its per-file total is 214.5s, which a 10-core box compresses to 55.5s and this runner does not. A pure project split therefore leaves theuihalf fully serialized, which is why it is the slowest of the three despite using the fewest runners.3. Sharding
uiis not free either. Twouishards cost 476s ofpnpm testagainst 439s unsharded, because each shard re-pays vitest startup and the shared StyleX transform. Solving the first two runs for the shared core build puts it at ~42s, which leavesnodeas a ~224s floor. A thirduishard buys much less than439s / 3would suggest and would land on that floor anyway, so this stops at two.Scope
ci.ymlonly (pull_request + merge_group — the paths people wait on).deploy.yml's test job also runs the full suite on main, but it interleavespnpm testwith build/typecheck deploy gates in one job; sharding it needs a restructure of the deploy dependency graph and is left as a follow-up.Verification
--project=uiskipping thenodeglobalSetup was verified directly: withpackages/core/distremoved,vitest run --project=uileaves it absent, while--project=noderecreates it.pnpm test --project=… --shard=…forwards through thepnpm testscript, and--shard=1/1is a valid single-shard selection.testfinished at 296s againstbuild-sandbox's 298s —testis no longer the critical path on cold pushes. Onmerge_group, wherebuild-sandboxnever runs, it remains the longest job, now ahead ofbuild-storybook(193s) by ~100s rather than by the full single-job time.One caveat worth recording: the near-even
uisplit is a property of today's file set, not of the algorithm. Replaying vitest's hash over the current 278uifiles splits the measured work 49.9% / 50.1%, but adding or renaming test files reshuffles it, and the same replay over three shards gives 24% / 42% / 34%.