Homebrew / actions

🚀 Homebrew's GitHub Actions
BSD 2-Clause "Simplified" License
118 stars 39 forks source link

Linter for checking github action yaml syntax #293

Open mohzulfikar opened 2 years ago

mohzulfikar commented 2 years ago

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 commented 2 years ago

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.

carlocab commented 2 years ago

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

carlocab commented 2 years ago

actionlint might also be useful for this.

mohzulfikar commented 2 years ago

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.

carlocab commented 2 years ago

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.

mohzulfikar commented 2 years ago

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 commented 2 years ago

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.

ryantimjohn commented 1 year ago

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

MikeMcQuaid commented 11 months ago

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