-
Notifications
You must be signed in to change notification settings - Fork 127
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
✨ add a GitHub Action for shellcheck'ing on every PR and push to master branch + shellcheck'ed script #75
Open
thomasmerz
wants to merge
1
commit into
hackerb9:master
Choose a base branch
from
thomasmerz:shellcheck
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Shellcheck Lint | ||
|
||
on: | ||
push: | ||
paths: | ||
# Run workflow on every push | ||
# only if a file within the specified paths has been changed: | ||
- 'lsix' | ||
|
||
pull_request: | ||
paths: | ||
# Run workflow on every push | ||
# only if a file within the specified paths has been changed: | ||
- 'lsix' | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Shellcheck Lint | ||
|
||
# This job runs on Linux | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Required to access files of this repository | ||
- uses: actions/checkout@v4 | ||
|
||
# Download Shellcheck and add it to the workflow path | ||
- name: Download Shellcheck | ||
run: | | ||
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv | ||
chmod +x shellcheck-stable/shellcheck | ||
# Verify that Shellcheck can be executed | ||
- name: Check Shellcheck Version | ||
run: | | ||
shellcheck-stable/shellcheck --version | ||
|
||
# Run Shellcheck on repository | ||
# --- | ||
# https://github.com/koalaman/shellcheck | ||
# --- | ||
# Excluded checks: | ||
# https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/rc.status was... | ||
# https://www.shellcheck.net/wiki/SC1090 -- Can't follow non-constant source. .. | ||
# --- | ||
- name: Run Shellcheck | ||
run: | | ||
set +e | ||
find ./*/ -type f | while read -r sh; do | ||
if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then | ||
echo "shellcheck'ing $sh" | ||
if ! shellcheck-stable/shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$sh"; then | ||
touch some_scripts_have_failed_shellcheck | ||
fi | ||
fi | ||
done | ||
if [ -f ./some_scripts_have_failed_shellcheck ]; then | ||
echo "Shellcheck failed for one or more shellscript(s)" | ||
exit 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oog. That's ugly. lsix is supposed to be a simple script that people can easily hack upon without all the extra cognitive load of these sort of distractions.
How about just adding the GitHub Action so it can run as an advisory linter but leave all these shellcheck comments out of the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are neccessary for
shellcheck
so it won't complain about a specific error or warning in the next line. So for bash-hackers it should not confuse or distract them - but a failingshellcheck
GitHub Action might confuse 🤔I tried to fix this as mentioned/hinted on https://github.com/koalaman/shellcheck/wiki/SC2068 - but then
lsix
failed doing the right thing 😞 So I leftshellcheck
intentionally ignore this because it works/does the right thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment that should help other users understand why these shellcheck-lines are neccessary. And I fixed
(cd "$arg"; $lsix)
to(cd "$arg" && $lsix)
- Do you @hackerb9 agree to that?