[GPU] Enable clang-tidy for Intel GPU plugin#36570
Conversation
Add .clang-tidy config enabling only modernize-use-override, wire the GPU targets (runtime, kernels, graph, plugin) into the existing ov_apply_clang_tidy/ADD_CLANG_TIDY flow, and apply the resulting override fixes across the plugin. Add a Build-GPU clang-tidy CI job and refactor the shared build steps into a clang_tidy_build composite action.
Set WarningsAsErrors to '*' in the GPU .clang-tidy so future checks added to the Checks list are enforced without editing the field, matching the CPU plugin config. Normalize the copyright headers of two touched kernel_selector files to the SPDX format required by the copyright_check CI.
Apply ov_apply_clang_tidy inside ov_gpu_add_backend_target so the per-backend OBJECT libraries (common, cpu, ocl, ocl_v2, onednn, sycl, cm) are analyzed; the openvino_intel_gpu_graph STATIC lib excludes those sources, so they were previously unlinted. This raises clang-tidy coverage of the plugin build from 793 to 962 sources. Restrict HeaderFilterRegex to first-party include/src/tests headers and drop the non-existent src/tests/functional/plugin/gpu path, so thirdparty headers are no longer diagnosed. Thread openvino-repo/build-dir inputs into the clang_tidy_build action calls so the job-level env stays authoritative instead of relying on the action defaults.
|
@isanghao , FYI |
… GPU job Rename the clang-tidy build jobs to a consistent Build-<target> scheme: Build -> Build-x86_64 and Build-GPU -> Build-gpu (Build-aarch64 and Build-riscv64 already match), and update Overall_Status.needs. Temporarily drop --quiet from the GPU job to confirm in CI logs that clang-tidy actually runs over intel_gpu sources; --quiet will be restored in a follow-up commit.
Revert the temporary verbose build flag used to verify in CI that clang-tidy runs over intel_gpu sources. The verbose run confirmed 775 intel_gpu objects (incl. 169 graph/impls) are freshly compiled by the Build-gpu target; restore '--quiet -k 0' to match the other jobs.
3d74f80 to
c38789f
Compare
| @@ -0,0 +1,89 @@ | |||
| name: 'Clang-tidy build' | |||
There was a problem hiding this comment.
Typically we add builds as re-usable workflows, not as composite actions... Was there any particular reason to choose a composite action?
There was a problem hiding this comment.
This is step-level reuse, not job-level.
The four jobs (Build-x86_64/aarch64/riscv64/gpu) differ only in runs-on, container and env, but share the same step sequence:
sccache setup -> checkout -> cmake configure -> build -> upload compile_commands.json -> sccache stats
A composite action lets each job keep its own runner/container/env and inject only the deltas via inputs (build-target, cmake-extra-args, build-extra-args, compile-commands-artifact).
A workflow_call would pull the runner labels and container definition behind the reusable-workflow boundary and re-expose them as inputs — more indirection for the same result. Composite actions also can't set runs-on/container, so those stay declarative in the caller, which is what we want here.
Can switch to a reusable job_clang_tidy.yml if you'd rather keep it uniform with the rest of CI.
| WarningsAsErrors: '*' | ||
| # Use clang-format for applied fixes. | ||
| FormatStyle: file | ||
| HeaderFilterRegex: "src/plugins/intel_gpu/(include|src|tests)/.*\\.(h|hpp)$" |
There was a problem hiding this comment.
We shouldn't probably enable tidy for tests (as I can see in other components, this is a common practice), otherwise we may spend significant resources on tests refactoring during new tidy checks adding
…-bootstrap # Conflicts: # .github/workflows/clang_tidy.yml
Drop the 'tests' path from the header filter so clang-tidy only covers include/ and src/, matching the common practice in other components (e.g. intel_cpu). This avoids spending resources on test refactoring when new checks are enabled.
The clang-tidy CI job builds with -DENABLE_TESTS=OFF and the tests path is excluded from HeaderFilterRegex, so test sources are not checked. Leave them untouched instead of carrying override edits that clang-tidy does not enforce.
Document the two entry points: ov_add_plugin's ADD_CLANG_TIDY option for the plugin target, and direct ov_apply_clang_tidy() calls for the static/object libraries that are not created via ov_add_plugin.
Bootstrap clang-tidy for the Intel GPU plugin with a single check: modernize-use-override.