Pipelines
Run a job for several versions (matrix)
Run one job once for each combination of values, such as Go versions and databases.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
# .branchd/pipelines/ci.yaml
# Test on two Go versions and two databases: four jobs. The include entry
# adds race: true to the cell it agrees with, (1.26, mysql:8).
name: CI
on: [push, pull_request]
jobs:
test:
matrix:
go: ['1.25', '1.26']
db: ['mysql:8', 'mariadb:11']
include:
- {go: '1.26', db: 'mysql:8', race: true}
image: golang:${{ matrix.go }}
services:
db:
image: ${{ matrix.db }}
env: {MYSQL_ROOT_PASSWORD: test, MARIADB_ROOT_PASSWORD: test}
env:
RACE: ${{ matrix.race }}
steps:
- run: go test ${RACE:+-race} ./...
report:
# Waits for every cell of test.
needs: [test]
image: alpine:3
steps:
- run: echo "all cells passed"
- Cells.
matrix:maps keys to lists. The job runs once for each combination: heretest (1.25, mysql:8),test (1.25, mariadb:11),test (1.26, mysql:8)andtest (1.26, mariadb:11). Each is a check of its own, such asCI / test (1.26, mysql:8). ${{ matrix.<key> }}reads a cell's value, inimage:,services:,env:,run:andif:. Each cell'sif:is decided on its own.includeentries join every cell whose values they agree with, adding their other keys:race: truelands on the(1.26, mysql:8)cell. An entry that agrees with no cell is a cell of its own. In other cellsmatrix.raceis empty, so${RACE:+-race}adds nothing.excludeentries remove the cells they match.needs: [test]waits for every cell that runs.- A failed cell stops the others, as on GitHub: once a cell fails (after
its retries), the cells that have not started never start, and running
cells are cancelled. Jobs that need a cancelled cell are skipped, unless
they run whatever happened (
if: always()). Writefail-fast: falseto let every cell run to its end. - A matrix job has no
outputs:.
Limits: at most 256 cells; the product of the lists may be up to 1,024
before exclude removes cells.