Matrix Strategy
ELI5 — The Vibe Check
Matrix Strategy is CI/CD's way of testing every combo without writing every combo. Test on Node 18, 20, and 22? On Ubuntu and macOS? Matrix makes a grid and runs ALL combinations in parallel. It's like ordering every pizza topping combination without having to list them all.
Real Talk
Matrix strategy in GitHub Actions generates multiple job runs from a set of variable combinations. Each combination runs as a separate job in parallel. Supports include/exclude rules for fine-grained control and fail-fast behavior to cancel remaining jobs on first failure.
Show Me The Code
jobs:
test:
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, macos-latest]
exclude:
- node: 18
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
When You'll Hear This
"Our matrix tests across 3 Node versions and 2 OS variants." / "Matrix strategy caught that our code breaks on Node 18 but works on 20."
Related Terms
Continuous Integration
Imagine a group project where everyone keeps adding their piece to a shared Google Doc and a robot instantly proofreads the whole thing every single time.
GitHub Actions
GitHub Actions is CI/CD built right into GitHub. Push code, run tests, deploy — all from YAML files in your repo. No separate CI server needed.
Job Dependencies
Job Dependencies tell GitHub Actions 'don't start job B until job A finishes.' Build before test. Test before deploy.