Sikau

GitHub Actions · Day 8 · about 30 min

Matrix builds

Test several Node versions at once with strategy.matrix.

Works on every version

Your users run Node 18, 20 and 22. A matrix runs the same job once per combination — in parallel on GitHub — so you know it works everywhere.

strategy.matrix

name: Matrix
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node: [18, 20, 22]
        include:
          - node: 22
            experimental: true
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
      - run: npm ci
      - run: npm test
      - if: matrix.experimental
        run: echo "Extra checks on the newest Node"

The rest of this lesson

  • Two-dimensional matricesexplain
  • When to use a matrixexplain
  • How many jobs?predict
  • Counting combinationspredict
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 12 lessons of GitHub Actions