-
Notifications
You must be signed in to change notification settings - Fork 902
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
[FEA] Make CMake style check used in CI easy to run locally #9396
Comments
I could be wrong, but while I see runs of Both clang-format and all of the linters that we use for cuDF Python (black, isort, flake8) are currently configured to work with pre-commit as well as by running them directly (and in clang-format's case, using the |
I prefer format-on-save and automatic in-IDE linter plugins (e.g. clangd). Precommit only lints when I commit, which is not frequently enough IMO. |
Got it, but isn't that significantly different from the original issue request? The |
Yeah, I wasn't asking for save-on-format because I don't know if that plugin is available for my editor (vscode). What I'm asking for is to make it easy to reproduce CI failures locally and exactly. As I understand it, this is pretty easy to do, we just have to include the cmake format configuration in the repo, or make the script download it when run. |
For more clarity (after talking to Vyas offline), in this issue I'm purely asking for the prerequisites to run cmake-format locally. Specifically, that means that the Now as I'm typing this, I'm noticing that that file is installed into |
Yes for developers the requisite files will exist once a build directory exists. CI runs the formatting pass without generating a build directory and therefore needs to fetch the file from the internet explicitly. |
OK. In spite of this, a developer has to run cmake-format (and cmake-lint) on each CMakeLists.txt in the repo, and the commands are not short, e.g. the following for each file.
So I think we should provide a script for this in the repo, or a way to do it with pre-commit (which I only just learned about from @vyasr yesterday). |
This PR resolves #9396, making it easy to run `cmake-format` and `cmake-lint` on CMake files in cudf using pre-commit. The one additional complexity associated with these hooks compared to our other pre-commit hooks is the need for the `cmake-format-rapids-cmake.json` configuration file that is maintained in [rapids-cmake](https://github.com/rapidsai/rapids-cmake) and is only added during the build process. We don't want pre-commit to fail outright when the file isn't present, so this PR introduces a custom script wrapping the `cmake-format` and `cmake-lint` hooks in a check for the presence of the file. The script respects an associated environment variable that advanced users can exploit if they store this file in a nonstandard location. Once this PR is finalized I'll make a follow-up PR that actually applies the formatting to our existing CMake. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Robert Maynard (https://github.com/robertmaynard) URL: #9484
Is your feature request related to a problem? Please describe.
It's easy for developers to run the C++ and Python linters that get run in CI locally. I would like the same to be true of cmake style. Right now, fixing cmake style errors is an iterative process of looking at CI output, fixing locally, pushing, and then seeing more errors in the CI check and repeating.
Describe the solution you'd like
Include a shell script in the repo for running cmake style checks, like we have with
run-clang-format.sh
.Additional context
I ran into this working on RMM, but it applies to cuDF and other repos as well, so I filed it here for visibility.
CC @robertmaynard
The text was updated successfully, but these errors were encountered: