act icon indicating copy to clipboard operation
act copied to clipboard

Enhancement: Fail if env variable is used in strategy of a job

Open pdecat opened this issue 3 years ago • 4 comments

Describe feature

The following configuration works in act:

name: Python package

on: [push, pull_request]

env:
  target_python_version: 3.8

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 5
      matrix:
        python-version: [3.7, "${{env.target_python_version}}"]

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox tox-gh-actions
    - name: Test with tox
      run: tox

but fails in Github Actions:

.github/workflows/main.yml#L14The workflow is not valid. .github/workflows/main.yml (Line: 14, Col: 31): Unrecognized named-value: 'env'. Located at position 1 within expression: env.target_python_version

Sadly, this is not supported:

  • https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#env
  • https://github.com/actions/runner/issues/480
  • https://github.community/t/env-vars-are-not-expanded-causing-dry-violations/16550
  • https://github.community/t/how-to-use-env-context/16975/2
  • https://github.com/fbradyirl/openwrt-luci-rpc/pull/47

pdecat avatar Mar 20 '21 08:03 pdecat

Issue is stale and will be closed in 14 days unless there is new activity

github-actions[bot] avatar Apr 20 '21 00:04 github-actions[bot]

I am very new to act and github actions, so my assumption that my issue is related might be wrong. I am seeing at least the same error, if I try to skip an entire workflow locally. https://github.com/zbMATHOpen/linksApi/blob/master/.github/workflows/codeql-analysis.yml#L27 I wonder if the is a different method people use to determine if the job is executed on github or locally.

physikerwelt avatar May 18 '21 20:05 physikerwelt

@physikerwelt you don't use environment variables in matrix so it's definitely not the same issue

catthehacker avatar May 18 '21 20:05 catthehacker

Check out https://github.com/rhysd/actionlint to lint your workflow files.

ZauberNerd avatar Feb 01 '22 18:02 ZauberNerd