[GitHub Actions] Matrix options dont work as documented

name: CI

on: [check_run]

jobs:
  UWPPR:
    name: UWP PR

    runs-on: windows-2016

    strategy:
      matrix:
        include:
        - BuildConfiguration: Debug
          BuildPlatform: x64
          UseRNFork: true
        - BuildConfiguration: Debug
          BuildPlatform: x86
          UseRNFork: true
        - BuildConfiguration: Debug
          BuildPlatform: arm
          UseRNFork: true
        - BuildConfiguration: Release
          BuildPlatform: x64
          UseRNFork: true
        - BuildConfiguration: Release
          BuildPlatform: x86
          UseRNFork: true
        - BuildConfiguration: Release
          BuildPlatform: arm
          UseRNFork: true
        - BuildConfiguration: Debug
          BuildPlatform: x86
          UseRNFork: false

    steps:
    - uses: actions/checkout@v1

    - name: Dump GitHub context
      env:
        GITHUB_CONTEXT: ${{ toJson(github) }}
      run: echo "$GITHUB_CONTEXT"
    - name: Dump strategy context
      env:
        STRATEGY_CONTEXT: ${{ toJson(strategy) }}
      run: echo "$STRATEGY_CONTEXT"
    - name: Dump matrix context
      env:
        MATRIX_CONTEXT: ${{ toJson(matrix) }}
      run: echo "$MATRIX_CONTEXT"
    - name: Dump job context
      env:
        JOB_CONTEXT: ${{ toJson(job) }}
      run: echo "$JOB_CONTEXT"
    - name: Dump runner context
      env:
        RUNNER_CONTEXT: ${{ toJson(runner) }}
      run: echo "$RUNNER_CONTEXT"
    - name: Dump steps context
      env:
        STEPS_CONTEXT: ${{ toJson(steps) }}
      run: echo "$STEPS_CONTEXT"

This results in the following error:

- Your workflow file was invalid: .github/workflows/pr.yml (Line: 13, Col: 9): Matrix must defined at least one vector

https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

The above docs show that you can use matrix by manually specifying the exact combinations you want, but the error seems to want a vector to be define.

8 Likes

GitHub Actions is currently still in beta and things are changing quickly. New features and fixes are being released for it constantly and the documentation is lagging behind a little bit. Our apologies for the inaccuracy in the documentation. I’ve passed along your feedback to the team.

Thanks for letting us know!

3 Likes

Have you found any fix for this? I’m currently running into this but I would really like to use this feature.

I ended up using vectors for the matrix options, and then duplicating the whole job to do some extra slices, since I couldn’t get various combinations of include/exclude to do what I wanted.

Thanks! Is there any way for us to track the issue? It’s a bit more than just a documentation problem as the matrix stuff seems to be generally broken right now. I would just like to know once the issue is resolved so that I can re-activate my builds.

I’m facing the same issue. I’d love to beta test the rest of Github Action’s new features but I cannot set up a complete workflow until I can specify my matrix using only include statements.

I kind of found a workaround for this bug. See here: https://github.com/svenstaro/proxyboi/blob/master/.github/workflows/publish.yml

2 Likes

The current API use of include: differs from other CI systems in that in those systems, with a 2 x 3 matrix and one include:, one would have 7 jobs.

Currently, Actions include: allows one to modify jobs already defined by the matrix.

Hence. maybe add another option, possibly 'additional-jobs:`, that would allow one to defiine a new job by specifying all the vectors of the current matrix, along with additional data?

An example based, on CI on Travis, is a Ruby matrix, where jobs defined based on Ruby version.  Additionally, there is an added Ruby 2.6.x job that runs with --jit enabled.  This can’t be done without something like 'addition-jobs:`…

With reproc, I currently get around this issue by adding an arbitrary name row to the matrix which I then match against in include:

matrix:
  # Github Actions requires a single row to be added to the build matrix.
  # See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
  name: [
    ubuntu-18.04-gcc-4.8,
    ubuntu-18.04-gcc-9,
    ubuntu-18.04-clang-4.0,
    ...
  ]

  include:
    - name: ubuntu-18.04-gcc-4.8
      os: ubuntu-18.04
      compiler: gcc
      version: "6"

    - name: ubuntu-18.04-gcc-9
      os: ubuntu-18.04
      compiler: gcc
      version: "9"

    - name: ubuntu-18.04-clang-4.0
      os: ubuntu-18.04
      compiler: clang
      version: "6.0"

...

Ideally, I would be able to do the following instead:

matrix:
  - os: ubuntu-18.04
    compiler: gcc
    version: "6"

  - os: ubuntu-18.04
    compiler: gcc
    version: "9"

  - os: ubuntu-18.04
    compiler: clang
    version: "6.0"

...
10 Likes