Skip to content

Commit e6f193d

Browse files
authored
add shellcheck, update pre-commit hooks (#738)
Contributes to #667 Expands testing to improve release confidence in these images. * adds new `pre-commit` hooks: - `rapidsai/verify-copyright` = keep copyright notices up to date - `shellcheck` = catch issues and enforce consistency in shell scripts * updates all other `pre-commit` hooks * switches from a manual `run:` to `pre-commit/[email protected]` in CI, for faster runs of `pre-commit` and simpler CI configuration Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: #738
1 parent b54d89d commit e6f193d

22 files changed

+54
-18
lines changed

.github/workflows/build-cuvs-image.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
12
name: Build and push image variant
23

34
on:

.github/workflows/build-rapids-image.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
12
name: Build and push image variant
23

34
on:

.github/workflows/build-test-publish-images.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
12
name: build and publish imgs workflow
23

34
on:
@@ -46,12 +47,9 @@ jobs:
4647
checks:
4748
runs-on: ubuntu-latest
4849
steps:
49-
- name: Checkout
50-
uses: actions/checkout@v4
50+
- uses: actions/checkout@v4
5151
- name: Run pre-commit
52-
run: |
53-
pip install pre-commit
54-
pre-commit run --all-files
52+
uses: pre-commit/[email protected]
5553
compute-matrix:
5654
runs-on: ubuntu-latest
5755
container:

.github/workflows/pr.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
12
name: ci
23

34
on:

.github/workflows/publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
12
name: publish
23

34
on:

.github/workflows/release-to-ngc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
12
name: Publish release images to NGC
23

34
on:

.github/workflows/test-notebooks.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
12
name: Test notebooks
23

34
on:

.github/workflows/trigger-breaking-change-alert.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
12
name: Trigger Breaking Change Notifications
23

34
on:

.pre-commit-config.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
12
---
23
repos:
34
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.6.0
5+
rev: v5.0.0
56
hooks:
67
- id: end-of-file-fixer
78
- id: trailing-whitespace
89
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.5.2
10+
rev: v0.11.0
1011
hooks:
1112
- id: ruff
1213
args: ["--config", "pyproject.toml"]
14+
- repo: https://github.com/shellcheck-py/shellcheck-py
15+
rev: v0.10.0.1
16+
hooks:
17+
- id: shellcheck
18+
args: ["--severity=warning"]
19+
- repo: https://github.com/rapidsai/pre-commit-hooks
20+
rev: v0.6.0
21+
hooks:
22+
- id: verify-copyright
23+
files: |
24+
(?x)
25+
[.](jq|py|sh|toml|yml|yaml)$|
26+
Dockerfile$

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# syntax=docker/dockerfile:1
2+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
23

34
ARG CUDA_VER=unset
45
ARG PYTHON_VER=unset

ci/common.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
23

34
set -eEuo pipefail
45

ci/compute-matrix.jq

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
2+
13
def compute_arch($x):
24
$x + {ARCHES: ["amd64", "arm64"]};
35

ci/compute-matrix.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
23

34
set -euo pipefail
45

ci/create-cuvs-multiarch-manifest.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
23

34
set -eEuo pipefail
45

@@ -7,18 +8,18 @@ common_path="$(dirname "$(realpath "$0")")/common.sh"
78
source "$common_path"
89

910
cuvs_bench_source_tags=()
10-
cuvs_bench_datasets_source_tags=()
11+
# cuvs_bench_datasets_source_tags=()
1112
cuvs_bench_cpu_source_tags=()
1213

1314
# Define tag arrays for different images
1415
cuvs_bench_tag="${CUVS_BENCH_TAG_PREFIX}${RAPIDS_VER}${ALPHA_TAG}-cuda${CUDA_TAG}-py${PYTHON_VER}"
15-
cuvs_bench_datasets_tag="${CUVS_BENCH_DATASETS_TAG_PREFIX}${RAPIDS_VER}${ALPHA_TAG}-cuda${CUDA_TAG}-py${PYTHON_VER}"
16+
# cuvs_bench_datasets_tag="${CUVS_BENCH_DATASETS_TAG_PREFIX}${RAPIDS_VER}${ALPHA_TAG}-cuda${CUDA_TAG}-py${PYTHON_VER}"
1617
cuvs_bench_cpu_tag="${CUVS_BENCH_CPU_TAG_PREFIX}${RAPIDS_VER}${ALPHA_TAG}-py${PYTHON_VER}"
1718

1819
# Check if all source tags exist and add to source tags array
1920
for arch in $(echo "${ARCHES}" | jq .[] -r); do
2021
full_cuvs_bench_tag="${cuvs_bench_tag}-${arch}"
21-
full_cuvs_bench_datasets_tag="${cuvs_bench_datasets_tag}-${arch}"
22+
# full_cuvs_bench_datasets_tag="${cuvs_bench_datasets_tag}-${arch}"
2223
full_cuvs_bench_cpu_tag="${cuvs_bench_cpu_tag}-${arch}"
2324

2425
check_tag_exists "$CUVS_BENCH_IMAGE_REPO" "$full_cuvs_bench_tag"
@@ -36,6 +37,8 @@ done
3637
docker manifest create "${org}/${CUVS_BENCH_IMAGE_REPO}:${cuvs_bench_tag}" "${cuvs_bench_source_tags[@]}"
3738
docker manifest push "${org}/${CUVS_BENCH_IMAGE_REPO}:${cuvs_bench_tag}"
3839

40+
# this and everything above that it uses can be uncommented once the issues with cuVS datasets are fixed
41+
# ref: https://github.com/rapidsai/docker/issues/724
3942
# docker manifest create "${org}/${CUVS_BENCH_DATASETS_IMAGE_REPO}:${cuvs_bench_datasets_tag}" "${cuvs_bench_datasets_source_tags[@]}"
4043
# docker manifest push "${org}/${CUVS_BENCH_DATASETS_IMAGE_REPO}:${cuvs_bench_datasets_tag}"
4144

ci/create-rapids-multiarch-manifest.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
23

34
set -eEuo pipefail
45

ci/release/update-version.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
23

34
## Usage
45
# bash update-version.sh <new_version>
@@ -9,10 +10,6 @@ NEXT_FULL_TAG=$1
910

1011
# Get current version
1112
CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v')
12-
CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}')
13-
CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}')
14-
CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}')
15-
CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR}
1613

