Sharding tests
After --shards N, every run: step sees HV_SHARD_INDEX (from 0) and
HV_SHARD_COUNT. Tell your test runner which slice to run; most have a flag
for it.
| Runner | Command |
|---|---|
| cargo-nextest | cargo nextest run --partition count:$((HV_SHARD_INDEX+1))/$HV_SHARD_COUNT |
| Jest | npx jest --shard=$((HV_SHARD_INDEX+1))/$HV_SHARD_COUNT |
| Vitest | npx vitest run --shard=$((HV_SHARD_INDEX+1))/$HV_SHARD_COUNT |
| Playwright | npx playwright test --shard=$((HV_SHARD_INDEX+1))/$HV_SHARD_COUNT |
| pytest | hv-pytest-shard tests/ (preinstalled), or the pytest-split plugin |
| Go | hv-go-shard ./... (preinstalled: one package per slot) |
plain cargo test |
hv-cargo-shard --workspace (preinstalled) |
automake make check |
hv-make-check-shard (preinstalled) |
Anything else works too: the variables are all there is. With --shards 1
nothing is split; the step simply runs recorded.
Balance: a shard takes as long as its slowest test file. Runners that split by test (nextest, our helpers) balance better than ones that split by file.