Skip to content

Commit

Permalink
Merge pull request #3940 from spyridon97/enable-shell-check-contract-…
Browse files Browse the repository at this point in the history
…scripts

Enable shell check scripts for existing scripts
  • Loading branch information
spyridon97 committed Dec 4, 2023
2 parents ca9c44b + ea4a249 commit 08f8995
Show file tree
Hide file tree
Showing 22 changed files with 159 additions and 98 deletions.
21 changes: 0 additions & 21 deletions .shellcheck_exclude_paths
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
scripts/ci/circle/postCDashStatus.sh
scripts/ci/circle/run.sh
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
Expand All @@ -15,18 +9,3 @@ scripts/developer/setup.sh
scripts/docker/setup-user.sh
scripts/runconf/runconf.sh
scripts/runconf/runconf_olcf.sh
testing/contract/lammps/build.sh
testing/contract/lammps/config.sh
testing/contract/lammps/install.sh
testing/contract/lammps/setup.sh
testing/contract/lammps/test.sh
testing/contract/scorpio/build.sh
testing/contract/scorpio/config.sh
testing/contract/scorpio/install.sh
testing/contract/scorpio/setup.sh
testing/contract/scorpio/test.sh
testing/contract/tau/build.sh
testing/contract/tau/config.sh
testing/contract/tau/install.sh
testing/contract/tau/setup.sh
testing/contract/tau/test.sh
7 changes: 4 additions & 3 deletions scripts/ci/circle/postCDashStatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USER=${STATUS_ROBOT_NAME}
TOKEN=${STATUS_ROBOT_KEY}
COMMIT=${CIRCLE_SHA1}
CDASH_STATUS_CONTEXT="cdash"
SOURCE_DIR="$(readlink -f ${CIRCLE_WORKING_DIRECTORY}/source)"
SOURCE_DIR="$(readlink -f "${CIRCLE_WORKING_DIRECTORY}"/source)"

build_status_body() {
cat <<EOF
Expand All @@ -18,8 +18,9 @@ EOF
}

PYTHON_SCRIPT="${SOURCE_DIR}/scripts/ci/findStatus.py"
curl -u "${USER}:${TOKEN}" "${API_BASE}/commits/${COMMIT}/statuses" | python3 ${PYTHON_SCRIPT} --context ${CDASH_STATUS_CONTEXT}
if [ $? -ne 0 ]
curl -u "${USER}:${TOKEN}" "${API_BASE}/commits/${COMMIT}/statuses" | python3 "${PYTHON_SCRIPT}" --context ${CDASH_STATUS_CONTEXT}
exit_status=$?
if [ "$exit_status" -ne 0 ]
then
echo "Need to post a status for context ${CDASH_STATUS_CONTEXT}"
postBody="$(build_status_body)"
Expand Down
11 changes: 7 additions & 4 deletions scripts/ci/circle/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash --login

# shellcheck source=/dev/null
. /etc/profile.d/modules.sh

# Parse the branch name used by the PR
Expand All @@ -8,8 +9,9 @@ REALBRANCH="${CIRCLE_BRANCH}"
if [ -n "${CIRCLE_PR_NUMBER}" ]
then
APIURL="${API_BASE}/pulls/${CIRCLE_PR_NUMBER}"
RESULT="$(curl -s ${APIURL} | python3 -c "import sys, json; print(json.load(sys.stdin)['head']['ref'])" 2> /dev/null)"
if [ $? -eq 0 ]
RESULT="$(curl -s "${APIURL}" | python3 -c "import sys, json; print(json.load(sys.stdin)['head']['ref'])" 2> /dev/null)"
exit_status=$?
if [ "$exit_status" -eq 0 ]
then
REALBRANCH="$(echo "${RESULT}" | tr '/' '-')"
fi
Expand Down Expand Up @@ -70,8 +72,9 @@ echo "**********Env End************"

echo "**********CTest Begin**********"
${CTEST} --version
echo ${CTEST} -VV -S ${CTEST_SCRIPT} -Ddashboard_full=OFF ${CTEST_STEP_ARGS}
${CTEST} -VV -S ${CTEST_SCRIPT} -Ddashboard_full=OFF ${CTEST_STEP_ARGS}
echo ${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 "**********CTest End************"

Expand Down
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
16 changes: 9 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,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::"

Expand Down
8 changes: 6 additions & 2 deletions testing/contract/lammps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

cmake --build ${build_dir} -j8
# Fail if is not set
build_dir="${build_dir:?}"

cmake --build "${build_dir}" -j8
16 changes: 11 additions & 5 deletions testing/contract/lammps/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

mkdir -p ${build_dir}
cd ${build_dir}
# Fail if is not set
source_dir="${source_dir:?}"
build_dir="${build_dir:?}"
install_dir="${install_dir:?}"

mkdir -p "${build_dir}"
cd "${build_dir}"

cmake \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
-DCMAKE_INSTALL_PREFIX="${install_dir}" \
-DBUILD_MPI=yes \
-DBUILD_EXE=yes \
-DBUILD_LIB=no \
-DBUILD_DOC=no \
-DLAMMPS_SIZES=smallbig \
-DPKG_ADIOS=yes \
${source_dir}/cmake
"${source_dir}/cmake"
8 changes: 6 additions & 2 deletions testing/contract/lammps/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

cmake --install ${build_dir}
# Fail if is not set
build_dir="${build_dir:?}"

cmake --install "${build_dir}"
15 changes: 11 additions & 4 deletions testing/contract/lammps/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
source_dir=$(readlink -f ${PWD})/source
build_dir=$(readlink -f ${PWD})/build
install_dir=$(readlink -f ${PWD})/install
test_dir=$(readlink -f ${PWD})/test
#!/bin/bash

source_dir=$(readlink -f "${PWD}")/source
build_dir=$(readlink -f "${PWD}")/build
install_dir=$(readlink -f "${PWD}")/install
test_dir=$(readlink -f "${PWD}")/test

export source_dir
export build_dir
export install_dir
export test_dir

echo "source_dir = \"${source_dir}\""
echo "build_dir = \"${build_dir}\""
Expand Down
13 changes: 9 additions & 4 deletions testing/contract/lammps/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

mkdir -p ${test_dir}
cd ${test_dir}
# Fail if is not set
install_dir="${install_dir:?}"
test_dir="${test_dir:?}"

mkdir -p "${test_dir}"
cd "${test_dir}"
cp -v /opt/adios2/source/testing/contract/lammps/{adios2_config.xml,check_results.sh,in.test} .


mpiexec -np 4 --oversubscribe ${install_dir}/bin/lmp -in in.test
mpiexec -np 4 --oversubscribe "${install_dir}/bin/lmp" -in in.test

./check_results.sh
8 changes: 6 additions & 2 deletions testing/contract/scorpio/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

cmake --build ${build_dir} -j8
# Fail if is not set
build_dir="${build_dir:?}"

cmake --build "${build_dir}" -j8
18 changes: 12 additions & 6 deletions testing/contract/scorpio/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

mkdir -p ${build_dir}
cd ${build_dir}
# Fail if is not set
source_dir="${source_dir:?}"
build_dir="${build_dir:?}"
install_dir="${install_dir:?}"

mkdir -p "${build_dir}"
cd "${build_dir}"

export CC=mpicc
export CXX=mpic++
export FC=mpifort

cmake \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
-DCMAKE_INSTALL_PREFIX="${install_dir}" \
-DFPHSA_NAME_MISMATCHED=ON \
-DPIO_ENABLE_TESTS=ON \
-DPIO_ENABLE_EXAMPLES=ON \
-DWITH_NETCDF=OFF \
-DWITH_PNETCDF=ON \
-DPnetCDF_PATH=$(spack location -i parallel-netcdf) \
-DPnetCDF_PATH="$(spack location -i parallel-netcdf)" \
-DWITH_ADIOS2=ON \
${source_dir}
"${source_dir}"
8 changes: 6 additions & 2 deletions testing/contract/scorpio/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

cmake --install ${build_dir}
# Fail if is not set
build_dir="${build_dir:?}"

cmake --install "${build_dir}"
15 changes: 11 additions & 4 deletions testing/contract/scorpio/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
source_dir=$(readlink -f ${PWD})/source
build_dir=$(readlink -f ${PWD})/build
install_dir=$(readlink -f ${PWD})/install
test_dir=$(readlink -f ${PWD})/test
#!/bin/bash

source_dir=$(readlink -f "${PWD}")/source
build_dir=$(readlink -f "${PWD}")/build
install_dir=$(readlink -f "${PWD}")/install
test_dir=$(readlink -f "${PWD}")/test

export source_dir
export build_dir
export install_dir
export test_dir

echo "source_dir = \"${source_dir}\""
echo "build_dir = \"${build_dir}\""
Expand Down
13 changes: 9 additions & 4 deletions testing/contract/scorpio/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
set -x
set -e

source $(dirname $(readlink -f ${BASH_SOURCE}))/setup.sh
# shellcheck disable=SC1091
source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/setup.sh"

mkdir -p ${test_dir}
cd ${test_dir}
# Fail if is not set
build_dir="${build_dir:?}"
test_dir="${test_dir:?}"

mpiexec --oversubscribe -np 4 ${build_dir}/examples/adios/example3 -v
mkdir -p "${test_dir}"
cd "${test_dir}"

mpiexec --oversubscribe -np 4 "${build_dir}/examples/adios/example3" -v

bpls -d example3_1.nc.bp.dir/example3_1.nc.bp.0 > 0.dump
diff -u 0.dump /opt/adios2/source/testing/contract/scorpio/0.dump
Expand Down

0 comments on commit 08f8995

Please sign in to comment.