Skip to content
Latchkey

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

Run this faster and cheaper on Latchkey managed runners. Start free →