intermediate
Matrix builds
Run the same workflow across supported Node versions, OS targets, browsers, package managers, or configuration variants.
Matrix builds run the same job across supported combinations: Node versions, operating systems, browsers, database versions, or package managers. They prove compatibility breadth promised to users.
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, windows-latest]
fail-fast: true
Exclude invalid combinations (`include` / `exclude`) to save minutes. Match the matrix to your documented support policy—not every theoretical combo.
On interviews: supported version policy, fail-fast trade-offs, excluding invalid pairs, keeping matrix affordable on every PR.
Common pitfalls: huge matrices slow every PR; testing versions you do not support confuses signal; no shard strategy for browser matrices.
The trade-off is compatibility confidence versus CI minutes and maintenance.
Checklist:
- Match matrix to support policy.
- Exclude irrelevant combinations.
- Use fail-fast deliberately.
- Run full matrix on main or nightly if PR cost is high.