-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: squash: switch back to reusable workflow
- Loading branch information
1 parent
76a820c
commit baa8e06
Showing
2 changed files
with
83 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,83 @@ | ||
# This is a reusable workflow for running ShellCheck, | ||
# a linter for shell scripts (https://shellcheck.net). | ||
|
||
# For more context, see: | ||
# https://github.com/openedx/.github/blob/master/docs/decisions/0001-shellcheck.rst | ||
|
||
name: ShellCheck | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
|
||
root-dirs: | ||
type: string | ||
required: true | ||
description: | | ||
Directories to search for .sh files, space-separated, each relative | ||
to the root of the repository. Directories containing spaces or other | ||
Bash delimiters must be wrapped in single quotes. | ||
shellcheck-version: | ||
type: string | ||
required: false | ||
default: "v0.9.0" | ||
description: | ||
ShellCheck version to install. | ||
Must be a tag or branch of https://github.com/koalaman/shellcheck. | ||
By default, the upstream action will use a reasonable, stable shellcheck version, | ||
which will be updated over time as new stable ShellCheck versions come out. | ||
If you want your repositoriy's build to be totally deterministic, though, then | ||
override with a specific version pin here, and manage updates ShellCheck yourself. | ||
|
||
# OPTIONAL: | ||
shellcheck-options: | ||
type: string | ||
required: false | ||
default: "" | ||
description: | | ||
Command-line options to forward to shellcheck. | ||
For details of available options, run "shellcheck --help." | ||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Download & unpack ShellCheck | ||
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${{ inputs.shellcheck-version }}/shellcheck-${{ inputs.shellcheck-version }}.linux.x86_64.tar.xz" | tar -xJ | ||
|
||
- name: Install ShellCheck | ||
run: sudo cp "shellcheck-${{ inputs.shellcheck-version }}/shellcheck" /usr/bin | ||
|
||
- name: Show ShellCheck version | ||
run: shellcheck -V | ||
|
||
- name: Check out repository branch | ||
uses: actions/checkout@v3 | ||
|
||
- name: Ensure that at least one script will be checked | ||
run: | | ||
if [[ -z "$(find ${{ inputs.root-dirs }} -name '*.sh')" ]] ; then | ||
echo "::error::Error: No .sh files found within any of the root-dirs: ${{ inputs.root-dirs }}" | ||
exit 1 | ||
fi | ||
- name: Print helpful information | ||
run: | | ||
echo "The following shell scripts will be checked:" | ||
find ${{ inputs.root-dirs }} -name '*.sh' | ||
echo | ||
echo "If ShellCheck passes, the next step will have no output." | ||
echo "If ShellCheck fails, you should see a list of violations." | ||
echo "Each violation type has an SCXXXX code which can be looked up at https://www.shellcheck.net/wiki/SCXXXX" | ||
echo "We recommend that you try to resolve any violations." | ||
echo "In the case where resolving the violation doesn't make sense, you can use directives (https://www.shellcheck.net/wiki/Directive) to ignore a single violation instance or an entire shell script." | ||
echo | ||
# This step is intentionally a big one-line command so that | ||
# devs can easily copy it and run it on their own machine. | ||
- name: Run ShellCheck | ||
run: find ${{ inputs.root-dirs }} -name '*.sh' -print0 | xargs -0 shellcheck ${{ inputs.shellcheck-options }} | ||
|