Configuration Matrix Construction
This document introduces how to achieve parallel builds and tests across multiple operating systems, language versions, and architectures using strategy.matrix.
When you need to execute tests or builds in parallel across multiple combinations of operating systems, language versions, and architectures.
Prerequisites
- The dimensions to be tested (OS, language version, architecture, etc.) have been identified.
- The Runner tags can cover the required running environments.
Quick Example
name: matrix-test
on:
push:
branches:
- main
jobs:
test:
name: Test
runs-on: ['${{ matrix.os }}','${{ matrix.arch }}',small]
strategy:
matrix:
os: [ubuntu-latest, euler-latest]
arch: [x64]
node-version: [18, 20]
exclude:
- os: euler-latest
node-version: 18
fail-fast: false
max-parallel: 4
steps:
- name: Checkout source code
uses: checkout
- name: setup node
uses: setup-node
with:
node-version: ${{ matrix.node-version }}
- name: Run ci
run: npm ci
- name
run: npm test