Test on several versions with a matrix

DevOps, Hands On20 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll run the same tests on several language versions and operating systems at once.

A matrix turns one job into many: list the values (Python 3.12, 3.13 and 3.14; Ubuntu and Windows) and GitHub runs every combination side by side. include adds a single extra combination or setting, and exclude removes ones you don't support.

By default fail-fast cancels the rest when one combination fails, which saves minutes but hides whether the problem is everywhere or only on one version. Turn it off while you're investigating. max-parallel limits how many run at once.

Example. Fernhill Cloud's shared Python library is used by teams on three Python versions. A matrix of three versions on Ubuntu, plus one Windows job, found a path bug that only appeared on Windows before any team upgraded.

Before you start

You need: A free GitHub account and a public test repository (Actions minutes are free for public repositories). Time: 20 minutes.

Where to look

  1. Repository
  2. .github/workflows/matrix.yml
  3. Actions tab

Steps

  1. In the test repository, add .github/workflows/matrix.yml from Commands.
  2. Push and open the run. Count the jobs: 3 versions on Ubuntu plus the one Windows job added by include.
  3. Make the test fail only on Windows (for example, assert that os.sep == '/'), with fail-fast left on, and see the other jobs cancelled.
  4. Set fail-fast: false, push again, and see every Linux job pass and only Windows fail.Now the result tells you where the problem is.
  5. Remove the Windows-only failure.

Commands

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        python: ['3.12', '3.13', '3.14']
        include:
          - os: windows-latest
            python: '3.13'
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with: { python-version: '${{ matrix.python }}' }
      - run: pip install -r requirements-dev.txt
      - run: pytest -q

Watch out for

Cost
Free in public repositories. In private ones, Windows minutes count double and macOS ten times, so add them only where they find real bugs.
Security
Matrix values from a workflow file are safe; never build a matrix from pull request text.
Common mistakes
A huge matrix on every push; run the full matrix nightly and a small one on pull requests.

Clean up

Delete matrix.yml when you've finished, or keep it for the final project.

Words to know

Matrix
A list of values that turns one job definition into several jobs.
include
Adds an extra combination, or extra values to existing ones.
exclude
Removes combinations from the matrix.
fail-fast
Cancels the other matrix jobs when one fails (on by default).

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going