Skip to content

Commit

Permalink
Enable Shell-Check for gh-actions scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
spyridon97 committed Nov 23, 2023
1 parent 990305e commit a3b5597
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
4 changes: 0 additions & 4 deletions .shellcheck_exclude_paths
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
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
2 changes: 1 addition & 1 deletion scripts/ci/gh-actions/check-branch-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
12 changes: 6 additions & 6 deletions scripts/ci/gh-actions/get-changed-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/ci/gh-actions/macos-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
15 changes: 8 additions & 7 deletions scripts/ci/gh-actions/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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::"

Expand All @@ -139,7 +140,7 @@ echo "::group::CTest version"
echo "::endgroup::"

echo "::group::Execute job step"
"${CTEST}" -VV -S ${CTEST_SCRIPT} -Ddashboard_full=OFF ${CTEST_STEP_ARGS}
"${CTEST}" -VV -S "${CTEST_SCRIPT}" -Ddashboard_full=OFF "${CTEST_STEP_ARGS}"
RET=$?
echo "::endgroup::"

Expand Down

0 comments on commit a3b5597

Please sign in to comment.