-
Notifications
You must be signed in to change notification settings - Fork 548
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
Add shellcheck to pre-commit and fix warnings #6246
base: branch-25.02
Are you sure you want to change the base?
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.
lgtm, nice improvement!
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.
Overall I support this! But left one question and one suggestion.
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.
Why not run this on all shell scripts in the repo?
I especially would love to have this coverage on build.sh
(at the repo root), as that's a public interface into building the components of this project. It's be nice to have shellcheck
catch issues in changes there.
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.
Yeah, build.sh
coverage is definitely on my list -- I wanted to start with ci
scripts to get shellcheck
in place, then we can start to expand coverage to other shell scripts in the repository.
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.
ok just wanted to be sure I understood the reasoning. As long as we'll come back again and do the rest, that's fine.
ci/run_cuml_integration_pytests.sh
Outdated
|
||
# Support invoking run_cuml_singlegpu_pytests.sh outside the script directory | ||
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuml/cuml/tests | ||
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuml/cuml/tests || exit |
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.
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuml/cuml/tests || exit | |
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuml/cuml/tests || exit 1 |
The ||
half of this will only be reached if the path doesn't exist. In that case, I think we want a non-0 exit code, so this fails loudly. Otherwise, we risk silently not running any tests in CI until someone notices.
A bare exit
returns exit code 0.
cat > ./out.sh <<EOF
exit
EOF
bash ./out.sh
echo $?
# 0
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.
yeah, that's a very good point and suggestion
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 put that suggestion on just this line to show the point, but there are other || exit
in the diff that I think should be || exit 1
, can you update those as well?
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.
Updated
Co-authored-by: James Lamb <[email protected]>
Description
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