A matrix of 40 jobs is eating minutes. How do you control cost?
IntermediateScenarioGitHub Actions
Answer
Situation read → Over-broad matrix.
What I'd do →
- Run the full matrix only on
mainand nightly; on PRs run one representative combination usingifor dynamic matrix from a previous job. - Use
strategy.fail-fast: trueandmax-parallelwhere useful. - Use
exclude, path filters and caching, and cancel redundant runs withconcurrency.
Why → Most regressions are caught by a small set; the rest can be post-merge.
Interview tip → Cost is a CI design constraint.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate