Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter for checking github action yaml syntax #293

Open
mohzulfikar opened this issue Aug 13, 2022 · 9 comments
Open

Linter for checking github action yaml syntax #293

mohzulfikar opened this issue Aug 13, 2022 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@mohzulfikar
Copy link
Contributor

mohzulfikar commented Aug 13, 2022

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
Copy link
Contributor Author

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
Copy link
Member

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

@Bo98 Bo98 added the help wanted Extra attention is needed label Aug 22, 2022
@carlocab
Copy link
Member

actionlint might also be useful for this.

@mohzulfikar
Copy link
Contributor Author

mohzulfikar commented Aug 24, 2022

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
Copy link
Member

carlocab commented Aug 24, 2022

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
Copy link
Contributor Author

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
Copy link
Contributor Author

mohzulfikar commented Sep 5, 2022

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
Copy link

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

@MikeMcQuaid
Copy link
Member

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants