actions icon indicating copy to clipboard operation
actions copied to clipboard

Linter for checking github action yaml syntax

Open mohzulfikar opened this issue 2 years ago • 9 comments

When I first contributed to this repository, It seems like there was no lint check for the action syntax on this repository as you can see on this PR. When a new contributor submits a PR about modifying action YAML they could write some typos that could make an error in the syntax.

Would it be great if we add a lint check to every action YAML or the modified one so that we could focus more on the code or modified part? Any suggestion about this?

mohzulfikar avatar Aug 13 '22 15:08 mohzulfikar

Some additional notes when I do some research about this.

Because we want the linter to check Github action syntax, a simple YAML linter just doesn't work, we need to get the linter that could lint a YAML that has custom rules or syntax in it. One example is v8r which could accept a JSON schema defining the custom rule of the YAML. We could also use the schema that's already available on schema store.

mohzulfikar avatar Aug 13 '22 15:08 mohzulfikar

I like the idea of catching syntax errors in our workflows automatically.

carlocab avatar Aug 13 '22 17:08 carlocab

actionlint might also be useful for this.

carlocab avatar Aug 24 '22 13:08 carlocab

My current solution is to use v8r. I just see the tools, yes seems like we could also use that. Might need some time to compare the linter output and which ones are the best.

mohzulfikar avatar Aug 24 '22 14:08 mohzulfikar

We'll probably want a v8r formula first, though, unless there's already a GitHub action that bundles it or something like that. But we probably want something that can be run as part of brew audit and/or brew style.

carlocab avatar Aug 24 '22 14:08 carlocab

I see the point, v8r is already part of megalinter. But, because we only need to check the GitHub action syntax, it'll be more worth trying the one tool that specializes in this and has a formula on homebrew like actionlint.

mohzulfikar avatar Aug 28 '22 13:08 mohzulfikar

actionlint might also be useful for this.

I've tested the actionlint, from this issue, it looks like composite action linting is not supported yet by actionlint.

mohzulfikar avatar Sep 05 '22 17:09 mohzulfikar

Seems like there's an actionlint action built in reviewdog: https://github.com/reviewdog/action-actionlint

ryantimjohn avatar Feb 24 '23 15:02 ryantimjohn

I think the best that can be done here for now is:

  • use actionlint for as much as possible
  • use yamllint for everything (else)

MikeMcQuaid avatar Oct 06 '23 15:10 MikeMcQuaid