GitHub Actions strategy array exclude

One of the powerful uses of YaML with CI systems such as GitHub Actions (GHA) is the ability to setup job matrices. Job matrices allow deduplication of jobs with terse specification, encouraging better test platform and parameter coverage. GHA strategy matrix allows excluding jobs, including via exclusion arrays. An example strategy matrix below excludes shared build on MacOS, due to bugs in third party library on MacOS.

        shared: [true, false]
        img: [
          {os: ubuntu-latest, fc: gfortran},
          {os: macos-latest, fc: gfortran-11}
          - shared: true
            img: {os: macos-latest}

    runs-on: ${{ matrix.img.os }}
      FC: ${{ matrix.img.fc }}

This strategy results in 3 CI jobs:

  • os=ubuntu-latest, shared=true, fc=gfortran
  • os=macos-latest, shared=false, fc=gfortran-11
  • os=ubuntu-latest, shared=false, fc=gfortran