Skip to content
Latchkey

GitHub Actions Workflow for Matrix Across Node Versions

Test against several Node.js versions at once.

This workflow fans out a matrix across Node LTS versions so you catch version-specific failures before release.

The workflow

.github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node: [18, 20, 22]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: ${{ matrix.node }}, cache: npm }
      - run: npm ci
      - run: npm test

Notes

  • Matrix runs install and test once per Node version.
  • fail-fast: false lets every version report so you see all failures.
  • Add os to the matrix to also span platforms.

Run it cheaper

Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.

Related guides

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