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

.github/workflow/reviewdog: Add shellcheck GitHub Action #105641

Closed
wants to merge 1 commit into from

Conversation

lukegb
Copy link
Contributor

@lukegb lukegb commented Dec 2, 2020

There's been some interest in running Shellcheck as part of the review workflow on discrete .sh scripts as a review aid. In particular, this would cover stage-1-init.sh and stage-2-init.sh.

The use of reviewdog here is to parse the output of Shellcheck and, crucially, only report failures on lines modified by the PR author, which allows for this to be introduced now and for Shellcheck lint failures to gradually be driven down over time (or through a separate concerted effort).

This is run in the default github-pr-check mode. If we used the github-pr-review mode instead then Shellcheck's suggestions would be in the form of review comments, but I don't think the tradeoff is worth it (and I don't really like the automatically generated commits that GitHub generates when you accept review comments...).

cc @SuperSandro2000 @grahamc

[WIP, but deliberately not draft so codeowners see it]

@SuperSandro2000
Copy link
Member

Will this mark the check red if there is an error and yellow if there is a warning?

Can we configure shellcheck and exclude things we definitely do not want globally?

@lukegb
Copy link
Contributor Author

lukegb commented Dec 2, 2020

Will this mark the check red if there is an error and yellow if there is a warning?

No, because checks checks are pass/fail/running, not really pass/error/warn.

Can we configure shellcheck and exclude things we definitely do not want globally?

Yes.

@grahamc
Copy link
Member

grahamc commented Dec 2, 2020

Can you add a commit demonstrating where it triggers?

@zowoq
Copy link
Contributor

zowoq commented Dec 2, 2020

How does it handle these errors?

SC1008: This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh. Add a 'shell' directive to specify.

SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

@lukegb
Copy link
Contributor Author

lukegb commented Dec 2, 2020

Can you add a commit demonstrating where it triggers?

I have a test PR: lukegb#1

How does it handle these errors?

SC1008: This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh. Add a 'shell' directive to specify.

SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

At the moment, those are implicitly silenced for review purposes by virtue of being preexisting - if someone edits the shebang line then it'll complain, though.

Copy link
Member

@grahamc grahamc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it!

@SuperSandro2000
Copy link
Member

How do we handle things like https://github.com/lukegb/nixpkgs/pull/1/files#annotation_652947792? This is clearly a false positive and we have lots of those.

@FRidh
Copy link
Member

FRidh commented Dec 2, 2020

How does it handle @variables@ that need to be substituted? It won't error on those?

Seems its the same as @SuperSandro2000 referred to

How do we handle things like https://github.com/lukegb/nixpkgs/pull/1/files#annotation_652947792? This is clearly a false positive and we have lots of those.

@SuperSandro2000
Copy link
Member

How does it handle @variables@ that need to be substituted? It won't error on those?

Seems its the same as @SuperSandro2000 referred to

How do we handle things like lukegb/nixpkgs#1 (files)? This is clearly a false positive and we have lots of those.

Yes I am. This is the big bummer about this PR because we will have a lot of those false positives and writing a comment above every single one of them is not fesable.

@FRidh
Copy link
Member

FRidh commented Dec 3, 2020

If its not possible to instruct it to avoid these substitutions I think we should just stick with or convert to using shellcheck in derivations.

@TredwellGit TredwellGit mentioned this pull request Jan 10, 2021
4 tasks
@Mic92 Mic92 marked this pull request as draft April 20, 2021 20:16
@Mic92 Mic92 changed the title [WIP] .github/workflow/reviewdog: Add shellcheck GitHub Action .github/workflow/reviewdog: Add shellcheck GitHub Action Apr 20, 2021
@stale
Copy link

stale bot commented Oct 22, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 22, 2021
@Mic92
Copy link
Member

Mic92 commented Oct 22, 2021

Not a show stopper but is there a way to only run this ci job if an actually .sh file changed? I have not checked if github provides some support in this direction.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 22, 2021
@stale
Copy link

stale bot commented Apr 25, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 25, 2022
@lukegb lukegb closed this Dec 5, 2022
@lukegb lukegb deleted the shellcheck-ratchet branch December 5, 2022 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants