Skip to content
Latchkey

How to Run Playwright Sharded Across Runners in GitHub Actions

A serial Playwright suite is the long pole in CI; sharding fans it out across runners that each take a slice.

Use --shard=N/M with a matrix over the shard index so each runner executes a disjoint slice of the suite in parallel.

Steps

  • Add a matrix over shard: [1, 2, 3, 4].
  • Pass --shard=${{ matrix.shard }}/4 to playwright test.
  • Upload the blob report from each shard as an artifact.
  • Merge the reports in a follow-up job (see the related guide).

Workflow

.github/workflows/e2e.yml
name: E2E
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test --shard=${{ matrix.shard }}/4
      - uses: actions/upload-artifact@v4
        with:
          name: blob-report-${{ matrix.shard }}
          path: blob-report/

Notes

  • Set fail-fast: false so one slow shard does not cancel the others.
  • On Latchkey managed runners these parallel shards spin up cheaper and self-heal a dropped shard.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →