From 90ac70a113b06f5fc15b574e71800328d713a2ea Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 22 Jan 2025 09:46:15 -0500 Subject: [PATCH] Add shellcheck to pre-commit and fix warnings --- .pre-commit-config.yaml | 6 ++++++ ci/build_docs.sh | 3 ++- ci/release/update-version.sh | 14 +++++--------- ci/test_python.sh | 1 + ci/test_wheel.sh | 2 +- ci/validate_wheel.sh | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2202df3b..31e8c32ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,6 +41,12 @@ repos: hooks: - id: rapids-dependency-file-generator args: ["--clean"] + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + args: ["--severity=warning"] + files: ^ci/ default_language_version: python: python3 diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 58da36c7c..5efa064ce 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,8 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ "dask-cuda=${RAPIDS_VERSION}" -export RAPIDS_DOCS_DIR="$(mktemp -d)" +RAPIDS_DOCS_DIR="$(mktemp -d)" +export RAPIDS_DOCS_DIR rapids-logger "Build Python docs" pushd docs diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index b229d2808..5457a634f 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -13,23 +13,19 @@ NEXT_FULL_TAG=$1 # Get current version CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') -CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}') -CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}') -CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}') -CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} #Get . for next version -NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}') -NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') +NEXT_MAJOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[1]}') +NEXT_MINOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[2]}') NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} NEXT_SHORT_TAG_PEP440=$(python -c "from packaging.version import Version; print(Version('${NEXT_SHORT_TAG}'))") -NEXT_UCXPY_VERSION="$(curl -s https://version.gpuci.io/rapids/${NEXT_SHORT_TAG})" +NEXT_UCXPY_VERSION="$(curl -s https://version.gpuci.io/rapids/"${NEXT_SHORT_TAG}")" echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG" # Inplace sed replace; workaround for Linux and Mac function sed_runner() { - sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak + sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak } # Centralized version file update @@ -70,6 +66,6 @@ for FILE in .github/workflows/*.yaml; do done # Docs referencing source code -find docs/source/ -type f -name *.rst -print0 | while IFS= read -r -d '' filename; do +find docs/source/ -type f -name '*.rst' -print0 | while IFS= read -r -d '' filename; do sed_runner "s|/branch-[^/]*/|/branch-${NEXT_SHORT_TAG}/|g" "${filename}" done diff --git a/ci/test_python.sh b/ci/test_python.sh index fadd473e5..ec4394e9d 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -37,6 +37,7 @@ rapids-logger "Check GPU usage" nvidia-smi EXITCODE=0 +# shellcheck disable=SC2317 set_exit_code() { EXITCODE=$? rapids-logger "Test failed with error ${EXITCODE}" diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index f883a7352..af8817475 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -14,6 +14,6 @@ rapids-dependency-file-generator \ rapids-logger "Installing test dependencies" # echo to expand wildcard -python -m pip install -v --prefer-binary -r /tmp/requirements-test.txt $(echo ./dist/dask_cuda*.whl) +python -m pip install -v --prefer-binary -r /tmp/requirements-test.txt "$(echo ./dist/dask_cuda*.whl)" python -m pytest ./dask_cuda/tests -k "not ucxx" diff --git a/ci/validate_wheel.sh b/ci/validate_wheel.sh index 60a80fce6..b3bbf93d6 100755 --- a/ci/validate_wheel.sh +++ b/ci/validate_wheel.sh @@ -9,10 +9,10 @@ rapids-logger "validate packages with 'pydistcheck'" pydistcheck \ --inspect \ - "$(echo ${wheel_dir_relative_path}/*.whl)" + "$(echo "${wheel_dir_relative_path}"/*.whl)" rapids-logger "validate packages with 'twine'" twine check \ --strict \ - "$(echo ${wheel_dir_relative_path}/*.whl)" + "$(echo "${wheel_dir_relative_path}"/*.whl)"