Skip to content
Latchkey

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: true so they do not trigger the cancel.
  • Set fail-fast: false when 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 test

Gotchas

  • Cancelled siblings report cancelled, which can hide whether they would have passed.
  • fail-fast is a strategy setting; the workflow concurrency block does not affect matrix legs.

Related guides

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