How to Fail Fast to Save CI Minutes
If lint is going to fail, you should not have already paid for a 20-minute test run behind it.
Failing fast means surfacing the cheapest failure first and not wasting minutes on the rest of the pipeline once you know it is doomed.
Cheap checks first
Gate slow jobs behind fast ones with needs:. Lint and typecheck run in seconds and catch a large share of failures before any test job starts.
Keep matrix fail-fast on
The default fail-fast: true cancels remaining matrix legs when one fails, so you do not run 11 more shards after the first breaks.
.github/workflows/ci.yml
strategy:
fail-fast: true
matrix:
node: [18, 20, 22]Know when to disable it
For a release matrix where you want full results across all platforms, set fail-fast: false. For day-to-day PRs, keep it on to save minutes.
Key takeaways
- Run lint/typecheck before slow tests.
- Keep matrix fail-fast on for PRs.
- Disable fail-fast only when you need full matrix results.
Related guides
How to Cancel Superseded CI RunsUse concurrency groups in GitHub Actions to cancel in-progress runs when a newer commit lands, freeing runner…
How to Set Sensible Timeouts in CISet job and step timeouts in GitHub Actions so a hung process fails fast instead of burning the full 6-hour l…
How to Use a Merge Queue to Cut CI LoadUse GitHub merge queue to batch and serialize merges, cutting redundant CI runs and eliminating the broken-ma…
How to Measure and Cut Your CI BillMeasure your GitHub Actions bill by runner OS and workflow, find where minutes go, and cut spend with caching…