How to Refine a Cross-Platform Matrix With include and exclude
exclude removes combinations from the full cross-product; include adds extra cells or attaches keys to a specific combination.
A cross-platform matrix rarely needs every cell. Use exclude to prune combinations that do not apply, and include to add a one-off leg or extend a single cell.
Steps
- List base
osand version dimensions. - Add
exclude:for pairs you do not support (for example old Node on Windows). - Add
include:to append a special leg or attach an extra flag.
Workflow
.github/workflows/ci.yml
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20]
exclude:
- os: windows-latest
node: 18
include:
- os: ubuntu-latest
node: 22
experimental: trueGotchas
excludeis applied first, thenincludeadds cells back on top.- An
includeentry whose keys match an existing cell extends that cell instead of creating a new job.
Related guides
How to Matrix Across OS and Language Version TogetherCombine an os dimension with a language version dimension in a GitHub Actions matrix so every OS is tested ag…
How to Keep Every Platform Running With fail-fast: falseStop one failing OS from cancelling the rest of a cross-platform GitHub Actions matrix by setting strategy.fa…