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

Introduce shellcheck to lint shell scripts #15169

Merged
merged 18 commits into from
Feb 22, 2025

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Nov 6, 2024

@@ -0,0 +1,29 @@
on:
push:
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth defining paths here. Supposedly this check could then run very rarely, only when needed
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore

Copy link
Member Author

@straight-shoota straight-shoota Nov 8, 2024

Choose a reason for hiding this comment

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

Yeah, I was wondering about that as well. A bit of an obstacle is that there's no simple glob to catch all shell script. Some like bin/crystal have no extension. The GitHub action actually checks all files for a matching shebang.
Limiting paths would need to hard code all paths that don't identify as shell script by their extension. That means the check could miss out on new ones being added.
I suppose this is an acceptable limitation, though. I wouldn't expect too much movement in that regard.

On the other hand, this job finishes reallly quickly - especially compared to our other workflows - in just 7s so it's not too much overhead to run it on every commit.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it's a fair point. Not a good tradeoff then

Copy link
Member Author

@straight-shoota straight-shoota Nov 8, 2024

Choose a reason for hiding this comment

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

I'm actually not so sure. Either way seems quite fine. So maybe we can hear some other's comments on this.

It's also relevant to note that the discovery feature depends on the GitHub action and another comment is suggesting we might do without the action. Droping automatic path discovery would make that easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

I inspected the repository and found the following scripts which cannot be identified by typical shell extensions in the file name:

$ find . -type f ! -path './.git/*' -exec file {} + | awk -F: '/shell script/{print $1}' | grep -v \.sh
./src/llvm/ext/find-llvm-config
./scripts/git/pre-commit
./bin/crystal
./bin/ci
./bin/check-compiler-flag

That shouldn't be difficult to hardcode. And maybe we could even rename some to include an extension (find-llvm-config.sh for example; it's only an internal tool anyway).
In case we add a new script without an extension, the risk of missing to add it here it's acceptable.

@oprypin
Copy link
Member

oprypin commented Nov 8, 2024

It will be nice to have this 🙂

@straight-shoota straight-shoota added this to the 1.16.0 milestone Feb 20, 2025
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.

3 participants