[GitHub Actions (new)] [BUG] Unable to create environment variables based matrix

Here’s what I’m trying:

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version:
        - 3.7
        os:
        - ubuntu-18.04
        env:
        - TOXENV: python,check-docs,build-docs
- TOXENV: build-dists,pre-commit-ci

I want to generate a number of jobs from matrix also taking into account the specified env vars. Just like Travis CI does:

Anything I’m missing?

1 Like

Hi @webknjaz, thanks for being here! Did you give this workflow a go? Are you having any problems?

Hi @andreagriffiths11, I tried it and it doesn’t create jobs with different env var values from the matrix.

Workaround is to explicitly apply the env factor on a job level:

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version:
        - 3.7
        os:
        - ubuntu-18.04
        env:
        - TOXENV: python,check-docs,build-docs
- TOXENV: build-dists,pre-commit-ci
steps:
- ...
- run: |
some-command --with-access-to=env
env: ${{matrix.env }}
1 Like

@webknjaz, what about this mechanism ? https://docs.travis-ci.com/user/environment-variables/#defining-multiple-variables-per-item

That’s essentially the same except that with GH Actions you have to expose vars to each job explicitly.

I just checked and it turns out that you can use env: on the job level too now: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idenv

@webknjaz Could you provide an example as i have tried and failed as actions does not support multiple env variables.

I would like each job to receive multiple variables like

FOO=bar BAR=foo

@webknjaz Sorry figured it out:

  • {FOO: bar, BAR=foo}

The actions editor on github tripped me up with the error “only primitive types are allowed for”.