mpalmer / action-validator

Tool to validate GitHub Action and Workflow YAML files
GNU General Public License v3.0
271 stars 25 forks source link

Additional property "steps" not allowed on GitHub Action #46

Closed sladesamuel closed 1 year ago

sladesamuel commented 1 year ago

I've setup a reusable GitHub Action that works when running on GitHub and conforms to the GitHub documentation, but fails validation through the use of this tool.

This is the action code:

name: Install Terragrunt
description: Installs the specified Terragrunt version from the cache or internet

inputs:
  version:
    description: "The Terragrunt CLI version to install (expected format: v0.45.0)"
    required: true

runs:
  using: composite
  steps:
    - name: Cache Terragrunt
      uses: actions/cache@v3
      with:
        path: /bin/terragrunt
        key: ${{ runner.os }}-terragrunt-${{ inputs.version }}
        restore-keys: ${{ runner.os }}-terragrunt-${{ inputs.version }}

    - name: Setup Terragrunt ${{ inputs.version }}
      run: |
        sudo wget -q -O /bin/terragrunt "https://github.com/gruntwork-io/terragrunt/releases/download/${{ inputs.version }}/terragrunt_linux_amd64"
        sudo chmod +x /bin/terragrunt
        terragrunt -v

And the validation error:

Treating .github/actions/install-terragrunt/action.yml as an Action definition
Validation failed: ValidationState {
    errors: [
        OneOf {
            path: "/runs",
            states: [
                ValidationState {
                    errors: [
                        Properties {
                            path: "/runs",
                            detail: "Additional property 'steps' is not allowed",
                        },
                        Const {
                            path: "/runs/using",
                        },
Fatal error validating .github/actions/install-terragrunt/action.yml: validation failed
                        Required {
                            path: "/runs/main",
                        },
                    ],
                    missing: [],
                    replacement: None,
                },
                ValidationState {
                    errors: [
                        OneOf {
                            path: "/runs/steps/1",
                            states: [
                                ValidationState {
                                    errors: [
                                        Required {
                                            path: "/runs/steps/1/shell",
                                        },
                                    ],
                                    missing: [],
                                    replacement: None,
                                },
                                ValidationState {
                                    errors: [
                                        Required {
                                            path: "/runs/steps/1/uses",
                                        },
                                    ],
                                    missing: [],
                                    replacement: None,
                                },
                            ],
                        },
                    ],
                    missing: [],
                    replacement: None,
                },
                ValidationState {
                    errors: [
                        Properties {
                            path: "/runs",
                            detail: "Additional property 'steps' is not allowed",
                        },
                        Const {
                            path: "/runs/using",
                        },
                        Required {
                            path: "/runs/image",
                        },
                    ],
                    missing: [],
                    replacement: None,
                },
            ],
        },
    ],
    missing: [],
    replacement: None,
}

From looking into the action validator code, it appears to be trying to match to an externally maintained schema. But this schema appears to follow the GitHub documentation, so I'm not sure why the tool is failing.

I initially tried using tool version 0.1.2 as mentioned through the examples. Using 0.5.1 made no difference to the error.

Any support/direction here would be appreciated. I'm only trialling this tool to see if it's sufficient for use within my projects, but this is a major blocker for me.

mpalmer commented 1 year ago

Innnnnteresting. A solid bug report -- I can confirm I'm seeing the same behaviour when I run locally, but the action doesn't look obviously wrong to me, either. I'll fiddle around and try and figure out what's going on.

mpalmer commented 1 year ago

Ah! Figured it out. Your action didn't have a shell key in the second step ("Setup Terragrunt..."). According to the parameter docs this is, indeed, required ("Required if run is set"), and I have a vague recollection of being bitten by that myself in the dim, dark distant past. The fact that took me a bit of ruminating at the error message is another indication I really need to sit down and figure out how to translate the validation output into something that's human-readable...

If your action is, in fact, running successfully, then the best approach will be to submit a PR on the relevant page, then we can get the schema updated and then pull that into action-validator for great winning.

In the meantime, though, I'll close this off, as it isn't really a bug in action-validator, from the perspective of "we do what the docs say is correct", which is the standard I generally adopt.

sladesamuel commented 1 year ago

Thanks, I'll take a look into this and make the change on my end to check it works as expected

sladesamuel commented 1 year ago

This resolved my issue, thanks!