-
Notifications
You must be signed in to change notification settings - Fork 326
Add shellcheck to pre-commit and fix warnings #4954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continuing this. Left some comments for your consideration.
DGL_CHANNEL="dglteam/label/th23_cu118" | ||
else | ||
CONDA_CUDA_VERSION="12.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love when these shellcheck
PRs find unused variables 😁
ci/test_wheel.sh
Outdated
@@ -28,5 +28,5 @@ else | |||
--import-mode=append \ | |||
--benchmark-disable \ | |||
-k "not test_property_graph_mg and not test_bulk_sampler_io" \ | |||
./python/${package_name}/${python_package_name}/tests | |||
./python/"${package_name}"/"${python_package_name}"/tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./python/"${package_name}"/"${python_package_name}"/tests | |
"./python/${package_name}/${python_package_name}/tests" |
Since there isn't anything else here like wildcards that need to be evaluated, I have a mild preference for just wrapping the entire thing in double quotes, instead of having 2 inner sets of double quotes. Think that's a little easier to read and to modify.
ci/utils/nbtest.sh
Outdated
jupyter nbconvert --to script "${NBFILENAME}" --output "${NBTMPDIR}"/"${NBNAME}"-test | ||
echo "${MAGIC_OVERRIDE_CODE}" > "${NBTMPDIR}"/tmpfile | ||
cat "${NBTESTSCRIPT}" >> "${NBTMPDIR}"/tmpfile | ||
mv "${NBTMPDIR}"/tmpfile "${NBTESTSCRIPT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jupyter nbconvert --to script "${NBFILENAME}" --output "${NBTMPDIR}"/"${NBNAME}"-test | |
echo "${MAGIC_OVERRIDE_CODE}" > "${NBTMPDIR}"/tmpfile | |
cat "${NBTESTSCRIPT}" >> "${NBTMPDIR}"/tmpfile | |
mv "${NBTMPDIR}"/tmpfile "${NBTESTSCRIPT}" | |
jupyter nbconvert --to script "${NBFILENAME}" --output "${NBTMPDIR}/${NBNAME}-test" | |
echo "${MAGIC_OVERRIDE_CODE}" > "${NBTMPDIR}/tmpfile" | |
cat "${NBTESTSCRIPT}" >> "${NBTMPDIR}/tmpfile" | |
mv "${NBTMPDIR}/tmpfile" "${NBTESTSCRIPT}" |
Similar to my comments above.
.pre-commit-config.yaml
Outdated
hooks: | ||
- id: shellcheck | ||
args: ["--severity=warning"] | ||
files: ^ci/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand this a bit? I'd really like to see it cover stuff like https://github.com/rapidsai/cugraph/blob/branch-25.04/datasets/get_test_data.sh and https://github.com/rapidsai/cugraph/blob/branch-25.04/scripts/dask/run-dask-process.sh too
If you want to just remove this exclusion and have it cover all shell scripts in this round, I don't mind that making the PR larger.
That'd also be one less repo to have to modify in the second round of this that covers build.sh
scripts.
@gforsyth Want to revive this? I retargeted to 25.06 but there are merge conflicts. |
If we quote a string variable like `INSTALL_TARGET=""` then that expands with `${INSTALL_TARGET}` into `''` inline which can break argument parsing for `cmake` and other programs. If we make them arrays, empty arrays splat out to nothing, but arguments are correctly spaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good from Docs standpoint.
I have a question but nothing to slow down approval.
build.sh
Outdated
CMAKE_VERBOSE_OPTION=() | ||
BUILD_TYPE=Release | ||
INSTALL_TARGET="--target install" | ||
INSTALL_TARGET=("--target" "install") | ||
BUILD_CPP_TESTS=ON | ||
BUILD_CPP_MG_TESTS=OFF | ||
BUILD_CPP_MTMG_TESTS=OFF | ||
BUILD_ALL_GPU_ARCH=0 | ||
CMAKE_GENERATOR_OPTION="-G Ninja" | ||
PYTHON_ARGS_FOR_INSTALL="-m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true" | ||
CMAKE_GENERATOR_OPTION=("-G" "Ninja") | ||
PYTHON_ARGS_FOR_INSTALL=("-m" "pip" "install" "--no-build-isolation" "--no-deps" "--config-settings" "rapidsai.disable-cuda=true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that shellcheck turns strings with spaces into arrays. The potential issues it's trying to avoid don't seem to outweigh the clunkiness of using an array as a string with spaces IMO, but maybe I'll get used to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was probably a macro gone overboard by me. I think I can strip out the quotes
/merge |
`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 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - James Lamb (https://github.com/jameslamb) - Bradley Dice (https://github.com/bdice) - Don Acosta (https://github.com/acostadon) - Chuck Hastings (https://github.com/ChuckHastings) - Rick Ratzel (https://github.com/rlratzel) URL: rapidsai#4954
shellcheck
is a fast, static analysis tool for shell scripts. It's good atflagging up unused variables, unintentional glob expansions, and other potential
execution and security headaches that arise from the wonders of
bash
(andother shlangs).
This PR adds a
pre-commit
hook to runshellcheck
on all of thesh-lang
files in the
ci/
directory, and the changes requested byshellcheck
to makethe existing files pass the check.
xref: rapidsai/build-planning#135