feat(ci): integrate clang-tidy for changed C/C++ files#116
feat(ci): integrate clang-tidy for changed C/C++ files#116kgeg401 wants to merge 21 commits intoalibaba:mainfrom
Conversation
432cf4a to
25d39a7
Compare
25d39a7 to
f5aedce
Compare
|
Cleaned up PR scope and hardened clang-tidy workflow:\n\n- Removed unrelated FP16 test changes from this PR (keeps overlap out of #116).\n- Kept this PR scoped to .clang-tidy, workflow, and CI plumbing files only.\n- Updated workflow to run clang-tidy only on changed source files that exist in compile_commands.json, with explicit skipped-file reporting and non-failing no-op behavior when no analyzable files are present. |
|
This PR is now strictly scoped to .clang-tidy, the clang-tidy workflow, and related CI plumbing. No further code changes in this pass; it is ready for review when bandwidth allows. |
|
@greptile |
|
Thanks @kgeg401 for a pretty good start. |
|
resolve #295 |
Summary
Notes
Fixes #295
Greptile Summary
This PR adds a clang-tidy CI integration for the
zvecrepository: a new.clang-tidyconfiguration file, a GitHub Actions workflow (.github/workflows/clang_tidy.yml) that runs on C/C++ and CMake changes, and a.gitignoreupdate to allow tracking.clang-tidy. The approach — running CMake to producecompile_commands.json, then runningclang-tidyonly on changed files that appear in that database — is sound and well-structured. However, there are two issues that need to be addressed before this is safe and fully functional:.github/workflows/clang_tidy.yml, line 83): The changed-files list is interpolated directly into the Python triple-quoted string inside the heredoc. A PR author could trigger Python code execution by including a file whose path contains""". The file list should be passed via an environment variable instead.HeaderFilterRegexanchoring (.clang-tidy, line 9): The regex^(src|tests|tools)/is anchored to the start of the string but clang-tidy evaluates it against the full absolute path (e.g./home/runner/work/zvec/zvec/src/foo.h). The anchor prevents any project header from matching, silently disabling all header-level diagnostics. The pattern should be changed to.*(src|tests|tools)/.*."CMakeLists.txt"in bothpushandpull_requestpath blocks is already covered by"**/CMakeLists.txt".tj-actions/changed-files@v46should be pinned to a commit SHA to prevent supply-chain risk.Confidence Score: 3/5
.github/workflows/clang_tidy.yml(template injection, line 83) and.clang-tidy(HeaderFilterRegex, line 9) need the most attention.Important Files Changed
.clang-tidyto be tracked, consistent with the existing pattern for.clang-format; no issues found.Sequence Diagram
sequenceDiagram participant GH as GitHub Event (push/PR) participant WF as clang_tidy.yml participant TJ as tj-actions/changed-files@v46 participant PY as Python Filter Script participant CT as clang-tidy GH->>WF: Trigger on C/C++, CMake, or .clang-tidy change WF->>WF: actions/checkout@v4 (submodules: recursive) WF->>WF: apt-get install clang-tidy cmake ninja-build WF->>WF: cmake -S . -B build (exports compile_commands.json) WF->>TJ: Collect changed *.c / *.cc / *.cpp / *.cxx files TJ-->>WF: all_changed_files (newline-separated) WF->>PY: Interpolate file list into Python heredoc PY->>PY: Cross-reference with build/compile_commands.json PY-->>WF: any_tidy_files, all_tidy_files, skipped_files WF->>WF: Show skipped files (if any) WF->>CT: clang-tidy -p build --warnings-as-errors='*' <file> CT-->>WF: Pass / Fail (fail = CI blocked)Last reviewed commit: 30343b3