Skip to content

Commit 7cdc778

Browse files
authored
add shellcheck to pre-commit (#238)
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 warnings: ```text SC2102 (info): Ranges can only match single chars (mentioned due to duplicates). SC2086 (info): Double quote to prevent globbing and word splitting. SC1091 (info): Not following: rapids-init-pip was not specified as input (see shellcheck -x). SC1091 (info): Not following: /opt/conda/etc/profile.d/conda.sh was not specified as input (see shellcheck -x). SC2034 (warning): NEXT_SHORT_TAG appears unused. Verify use (or export if used externally). SC2034 (warning): CURRENT_SHORT_TAG appears unused. Verify use (or export if used externally). SC2034 (warning): package_name appears unused. Verify use (or export if used externally). ``` Also updates all other hooks with `pre-commit autoupdate`. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Jacob Tomlinson (https://github.com/jacobtomlinson) - Gil Forsyth (https://github.com/gforsyth) URL: #238
1 parent a2830cc commit 7cdc778

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# CI code owners
55
.flake8 @rapidsai/ci-codeowners @rapidsai/packaging-codeowners
66
/.github/ @rapidsai/ci-codeowners
7+
.shellcheckrc @rapidsai/ci-codeowners
78
/ci/ @rapidsai/ci-codeowners
89

910
# packaging code owners

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ repos:
1414
- id: flake8
1515
args: ['--config=.flake8']
1616
files: jupyterlab_nvdashboard/.*$
17+
- repo: https://github.com/shellcheck-py/shellcheck-py
18+
rev: v0.10.0.1
19+
hooks:
20+
- id: shellcheck
1721
- repo: https://github.com/rapidsai/dependency-file-generator
1822
rev: v1.18.1
1923
hooks:

.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/build_wheel.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# Exit script if any command fails
55
set -euo pipefail
66

7-
# Set the package name
8-
package_name="jupyterlab-nvdashboard"
9-
107
# Configure sccache and set the date string
118
source rapids-configure-sccache
129
source rapids-date-string

ci/release/update-version.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,12 @@ NEXT_FULL_TAG=$1
1212

1313
# Get current version
1414
CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v')
15-
CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}')
16-
CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}')
17-
CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}')
18-
CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR}
19-
20-
#Get <major>.<minor> for next version
21-
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
22-
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}')
23-
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR}
2415

2516
echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG"
2617

2718
# Inplace sed replace; workaround for Linux and Mac
2819
function sed_runner() {
29-
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
20+
sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak
3021
}
3122

3223
jq --indent 4 -e --arg tag "$NEXT_FULL_TAG" '.version=$tag' package.json > package.json.tmp

ci/test_wheel.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ rapids-logger "Downloading artifacts from previous jobs"
1212
WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="${package_name}" RAPIDS_PY_WHEEL_PURE="1" rapids-download-wheels-from-github python)
1313

1414
# echo to expand wildcard before adding `[extra]` required for pip
15-
python -m pip install $(echo "${WHEELHOUSE}"/jupyterlab_nvdashboard*.whl)[test]
15+
python -m pip install \
16+
"$(echo "${WHEELHOUSE}"/jupyterlab_nvdashboard*.whl)[test]"
1617

1718
rapids-logger "Check GPU usage"
1819
nvidia-smi

ci/validate_wheel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)"

0 commit comments

Comments
 (0)