For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt, and this page is available as Markdown at https://docs.hod.sh/pipelines/matrix.md.

Matrix

A job with matrix: runs once per combination of values. The compiler expands it into one job per instance, named after its values: test (linux, 1.22).

version: 0
on: [push]
jobs:
  test:
    matrix:
      - os: [linux, macos]
        go: ["1.22", "1.23"]
      - os: windows
        go: "1.23"
    fail_fast: true
    max_parallel: 2
    runs-on: ["${{ matrix.os }}"]
    image: golang:${{ matrix.go }}
    steps:
      - run: go test ./...
  • matrix: is a map from keys to lists of values, or a list of such maps. Each map expands into every combination of its values, the first key outermost, and the instances are all of them, in order. A single value needs no list. There's no include or exclude: an instance that differs is another entry of the list.
  • Values are strings as written: 1.20 stays "1.20".
  • matrix.<key> is a CEL string anywhere in the job: image, runs-on, env, if, services and steps. A key that only some entries set can't be read.
  • fail_fast: true cancels the other instances when one fails, and max_parallel runs at most that many at once.
  • needs: [test] waits for every instance and gets all their files. jobs.test.result reads the matrix as one: failure if any instance failed, else cancelled if any was cancelled, else skipped if all were skipped, else success.
  • At most 256 instances per job, and 512 jobs per pipeline once expanded.