mpalmer / action-validator

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

Anchors aren't allowed in workflow definitions #7

Closed iainlane closed 1 year ago

iainlane commented 2 years ago

My workflow had some parameters like this:

          issue-ignore-any-labels: &exemptLabels |
            pinned
            security
            type/security
            keepalive
          pull-request-ignore-any-labels: *exemptLabels

GitHub sadly rejects this, because it isn't using full YAML. (See here)

But action-validator accepts this action:

laney@melton(:a0e851fcf4|…)> action-validator --verbose .github/workflows/stale.yml
Treating .github/workflows/stale.yml as a Workflow definition
laney@melton(:a0e851fcf4|…)> echo $?
0

probably a tough one, as this isn't about the schema but not accepting conformant YAML!

mpalmer commented 2 years ago

Oh, yeah, I've been bitten by this one as well. Have to duplicate long lists of include/exclude paths in all my action triggers, very tedious.

As you say, this is likely to be a tough one, as I wouldn't be surprised if by the time the YAML is finished being parsed, the anchors have been dereferenced and there's no indication that there ever was an anchor.

mpalmer commented 1 year ago

I've taken a brief look at this issue today, and it looks like, indeed, that anchors do indeed get dereferenced inside the YAML parser, so action-validator can't tell there ever was an anchor, and there's no way to ask the YAML parser to not support anchors (because to do that is bonkers, obvs). I surfaced this issue which appears to the canonical place to whinge about a lack of support for anchors, and has some backstory as to why they're not supported, a very half-hearted commitment over a year ago from someone at GitHub to do something about it, and some possible workarounds. In the meantime, I'm just going to have to close this issue as "practically impossible to support", sadly.