Skip to content
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

CI: Add custom GitHub Actions job to run clang-tidy #5235

Merged

Conversation

csadorf
Copy link
Contributor

@csadorf csadorf commented Feb 14, 2023

Follow-up from #4983 ; should be merged after that.

@csadorf csadorf added feature request New feature or request non-breaking Non-breaking change labels Feb 14, 2023
@csadorf csadorf changed the title Ci: Addd custom GitHub Actions job to run clang tidy Ci: Addd custom GitHub Actions job to run clang-tidy Feb 14, 2023
@csadorf csadorf changed the title Ci: Addd custom GitHub Actions job to run clang-tidy CI: Addd custom GitHub Actions job to run clang-tidy Feb 14, 2023
@csadorf csadorf self-assigned this Feb 14, 2023
ci/run_clang_tidy.sh Outdated Show resolved Hide resolved
@csadorf csadorf changed the title CI: Addd custom GitHub Actions job to run clang-tidy CI: Ad custom GitHub Actions job to run clang-tidy Feb 14, 2023
@csadorf csadorf changed the title CI: Ad custom GitHub Actions job to run clang-tidy CI: Add custom GitHub Actions job to run clang-tidy Feb 14, 2023
@bdice
Copy link
Contributor

bdice commented Feb 16, 2023

Hmm. I tried adding cudatoolkit to fix this problem, but to no avail. I wonder if we need to do something with include paths? I also tried adding gcc_linux-64 to make sure <omp.h> is found. We'll see. FYI @csadorf, I won't be able to look at this for about another week.

---------------- File:/__w/cuml/cuml/cpp/test/c_api/svm_api_test.c FAILED ----------------
CMD: clang-tidy -header-filter='.*cuml/cpp/(src|include|bench|comms).*' /__w/cuml/cuml/cpp/test/c_api/svm_api_test.c -- clang++ -DCUTLASS_NAMESPACE=raft_cutlass -DDISABLE_CUSPARSE_DEPRECATED -DFMT_HEADER_ONLY=1 -DFMT_SHARED -DRAFT_DISTANCE_COMPILED -DRAFT_NN_COMPILED -DRAFT_SYSTEM_LITTLE_ENDIAN=1 -DSPDLOG_FMT_EXTERNAL -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -Dcuml_test_EXPORTS -I/__w/cuml/cuml/cpp/include -I/opt/conda/envs/clang_tidy/include/rapids -I/opt/conda/envs/clang_tidy/include/rapids/libcudacxx -isystem /opt/conda/envs/clang_tidy/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /opt/conda/envs/clang_tidy/include -O3 -DNDEBUG -fPIC -pthread -I /opt/conda/envs/clang_tidy/include/ClangHeaders /__w/cuml/cuml/cpp/test/c_api/svm_api_test.c1 error generated.
Error while processing /__w/cuml/cuml/cpp/test/c_api/svm_api_test.c.
/__w/cuml/cuml/cpp/include/cuml/cuml_api.h:21:10: error: 'cuda_runtime_api.h' file not found [clang-diagnostic-error]
#include <cuda_runtime_api.h>
         ^~~~~~~~~~~~~~~~~~~~
Found compiler error(s).
---------------- File:/__w/cuml/cuml/cpp/test/c_api/svm_api_test.c ENDS ----------------

cmake -DGPU_ARCHS=70 \
-DBLAS_LIBRARIES=${CONDA_PREFIX}/lib/libopenblas.so.0 \
..
make -j treelite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to build treelite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question for @bdice who supposed that it is likely to put some header files into place. However, I don't understand well enough how clang-tidy works to have a better explanation.

This was changed from benchmark to treelite in 52320b0 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, no, we do not actually build anything to run clang-tidy, but we do have to invoke CMake to create the compile command database. That's why I added a --nobuild option to our build script in 2c28995 . I assume that the previous targets where an attempt at reducing the build time, but I think not building anything is the better (and faster) approach.

@csadorf csadorf linked an issue Jul 3, 2023 that may be closed by this pull request
@csadorf csadorf changed the base branch from branch-23.04 to branch-23.08 July 3, 2023 19:49
@csadorf csadorf force-pushed the ci-add-custom-ga-job-to-run-clang-tidy branch 3 times, most recently from 8a94377 to d12d082 Compare July 5, 2023 23:01
@github-actions github-actions bot added the conda conda issue label Jul 6, 2023
Needed by default unless the --nolibcumltest option is provided to the
build.sh script.
@csadorf csadorf force-pushed the ci-add-custom-ga-job-to-run-clang-tidy branch from 5e44948 to ac4bb40 Compare July 10, 2023 19:33
@csadorf csadorf marked this pull request as ready for review July 11, 2023 20:21
@csadorf csadorf requested review from a team as code owners July 11, 2023 20:21
@csadorf csadorf requested review from dantegd and bdice July 11, 2023 20:24
@csadorf
Copy link
Contributor Author

csadorf commented Jul 11, 2023

Tagging @wphicks who previously expressed interest in this PR.

build.sh Outdated
@@ -46,6 +46,7 @@ HELP="$0 [<target> ...] [<flag> ...]
--codecov - Enable code coverage support by compiling with Cython linetracing
and profiling enabled (WARNING: Impacts performance)
--ccache - Use ccache to cache previous compilations
--nobuild - Invoke CMake without actually building
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another name might be --configure-only. Just a proposal, no strong feelings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I prefer --no-build over --nobuild, if we choose to keep the current name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me, too, but this was more consistent with the other option names. Regardless, I changed it to --configure-only now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages:
- clang==15.0.7
- clang-tools==15.0.7
- make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use ninja instead? Tends to be faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -239,7 +265,7 @@ def main():
if not os.path.exists(".git"):
raise Exception("This needs to always be run from the root of repo")
# Check whether clang-tidy exists
if shutil.which("clang-tidy") is not None:
if shutil.which("clang-tidy") is None:
print("clang-tidy not found. Exiting...")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe raise an exception here instead? It seems to me that a silent pass could be problematic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds fine to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@dantegd dantegd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick request

@@ -0,0 +1,22 @@
#!/bin/bash
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
# Copyright (c) 2023, NVIDIA CORPORATION.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@dantegd dantegd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to submit this comment in the prior review


rapids-logger "Run clang-tidy"

python cpp/scripts/run-clang-tidy.py -ignore '[.]cu$|_deps|examples/kmeans/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a section in https://github.com/rapidsai/cuml/blob/branch-23.08/CONTRIBUTING.md#code-formatting that quickly describes how to run this locally for devs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c4e6565 .

Copy link
Member

@ajschmidt8 ajschmidt8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving ops-codeowner file changes

Copy link
Contributor

@wphicks wphicks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice! Nothing further to add beyond what other reviewers have mentioned.

@github-actions github-actions bot added the conda conda issue label Jul 12, 2023
@csadorf csadorf requested a review from dantegd July 12, 2023 20:38
@csadorf
Copy link
Contributor Author

csadorf commented Jul 13, 2023

/merge

@rapids-bot rapids-bot bot merged commit 3e59b65 into rapidsai:branch-23.08 Jul 13, 2023
47 checks passed
@csadorf csadorf deleted the ci-add-custom-ga-job-to-run-clang-tidy branch July 13, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci conda conda issue CUDA/C++ feature request New feature or request non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] check for clang-tiny in the script run-clang-format.py
5 participants