1714
# Get <major>.<minor> for next version
1815
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
@@ -26,7 +23,7 @@ function sed_runner() {
2623
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
2724
}
2825

29-
for FILE in $(find . -name Dockerfile); do
26+
find . -name Dockerfile | while IFS= read -r -d '' FILE; do
3027
sed_runner "s/ARG RAPIDS_VER=.*/ARG RAPIDS_VER=${NEXT_SHORT_TAG}/g" "${FILE}"
3128
done
3229

context/entrypoint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
3+
24
set -eo pipefail
35

46
cat << EOF
@@ -33,6 +35,9 @@ fi
3335

3436
# Run whatever the user wants.
3537
if [ "${UNQUOTE}" = "true" ]; then
38+
# splitting elements without quoting is intentional here,
39+
# to make it possible to tightly control the quoting of arguments
40+
# shellcheck disable=SC2068
3641
exec $@
3742
else
3843
exec "$@"

context/notebooks.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
23

34
# Clones repos with notebooks & compiles notebook test dependencies
45
# Requires environment variables:

context/test_notebooks.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
23

34
import argparse
45
import os
@@ -186,7 +187,7 @@ def test_notebook(notebook_file, executed_nb_file):
186187

187188
if found_errors:
188189
print("Error during notebook tests!")
189-
for notebook in nb_errors.keys():
190-
if nb_errors[notebook]:
191-
print(f'Errors during {notebook}')
190+
for notebook_id, errors in nb_errors.items():
191+
if errors:
192+
print(f"Errors during '{notebook_id}'")
192193
sys.exit(2)

cuvs-bench/cpu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# syntax=docker/dockerfile:1
2+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
23

34
ARG PYTHON_VER=unset
45
ARG RAPIDS_VER=25.04

cuvs-bench/gpu/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# syntax=docker/dockerfile:1
2+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
23

34
ARG CUDA_VER=unset
45
ARG PYTHON_VER=unset

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
2+
13
[tool.ruff]
24
target-version = "py310"
35

0 commit comments

Comments
 (0)