-
Notifications
You must be signed in to change notification settings - Fork 76
Add option to skip downloading shellcheck on every run #108
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,7 +41,7 @@ inputs: | |||||||||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||||||||||
default: "gcc" | ||||||||||||||||||||||||||||||||||
version: | ||||||||||||||||||||||||||||||||||
description: "Specify a concrete version of ShellCheck to use" | ||||||||||||||||||||||||||||||||||
description: "The version of ShellCheck to download. Set to 'system' to use pre-installed shellcheck." | ||||||||||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||||||||||
default: "stable" | ||||||||||||||||||||||||||||||||||
outputs: | ||||||||||||||||||||||||||||||||||
|
@@ -61,26 +61,30 @@ runs: | |||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||
INPUT_VERSION: ${{ inputs.version }} | ||||||||||||||||||||||||||||||||||
OS_NAME: ${{ runner.os }} | ||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||
if [[ "${{ runner.os }}" == "macOS" ]]; then | ||||||||||||||||||||||||||||||||||
if [ "${INPUT_VERSION}" = "system" ]; then | ||||||||||||||||||||||||||||||||||
echo "Using system shellcheck: $(command -v shellcheck)" | ||||||||||||||||||||||||||||||||||
exit 0 | ||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||
mislav marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if [ "${OS_NAME}" = "macOS" ]; then | ||||||||||||||||||||||||||||||||||
osvariant="darwin" | ||||||||||||||||||||||||||||||||||
download_dir="$(mktemp -d -t shellcheck)" | ||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||
osvariant="linux" | ||||||||||||||||||||||||||||||||||
download_dir="$(mktemp -d --tmpdir shellcheck.XXX)" | ||||||||||||||||||||||||||||||||||
mislav marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
baseurl="https://github.com/koalaman/shellcheck/releases/download" | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
curl -Lso "${{ github.action_path }}/sc.tar.xz" \ | ||||||||||||||||||||||||||||||||||
"${baseurl}/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | ||||||||||||||||||||||||||||||||||
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \ | ||||||||||||||||||||||||||||||||||
tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck" | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
tar -xf "${{ github.action_path }}/sc.tar.xz" -C "${{ github.action_path }}" | ||||||||||||||||||||||||||||||||||
mv "${{ github.action_path }}/shellcheck-${INPUT_VERSION}/shellcheck" \ | ||||||||||||||||||||||||||||||||||
"${{ github.action_path }}/shellcheck" | ||||||||||||||||||||||||||||||||||
echo "${download_dir}" >> "$GITHUB_PATH" | ||||||||||||||||||||||||||||||||||
Comment on lines
+79
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify shellcheck binary after extraction. The download and extraction should be verified to ensure we have a working shellcheck binary. curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \
tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck"
+if [ ! -x "${download_dir}/shellcheck" ]; then
+ echo "::error::Failed to download or extract shellcheck"
+ exit 1
+fi
+
echo "${download_dir}" >> "$GITHUB_PATH" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
- name: Display shellcheck version | ||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||
"${{ github.action_path }}/shellcheck" --version | ||||||||||||||||||||||||||||||||||
shellcheck --version | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
- name: Set options | ||||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||||
|
@@ -204,13 +208,11 @@ runs: | |||||||||||||||||||||||||||||||||
-print0) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if [[ -n "${INPUT_CHECK_TOGETHER}" ]]; then | ||||||||||||||||||||||||||||||||||
"${{ github.action_path }}/shellcheck" \ | ||||||||||||||||||||||||||||||||||
${INPUT_SHELLCHECK_OPTIONS} \ | ||||||||||||||||||||||||||||||||||
shellcheck ${INPUT_SHELLCHECK_OPTIONS} \ | ||||||||||||||||||||||||||||||||||
"${filepaths[@]}" || statuscode=$? | ||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||
for file in "${filepaths[@]}"; do | ||||||||||||||||||||||||||||||||||
"${{ github.action_path }}/shellcheck" \ | ||||||||||||||||||||||||||||||||||
${INPUT_SHELLCHECK_OPTIONS} \ | ||||||||||||||||||||||||||||||||||
shellcheck ${INPUT_SHELLCHECK_OPTIONS} \ | ||||||||||||||||||||||||||||||||||
"$file" || statuscode=$? | ||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.