From 7d470fd41559a1f8cde81330863e7e20796f55ff Mon Sep 17 00:00:00 2001 From: Spiros Tsalikis Date: Thu, 23 Nov 2023 12:40:36 -0500 Subject: [PATCH] Enable Shell-Check for gh-actions scripts --- .shellcheck_exclude_paths | 4 ---- scripts/ci/gh-actions/check-branch-name.sh | 2 +- scripts/ci/gh-actions/get-changed-files.sh | 12 ++++++------ scripts/ci/gh-actions/macos-setup.sh | 8 ++++---- scripts/ci/gh-actions/run.sh | 16 +++++++++------- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/.shellcheck_exclude_paths b/.shellcheck_exclude_paths index 4f77bacc4d..873e54f928 100644 --- a/.shellcheck_exclude_paths +++ b/.shellcheck_exclude_paths @@ -1,7 +1,3 @@ -scripts/ci/gh-actions/check-branch-name.sh -scripts/ci/gh-actions/get-changed-files.sh -scripts/ci/gh-actions/macos-setup.sh -scripts/ci/gh-actions/run.sh scripts/ci/scripts/github-prs-to-gitlab.sh scripts/ci/scripts/run-clang-format.sh scripts/ci/scripts/run-flake8.sh diff --git a/scripts/ci/gh-actions/check-branch-name.sh b/scripts/ci/gh-actions/check-branch-name.sh index 83bffd8e85..52d09e6cb0 100755 --- a/scripts/ci/gh-actions/check-branch-name.sh +++ b/scripts/ci/gh-actions/check-branch-name.sh @@ -4,7 +4,7 @@ if [ "${GITHUB_EVENT_NAME}" = "pull_request" ] then if [ -z "${BASE_REF}" ] then - BASE_REF="$(jq -r .pull_request.base.ref ${GITHUB_EVENT_PATH})" + BASE_REF="$(jq -r .pull_request.base.ref "${GITHUB_EVENT_PATH}")" fi echo "Base ref: ${BASE_REF}" echo "Head ref: ${GITHUB_HEAD_REF}" diff --git a/scripts/ci/gh-actions/get-changed-files.sh b/scripts/ci/gh-actions/get-changed-files.sh index 9e3ed8fa5b..5afcd19396 100755 --- a/scripts/ci/gh-actions/get-changed-files.sh +++ b/scripts/ci/gh-actions/get-changed-files.sh @@ -3,12 +3,12 @@ case "${GITHUB_EVENT_NAME}" in pull_request) - BASE_SHA=$(jq -r .pull_request.base.sha ${GITHUB_EVENT_PATH}) - HEAD_SHA=$(jq -r .pull_request.head.sha ${GITHUB_EVENT_PATH}) + BASE_SHA=$(jq -r .pull_request.base.sha "${GITHUB_EVENT_PATH}") + HEAD_SHA=$(jq -r .pull_request.head.sha "${GITHUB_EVENT_PATH}") ;; push) - BASE_SHA=$(jq -r .before ${GITHUB_EVENT_PATH}) - HEAD_SHA=$(jq -r .after ${GITHUB_EVENT_PATH}) + BASE_SHA=$(jq -r .before "${GITHUB_EVENT_PATH}") + HEAD_SHA=$(jq -r .after "${GITHUB_EVENT_PATH}") ;; *) echo "Unable to get changed files from '${GITHUB_EVENT_NAME}' event" @@ -20,11 +20,11 @@ echo "Base: ${BASE_SHA}" echo "Head: ${HEAD_SHA}" echo "" -git fetch origin ${BASE_SHA} +git fetch origin "${BASE_SHA}" echo "" echo "::group::All changed files" -git diff --name-only ${BASE_SHA}...${HEAD_SHA} | tee all-changed-files.txt +git diff --name-only "${BASE_SHA}"..."${HEAD_SHA}" | tee all-changed-files.txt echo "::group::Filtered changes" grep -v '^docs/' all-changed-files.txt | tee filtered-changed-files.txt diff --git a/scripts/ci/gh-actions/macos-setup.sh b/scripts/ci/gh-actions/macos-setup.sh index 8cae241e0e..0eb6850f20 100755 --- a/scripts/ci/gh-actions/macos-setup.sh +++ b/scripts/ci/gh-actions/macos-setup.sh @@ -8,13 +8,13 @@ then echo "Error: GH_YML_MATRIX_COMPILER variable is not defined" exit 1 fi -XCODE_VER="$(echo ${GH_YML_MATRIX_COMPILER} | sed -e 's|_|.|g' -e 's|xcode||')" -if [ ! -d /Applications/Xcode_${XCODE_VER}.app ] +XCODE_VER="$(echo "${GH_YML_MATRIX_COMPILER}" | sed -e 's|_|.|g' -e 's|xcode||')" +if [ ! -d "/Applications/Xcode_${XCODE_VER}.app" ] then echo "Error: XCode installation directory /Applications/Xcode_${XCODE_VER}.app does not exist" exit 2 fi -sudo xcode-select --switch /Applications/Xcode_${XCODE_VER}.app +sudo xcode-select --switch "/Applications/Xcode_${XCODE_VER}.app" echo "Installing CMake" @@ -36,7 +36,7 @@ brew install ninja echo "Installing GCC" brew install gcc -sudo ln -v -s $(which gfortran-11) /usr/local/bin/gfortran +sudo ln -v -s "$(which gfortran-11)" /usr/local/bin/gfortran echo "Installing blosc compression" brew install c-blosc diff --git a/scripts/ci/gh-actions/run.sh b/scripts/ci/gh-actions/run.sh index 5dcfcca7aa..c511730eea 100755 --- a/scripts/ci/gh-actions/run.sh +++ b/scripts/ci/gh-actions/run.sh @@ -100,19 +100,19 @@ export ADIOS2_IP=127.0.0.1 export OMP_NUM_THREADS=1 # Load any additional setup scripts -if [ -f gha/scripts/ci/setup-run/ci-${GH_YML_JOBNAME}.sh ] +if [ -f "gha/scripts/ci/setup-run/ci-${GH_YML_JOBNAME}.sh" ] then SETUP_RUN_SCRIPT=gha/scripts/ci/setup-run/ci-${GH_YML_JOBNAME}.sh -elif [ -f gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}-${GH_YML_MATRIX_PARALLEL}.sh ] +elif [ -f "gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}-${GH_YML_MATRIX_PARALLEL}.sh" ] then SETUP_RUN_SCRIPT=gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}-${GH_YML_MATRIX_PARALLEL}.sh -elif [ -f gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}.sh ] +elif [ -f "gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}.sh" ] then SETUP_RUN_SCRIPT=gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}-${GH_YML_MATRIX_COMPILER}.sh -elif [ -f gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}.sh ] +elif [ -f "gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}.sh" ] then SETUP_RUN_SCRIPT=gha/scripts/ci/setup-run/ci-${GH_YML_MATRIX_OS}.sh -elif [ -f gha/scripts/ci/setup-run/ci-${GH_YML_BASE_OS}.sh ] +elif [ -f "gha/scripts/ci/setup-run/ci-${GH_YML_BASE_OS}.sh" ] then SETUP_RUN_SCRIPT=gha/scripts/ci/setup-run/ci-${GH_YML_BASE_OS}.sh fi @@ -126,7 +126,8 @@ echo "::endgroup::" echo "::group::Job-run setup (if any)" if [ "${SETUP_RUN_SCRIPT:-UNSET}" != "UNSET" ] then - source ${SETUP_RUN_SCRIPT} + # shellcheck source=/dev/null + source "${SETUP_RUN_SCRIPT}" fi echo "::endgroup::" @@ -139,7 +140,8 @@ echo "::group::CTest version" echo "::endgroup::" echo "::group::Execute job step" -"${CTEST}" -VV -S ${CTEST_SCRIPT} -Ddashboard_full=OFF ${CTEST_STEP_ARGS} +# shellcheck disable=SC2086 +"${CTEST}" -VV -S "${CTEST_SCRIPT}" -Ddashboard_full=OFF ${CTEST_STEP_ARGS} RET=$? echo "::endgroup::"