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 →
- 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 }} - Upload per-shard results (
junit-${{ matrix.shard }}) and merge in a fan-in job. - 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.
More on Speed, Caching & Cost
`npm ci` takes 4 minutes on every run. Fix it.BeginnerDocker builds take 12 minutes even when only one line of code changed. Speed them up.IntermediateThe repo hits the 10 GB cache limit daily and hit rates are poor. What do you change?IntermediatemacOS jobs are 60% of your bill. What are your options?IntermediateA job sometimes hangs and burns 6 hours. How do you stop it happening again?BeginnerYour PR matrix is 3 OS times 4 versions (12 jobs). How do you cut cost without losing coverage?Advanced