Interview Prep/GitHub Actions/Speed, Caching & Cost

Test suite takes 30 minutes on one runner. How do you parallelize it in Actions?

IntermediateScenarioSpeed, Caching & Cost
Answer

Situation read → Sharding across matrix legs.

What I'd do →

  1. Split into shards:
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4, 5, 6]
    steps:
      - run: npx jest --shard=${{ matrix.shard }}/${{ strategy.job-total }}
    
  2. Upload per-shard results (junit-${{ matrix.shard }}) and merge in a fan-in job.
  3. Balance shards by timing data if the tool supports it.

Why → Wall-clock drops roughly 5x; billed minutes rise slightly due to per-job overhead.

Interview tip → Be honest that sharding trades minutes for developer time.

All GitHub Actions questions Roadmap: GitHub Actions

More on Speed, Caching & Cost