Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 68e63ae

Browse files
gforsythbdice
andauthored
Add shellcheck to pre-commit and fix warnings (#126)
`shellcheck` is a fast, static analysis tool for shell scripts. It's good at flagging up unused variables, unintentional glob expansions, and other potential execution and security headaches that arise from the wonders of `bash` (and other shlangs). This PR adds a `pre-commit` hook to run `shellcheck` on all of the `sh-lang` files in the `ci/` directory, and the changes requested by `shellcheck` to make the existing files pass the check. xref: rapidsai/build-planning#135 Co-authored-by: Bradley Dice <[email protected]>
1 parent afb2f8d commit 68e63ae

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ repos:
2323
hooks:
2424
- id: verify-copyright
2525
args: [--fix, --main-branch=main]
26+
- repo: https://github.com/shellcheck-py/shellcheck-py
27+
rev: v0.10.0.1
28+
hooks:
29+
- id: shellcheck
30+
args: ["--severity=warning"]
31+
files: ^ci/

ci/build_conda.sh

Lines changed: 3 additions & 2 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

@@ -17,7 +17,8 @@ rapids-print-env
1717

1818
rapids-logger "Begin py build"
1919

20-
export CUDA_VERSION="$(cat pynvjitlink/CUDA_VERSION)"
20+
CUDA_VERSION="$(cat pynvjitlink/CUDA_VERSION)"
21+
export CUDA_VERSION
2122

2223
cat > cuda_compiler_version.yaml << EOF
2324
cuda_compiler_version:

ci/build_wheel.sh

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

44
set -euo pipefail
55

@@ -8,7 +8,7 @@ source rapids-configure-sccache
88
rapids-logger "Install CUDA Toolkit"
99
source "$(dirname "$0")/install_latest_cuda_toolkit.sh"
1010

11-
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
11+
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"
1212

1313
sccache --zero-stats
1414

ci/install_latest_cuda_toolkit.sh

Lines changed: 9 additions & 7 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
# Installs the latest CUDA Toolkit.
55
# Supports Rocky Linux 8.
@@ -13,12 +13,14 @@ if [ "${OS_ID}" != "rocky" ]; then
1313
exit 1
1414
fi
1515

16-
export CUDA_VERSION="$(cat pynvjitlink/CUDA_VERSION)"
17-
export YUM_CUDA_VERSION="${CUDA_VERSION//./-}"
16+
CUDA_VERSION="$(cat pynvjitlink/CUDA_VERSION)"
17+
export CUDA_VERSION
18+
YUM_CUDA_VERSION="${CUDA_VERSION//./-}"
19+
export YUM_CUDA_VERSION
1820

1921
yum install -y \
20-
cuda-nvcc-$YUM_CUDA_VERSION \
21-
cuda-cudart-devel-$YUM_CUDA_VERSION \
22-
cuda-driver-devel-$YUM_CUDA_VERSION \
23-
libnvjitlink-devel-$YUM_CUDA_VERSION \
22+
cuda-nvcc-"$YUM_CUDA_VERSION" \
23+
cuda-cudart-devel-"$YUM_CUDA_VERSION" \
24+
cuda-driver-devel-"$YUM_CUDA_VERSION" \
25+
libnvjitlink-devel-"$YUM_CUDA_VERSION" \
2426
;

ci/release/update-version.sh

Lines changed: 2 additions & 2 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
## Usage
55
# bash update-version.sh <new_version>
@@ -12,7 +12,7 @@ echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG"
1212

1313
# Inplace sed replace; workaround for Linux and Mac
1414
function sed_runner() {
15-
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
15+
sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak
1616
}
1717

1818
# Centralized version file update

ci/test_wheel.sh

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

44
set -euo pipefail
55

66
rapids-logger "Download Wheel"
7-
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
7+
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"
88
RAPIDS_PY_WHEEL_NAME="pynvjitlink_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist/
99

1010
RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/
1111
mkdir -p "${RAPIDS_TESTS_DIR}"
1212

1313
rapids-logger "Install wheel"
14-
python -m pip install $(echo ./dist/pynvjitlink_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]
14+
python -m pip install "$(echo ./dist/pynvjitlink_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]"
1515

1616
rapids-logger "Build Tests"
1717
pushd test_binary_generation

0 commit comments

Comments
 (0)