How to Cancel Redundant Matrix Legs in GitHub Actions
strategy.fail-fast (the default) cancels the other matrix legs the moment one leg fails.
Matrix cancellation is controlled by strategy.fail-fast, not the concurrency block. Leave it true to cancel siblings on the first failure, or set it false to let every leg finish.
Steps
- Keep
strategy.fail-fast: true(default) to cancel siblings on first failure. - Mark known-flaky legs
continue-on-error: trueso they do not trigger the cancel. - Set
fail-fast: falsewhen you need every result.
Workflow
.github/workflows/ci.yml
jobs:
test:
strategy:
fail-fast: true
matrix:
node: [18, 20, 22]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm ci && npm testGotchas
- Cancelled siblings report
cancelled, which can hide whether they would have passed. - fail-fast is a strategy setting; the workflow
concurrencyblock does not affect matrix legs.
Related guides
How to Choose Between Concurrency and max-parallel in GitHub ActionsUnderstand the difference between GitHub Actions concurrency, which serializes runs by group, and strategy.ma…
How to Cancel In-Progress Runs on a New Push in GitHub ActionsCancel an in-progress GitHub Actions run when a newer commit is pushed to the same ref by pairing a concurren…