Your PR matrix is 3 OS times 4 versions (12 jobs). How do you cut cost without losing coverage?
AdvancedScenarioSpeed, Caching & Cost
Answer
Situation read → Full coverage is needed before release, not on every PR push.
What I'd do →
- Build the matrix dynamically: on
pull_request, Linux with the latest and oldest supported versions; onpushtomainand nightly, the full matrix.matrix: ${{ fromJSON(github.event_name == 'pull_request' && '{"os":["ubuntu-24.04"],"node":[20,24]}' || '{"os":["ubuntu-24.04","windows-2025","macos-15"],"node":[20,22,24]}') }} - Keep the fan-in check stable regardless of matrix size.
Why → Most regressions surface on one OS and the version extremes.
Interview tip → Show the fromJSON ternary trick; it proves fluency with expressions.
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?BeginnerTest suite takes 30 minutes on one runner. How do you parallelize it in Actions?Intermediate