Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive object, array, and null values should not be evaluated in template with ${{ }} with lists in matrix #77

Closed
nantiferov opened this issue Nov 23, 2021 · 2 comments
Labels
question Further information is requested

Comments

@nantiferov
Copy link

Hi,

I think I might found a bug related to feature added in v1.6.2, actionlint now checks evaluated values at ${{ }} are not an object nor an array since they are not useful

Example below produces this error, however it's a valid workflow and recommended for self-hosted runners (multiple tags to select runner).
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-7

Link to playground

Error message:
object, array, and null values should not be evaluated in template with ${{ }} but evaluating the value of type array<string> [expression]

Example:

name: test
on: [push]
jobs:
  test:
    runs-on: ${{ matrix.runner }}
    strategy:
      matrix:
       include:
         - runner: 
           - arm64
           - linux
         - runner:  
            - x64
            - linux
    steps:
      - name: Echo details
        env:
          RUNNER: ${{ matrix.runner }}
        run: echo $RUNNER

I tried to change it to ${{ toJSON(matrix.runner) }}, actionlint passes after that, but workflow is broken after that.

@rhysd rhysd added the bug Something isn't working label Nov 23, 2021
@dekimsey
Copy link

I ran into this with another variation of this is that is also supported behavior by GHA:

jobs:
  build:
    strategy:
      matrix:
        include:
          - { runner: [os=macos, x64]}
          - { runner: [os=macos-arm, arm64]}
      fail-fast: false
    runs-on: [self-hosted, "${{matrix.runner}}"]
    steps:
      ...

@rhysd
Copy link
Owner

rhysd commented Nov 18, 2024

actionlint looks correct to me. matrix.runner is an array, not a string. So it cannot be embedded with ${{ }}. You need to put each elements

- run: echo ${{ matrix.runner[0] }} ${{ matrix.runner[1] }}

or serialize it to JSON string

- run: echo ${{ toJSON(matrix.runner) }}

@rhysd rhysd closed this as completed Nov 18, 2024
@rhysd rhysd added question Further information is requested and removed bug Something isn't working labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants