Skip to content

Commit 395a5dc

Browse files
authored
add shellcheck to pre-commit (#1145)
Contributes to rapidsai/build-planning#135 Adds `shellcheck` to `pre-commit`, to catch issues like unsafe access patterns, unused variables, etc. in shell scripts. Fixes these: ```text SC2034 (warning): UCX_PY_VERSION appears unused. Verify use (or export if used externally). SC2034 (warning): CURRENT_SHORT_TAG appears unused. Verify use (or export if used externally). SC2046 (warning): Quote this to prevent word splitting. SC2068 (error): Double quote array expansions to avoid re-splitting elements. SC2086 (info): Double quote to prevent globbing and word splitting. SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. SC2145 (error): Argument mixes string and array. Use * or separate argument ``` Also updates other RAPIDS-specific pre-commit hooks to their latest versions. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Gil Forsyth (https://github.com/gforsyth) - Peter Andreas Entschev (https://github.com/pentschev) URL: #1145
1 parent af18f11 commit 395a5dc

File tree

11 files changed

+50
-37
lines changed

11 files changed

+50
-37
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ benchmarks/ @rapidsai/ucxpy-python-codeowners
88
/.github/ @rapidsai/ci-codeowners
99
/ci/ @rapidsai/ci-codeowners
1010
/.pre-commit-config.yaml @rapidsai/ci-codeowners
11+
/.shellcheckrc @rapidsai/ci-codeowners
1112

1213
#packaging code owners
1314
/.devcontainer/ @rapidsai/packaging-codeowners

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ repos:
1919
types: [file]
2020
types_or: [python, cython]
2121
additional_dependencies: ["flake8-force"]
22+
- repo: https://github.com/shellcheck-py/shellcheck-py
23+
rev: v0.10.0.1
24+
hooks:
25+
- id: shellcheck
2226
- repo: https://github.com/rapidsai/pre-commit-hooks
23-
rev: v0.4.0
27+
rev: v0.6.0
2428
hooks:
2529
- id: verify-copyright
2630
- id: verify-alpha-spec
2731
args:
2832
- --fix
2933
- --rapids-version=25.08
3034
- repo: https://github.com/rapidsai/dependency-file-generator
31-
rev: v1.17.0
35+
rev: v1.18.1
3236
hooks:
3337
- id: rapids-dependency-file-generator
3438
args: ["--clean"]

.shellcheckrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Disable file checks (otherwise every use of `gha-tools` will get flagged)
2+
disable=SC1091

ci/release/update-version.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# Copyright (c) 2022-2025, NVIDIA CORPORATION.
3+
24
########################
35
# ucx-py Version Updater #
46
########################
@@ -13,18 +15,14 @@ NEXT_FULL_TAG=$1
1315

1416
# Get current version
1517
CURRENT_TAG=$(git tag | grep -xE 'v[0-9\.]+' | sort --version-sort | tail -n 1 | tr -d 'v')
16-
CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}')
17-
CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}')
18-
CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}')
19-
CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR}
2018

2119
#Get <major>.<minor> for next version
22-
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
23-
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}')
24-
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR}
20+
NEXT_MAJOR=$(echo "${NEXT_FULL_TAG}" | awk '{split($0, a, "."); print a[1]}')
21+
NEXT_MINOR=$(echo "${NEXT_FULL_TAG}" | awk '{split($0, a, "."); print a[2]}')
22+
NEXT_SHORT_TAG="${NEXT_MAJOR}.${NEXT_MINOR}"
2523

2624
# Get RAPIDS version associated w/ ucx-py version
27-
NEXT_RAPIDS_SHORT_TAG="$(curl -sL https://version.gpuci.io/ucx-py/${NEXT_SHORT_TAG})"
25+
NEXT_RAPIDS_SHORT_TAG="$(curl -sL "https://version.gpuci.io/ucx-py/${NEXT_SHORT_TAG}")"
2826

2927
# Need to distutils-normalize the versions for some use cases
3028
NEXT_SHORT_TAG_PEP440=$(python -c "from packaging.version import Version; print(Version('${NEXT_SHORT_TAG}'))")
@@ -35,7 +33,7 @@ echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG"
3533

3634
# Inplace sed replace; workaround for Linux and Mac
3735
function sed_runner() {
38-
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
36+
sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak
3937
}
4038

4139
DEPENDENCIES=(

ci/test_python.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../
99
rapids-logger "Create test conda environment using artifacts from previous job"
1010
. /opt/conda/etc/profile.d/conda.sh
1111

12-
UCX_PY_VERSION="$(head -1 ./VERSION)"
1312
PYTHON_CHANNEL=$(rapids-download-conda-from-github python)
1413

1514
rapids-dependency-file-generator \

ci/test_wheel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ set -eoxu pipefail
55

66
source rapids-init-pip
77

8-
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
8+
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"
99
PYTHON_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="ucx_py_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github python)
1010

1111
# echo to expand wildcard before adding `[extra]` requires for pip
12-
rapids-pip-retry install $(echo "${PYTHON_WHEELHOUSE}"/ucx_py*.whl)[test]
12+
rapids-pip-retry install "$(echo "${PYTHON_WHEELHOUSE}"/ucx_py*.whl)[test]"
1313

1414
cd tests
1515
timeout 10m python -m pytest --cache-clear -vs .

ci/validate_wheel.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2024, NVIDIA CORPORATION.
2+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
33

44
set -euo pipefail
55

@@ -9,10 +9,10 @@ rapids-logger "validate packages with 'pydistcheck'"
99

1010
pydistcheck \
1111
--inspect \
12-
"$(echo ${wheel_dir_relative_path}/*.whl)"
12+
"$(echo "${wheel_dir_relative_path}"/*.whl)"
1313

1414
rapids-logger "validate packages with 'twine'"
1515

1616
twine check \
1717
--strict \
18-
"$(echo ${wheel_dir_relative_path}/*.whl)"
18+
"$(echo "${wheel_dir_relative_path}"/*.whl)"

docker/bench-all.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
# Copyright (c) 2022, NVIDIA CORPORATION.
2+
# Copyright (c) 2022-2025, NVIDIA CORPORATION.
33

44
set -e
55

66
function logger {
7-
echo -e "\n$@\n"
7+
echo -e "\n${1}\n"
88
}
99

1010
# Requires conda installed at /opt/conda and the ucx environment setup
@@ -13,8 +13,15 @@ source /opt/conda/etc/profile.d/conda.sh
1313
conda activate ucx
1414

1515
cd ucx-py/
16+
1617
# Benchmark using command-line provided transports or else default
17-
for tls in ${@:-"tcp" "all"}; do
18+
if [[ ${#@} -eq 0 ]]; then
19+
transport_types=(tcp all)
20+
else
21+
transport_types=("${@}")
22+
fi
23+
24+
for tls in "${transport_types[@]}"; do
1825
export UCX_TLS=${tls}
1926
logger "Python pytest for ucx-py"
2027

docker/build-ucx-py.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
2+
# Copyright (c) 2022-2025, NVIDIA CORPORATION.
23
set -ex
34

45
CONDA_HOME=${1:-"/opt/conda"}
56
CONDA_ENV=${2:-"ucx"}
67

7-
source ${CONDA_HOME}/etc/profile.d/conda.sh
8-
source ${CONDA_HOME}/etc/profile.d/mamba.sh
9-
mamba activate ${CONDA_ENV}
8+
source "${CONDA_HOME}/etc/profile.d/conda.sh"
9+
source "${CONDA_HOME}/etc/profile.d/mamba.sh"
10+
mamba activate "${CONDA_ENV}"
1011

1112
git clone https://github.com/rapidsai/ucx-py.git
1213
pip install -v ucx-py/

docker/build-ucx.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
#!/bin/bash
2+
# Copyright (c) 2022-2025, NVIDIA CORPORATION.
23
set -ex
34

45
UCX_VERSION_TAG=${1:-"v1.13.0"}
56
CONDA_HOME=${2:-"/opt/conda"}
67
CONDA_ENV=${3:-"ucx"}
78
CUDA_HOME=${4:-"/usr/local/cuda"}
89
# Send any remaining arguments to configure
9-
CONFIGURE_ARGS=${@:5}
10+
CONFIGURE_ARGS=("${@:5}")
1011

11-
source ${CONDA_HOME}/etc/profile.d/conda.sh
12-
source ${CONDA_HOME}/etc/profile.d/mamba.sh
13-
mamba activate ${CONDA_ENV}
12+
source "${CONDA_HOME}/etc/profile.d/conda.sh"
13+
source "${CONDA_HOME}/etc/profile.d/mamba.sh"
14+
mamba activate "${CONDA_ENV}"
1415

1516
git clone https://github.com/openucx/ucx.git
1617

1718
cd ucx
18-
git checkout ${UCX_VERSION_TAG}
19+
git checkout "${UCX_VERSION_TAG}"
1920
./autogen.sh
2021
mkdir build-linux && cd build-linux
21-
../contrib/configure-release --prefix=${CONDA_PREFIX} --with-sysroot --enable-cma \
22+
../contrib/configure-release --prefix="${CONDA_PREFIX}" --with-sysroot --enable-cma \
2223
--enable-mt --with-gnu-ld --with-rdmacm --with-verbs \
23-
--with-cuda=${CUDA_HOME} \
24-
${CONFIGURE_ARGS}
24+
--with-cuda="${CUDA_HOME}" \
25+
"${CONFIGURE_ARGS[@]}"
2526
make -j install

docker/run.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
2-
# Copyright (c) 2021, NVIDIA CORPORATION.
2+
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
33
set -e
44

55
function logger {
6-
echo -e "\n$@\n"
6+
echo -e "\n${1}\n"
77
}
88

99
PYTHON_PREFIX=$(python -c "import distutils.sysconfig; print(distutils.sysconfig.PREFIX)")
@@ -25,17 +25,17 @@ pip list
2525
# BUILD - Build UCX master, UCX-Py and run tests
2626
################################################################################
2727
logger "Build UCX master"
28-
cd $HOME
28+
cd "${HOME}"
2929
git clone https://github.com/openucx/ucx
3030
cd ucx
3131
./autogen.sh
3232
./contrib/configure-devel \
33-
--prefix=$PYTHON_PREFIX \
33+
--prefix="${PYTHON_PREFIX}" \
3434
--enable-gtest=no \
3535
--with-valgrind=no
3636
make -j install
3737

38-
echo $PYTHON_PREFIX >> /etc/ld.so.conf.d/python.conf
38+
echo "${PYTHON_PREFIX}" >> /etc/ld.so.conf.d/python.conf
3939
ldconfig
4040

4141
logger "UCX Version and Build Information"
@@ -46,7 +46,7 @@ ucx_info -v
4646
# TEST - Run pytests for ucx-py
4747
################################################################################
4848
logger "Clone and Build UCX-Py"
49-
cd $HOME
49+
cd "${HOME}"
5050
git clone https://github.com/rapidsai/ucx-py
5151
cd ucx-py
5252
python setup.py build_ext --inplace

0 commit comments

Comments
 (0)