How do I run tests in parallel with GitHub Actions matrix?
Suite takes 40 min. Want to shard across 4 runners. What does the workflow look like?
github-actionsciparallel
Suite takes 40 min. Want to shard across 4 runners. What does the workflow look like?
Accepted solution
Use a build matrix to fan the same job out across versions, browsers or shards. GitHub Actions runs each combination as a parallel job on its own runner.
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx playwright test --shard=${{ matrix.shard }}/4Two things matter in practice. Set `fail-fast: false` or the first failing shard cancels the rest and you lose the full failure picture. And upload per-shard reports as artifacts with a shard-suffixed name, then merge them in a final job (`playwright merge-reports`) so you get one HTML report instead of four. Sharding four ways typically cuts a 20-minute suite to 5–6 minutes; beyond ~8 shards, runner startup overhead starts eating the gain.