-
Notifications
You must be signed in to change notification settings - Fork 1
feat(shellcheck): introduce shellcheck GH action #64
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fc42c8a
feat(shellcheck): introduce shellcheck GH action
Frzk 86c4164
feat(shellcheck): allow to specify ShellCheck version to use
Frzk 4a8bfdf
feat(shellcheck): update ShellCheck action
Frzk 7eecb42
fix: apply suggestion from Semgrep
Frzk 3d3530e
fix(shellcheck): use Docker Hub image
Frzk 6c9bf02
fix(shellcheck): hardcode Docker image tag
Frzk 32d77e0
feat(shellcheck): use koalaman/shellcheck-alpine Docker image
Frzk f80dabc
feat(shellcheck): use a composite action
Frzk 8419e68
fix(shellcheck): use environment var
Frzk ce22360
fix(shellcheck): move env in run block
Frzk 31f8e5b
fix(shellcheck): add example for 'inputs.files'
Frzk 29fdfb7
chore(shellcheck): move script in its own file
Frzk 529e737
fix(shellcheck): remove erroneous instruction from script
Frzk 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 hidden or 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,56 @@ | ||
| --- | ||
| name: ShellCheck GitHub Action | ||
| description: | | ||
| Execute ShellCheck in a GitHub Action. | ||
|
|
||
| inputs: | ||
| shellcheck-version: | ||
| description: | | ||
| ShellCheck version to use. This should match a Docker Hub tag. | ||
| See https://hub.docker.com/r/koalaman/shellcheck/tags for a list of | ||
| available tags. | ||
| required: false | ||
| default: "v0.11.0" | ||
|
|
||
| shellcheck-severity: | ||
| description: | | ||
| ShellCheck severity to use. | ||
| One of 'error', 'warning', 'info', or 'style'. | ||
| required: false | ||
| default: style | ||
|
|
||
| files: | ||
| description: | | ||
| List of files to scan. | ||
| When unset, defaults to recursively scanning all .sh files in the repo. | ||
| Use the following syntax to specify a list of files: | ||
|
|
||
| with: | ||
| files: | | ||
| first.sh | ||
| second file.sh | ||
| third file | ||
|
|
||
| required: false | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Run ShellCheck | ||
| shell: bash | ||
| env: | ||
| FILES: ${{ inputs.files }} | ||
| SEVERITY: ${{ inputs.shellcheck-severity }} | ||
| VERSION: ${{ inputs.shellcheck-version }} | ||
| run: | | ||
| docker run --rm \ | ||
| --env FILES \ | ||
| --env SEVERITY \ | ||
| --volume "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:ro" \ | ||
| --volume "${GITHUB_ACTION_PATH}:${GITHUB_ACTION_PATH}:ro" \ | ||
| --workdir "${GITHUB_WORKSPACE}" \ | ||
| koalaman/shellcheck-alpine:${VERSION} \ | ||
| /bin/sh "${GITHUB_ACTION_PATH}/scripts/run-shellcheck.sh" | ||
This file contains hidden or 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,25 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| if [ -n "${FILES}" ]; then | ||
| # Reset argv ($@): | ||
| set -- | ||
|
|
||
| # Fill argv with the files provided. Keeps spaces. | ||
| while IFS= read -r file; do | ||
| [ -n "${file}" ] && set -- "$@" "${file}" | ||
| done <<-EOF | ||
| ${FILES} | ||
| EOF | ||
|
|
||
| # Run ShellCheck | ||
| shellcheck -S "${SEVERITY}" -s bash "$@" | ||
| else | ||
| # Default behavior | ||
| # Finds all .sh files and pass them to ShellCheck. | ||
| # Ignores those in the `.git` directory. | ||
| find . -type f -name '*.sh' -not -path './.git/*' \ | ||
| -exec shellcheck -S "${SEVERITY}" -s bash {} + | ||
| fi |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.