From db213ee316c9e0785505c7382d5f65f6f915acc8 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 11 Feb 2023 08:37:44 -0600 Subject: [PATCH] Don't exit 1 on NON_EXECUTABLE_FILES and check all scripts --- checkrun.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/checkrun.sh b/checkrun.sh index 883cbad..dc1905c 100755 --- a/checkrun.sh +++ b/checkrun.sh @@ -1,9 +1,10 @@ #!/bin/bash # clear preexisting variables not set by job -unset EXECUTABLE_FILES MOUNT_OPTIONS NON_EXECUTABLE_FILES SHELLCHECK_OPTIONS SHELLCKECK_IMAGE TEST_AREA +unset ALL_SHELL_FILES EXECUTABLE_FILES MOUNT_OPTIONS NON_EXECUTABLE_FILES SHELLCHECK_OPTIONS SHELLCKECK_IMAGE TEST_AREA # initialize variables +ALL_SHELL_FILES=() EXECUTABLE_FILES=() MOUNT_OPTIONS=() NON_EXECUTABLE_FILES=() @@ -46,6 +47,7 @@ fi # check test area for executable files while IFS= read -r -d '' file; do if head -n1 "${file}" | grep -q -E -w "sh|bash|dash|ksh"; then + ALL_SHELL_FILES+=("${file}") if [[ -x "${file}" ]]; then EXECUTABLE_FILES+=("${file}") else @@ -58,11 +60,11 @@ done < <(find "${TEST_AREA[@]}" -type f -print0) if [[ ${#NON_EXECUTABLE_FILES[@]} -ne 0 ]]; then echo "the following shell scripts are not executable:" printf "'%s'\n" "${NON_EXECUTABLE_FILES[@]}" - exit 1 + #exit 1 # errors for non executable files are reported by https://github.com/linuxserver/github-workflows/blob/v1/.github/workflows/init-svc-executable-permissions.yml fi -# exit gracefully if no EXECUTABLE_FILES are found -if [[ ${#EXECUTABLE_FILES[@]} -eq 0 ]]; then +# exit gracefully if no ALL_SHELL_FILES are found +if [[ ${#ALL_SHELL_FILES[@]} -eq 0 ]]; then echo "no common files found, linting not required" exit 0 fi @@ -72,7 +74,7 @@ docker pull "${SHELLCKECK_IMAGE}" docker run --rm -t \ "${SHELLCKECK_IMAGE}" \ shellcheck --version -find "${EXECUTABLE_FILES[@]}" -exec \ +find "${ALL_SHELL_FILES[@]}" -exec \ docker run --rm -t \ "${MOUNT_OPTIONS[@]}" \ "${SHELLCKECK_IMAGE}" \