GitHub Actions test sharding: how many shards actually pay
GitHub Actions test sharding trades money for wall clock, and it stops paying at a point you can calculate from two numbers you already have. On a runner we measured, a 26.8 second suite split two ways finished in 13.8 seconds and four ways in 9.2, while the billed time went the other way, from 26.8 seconds to 27.5 and then 29.0. One twelve-file suite, split three ways, measured on a…
GitHub Actions test sharding divides a test suite across multiple shards to save time, but not every additional shard provides equal value. A measurement on a Latchkey runner showed a 26.8 second suite divided into two shards completed in 13.8 seconds, while four shards reduced it to 9.25 seconds - a 5.5 second savings. However, the billed time increased from 26.77 to 29.0 seconds, so the fourth shard did not justify its cost.
Billed time accumulates across all shards, rounding up to the nearest minute. For a small suite, sharding is a loss that only adds up when run multiple times. The savings scale with the work being done, while the fixed penalty per shard remains constant. To achieve optimal sharding, the test file durations should be balanced across shards, ensuring each shard has roughly equal work.
Tools like Vitest, Playwright, Jest, and pytest offer flags to split tests by duration or file count, allowing for more even distribution.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.
- npm ERR! network errors in GitHub Actions dev.to
- GitHub Incident with Webhooks, Actions, etc. githubstatus.com