actionlint icon indicating copy to clipboard operation
actionlint copied to clipboard

Actionlint too strict when checking matrix

Open JavaScriptBach opened this issue 3 years ago • 2 comments

I have a strategy matrix that looks like this:

strategy:
      matrix:
        service: ${{ fromJSON(needs.list-all-services.outputs.services) }}
        exclude:
          - service:
              npm_project: foo

Where services is produced from a previous workflow like this:

echo "::set-output name=services::$(jq -c '' services.json)"

Actionlint gives the following:

value {"npm_project": "foo"} in "exclude" does not exist in matrix "service" combinations. possible values are  [matrix]

I can see why actionlint thinks this code is wrong because it doesn't know what fields are available in services.json, but this code does work on GitHub Actions. Defining the services in a separate JSON file allows me to share it among other config files in my project so I don't have to duplicate lists.

Can we make actionlint allow any types in matrix when it isn't able to detect them?

JavaScriptBach avatar May 25 '22 17:05 JavaScriptBach

Would you provide entire workflow file content so that I can reproduce the error exactly?

rhysd avatar May 27 '22 11:05 rhysd

on:
  workflow_call:
    inputs:
      services:
        required: true
        type: string
        description: contents of services.json

jobs:
  build-lint-test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        service: ${{ fromJSON(inputs.services) }}
        exclude:
          - service:
              npm_project: foo
    steps:
      - run: echo 1

JavaScriptBach avatar May 30 '22 23:05 JavaScriptBach