Interview Prep/GitHub Actions/Speed, Caching & Cost

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 →

  1. Build the matrix dynamically: on pull_request, Linux with the latest and oldest supported versions; on push to main and 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]}') }}
    
  2. 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.

All GitHub Actions questions Roadmap: GitHub Actions

More on Speed, Caching & Cost