@@ -226,6 +226,7 @@ jobs:
226226 echo "PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}" | tee -a "${GITHUB_ENV}"
227227 echo "UV_INDEX=${UV_INDEX}" | tee -a "${GITHUB_ENV}"
228228 fi
229+
229230 export CLANG_TIDY_CMAKE_OPTIONS="${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_METAL=ON"
230231
231232 echo "USE_METAL=ON" | tee -a "${GITHUB_ENV}"
@@ -289,21 +290,33 @@ jobs:
289290
290291 - name : Run clang-tidy
291292 id : clang-tidy
293+ if : runner.os == 'Linux'
292294 run : |
293- clang-tidy --version
295+ echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version
296+
297+ if [[ -x "$(command -v run-clang-tidy)" ]]; then
298+ echo "Using run-clang-tidy from $(command -v run-clang-tidy)"
299+ CLANG_TIDY=(run-clang-tidy)
300+ else
301+ echo "Downloading run-clang-tidy script"
302+ wget -O run-clang-tidy.py https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
303+ CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py)
304+ fi
305+ if [[ -x "$(command -v clang-apply-replacements)" ]]; then
306+ echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)"
307+ CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)")
308+ else
309+ echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled."
310+ fi
294311
295312 # Run cmake to create the build directory with compile_commands.json
296313 cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here
297314
298315 CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h")
299316 rc=0
300- if [[ -x "$(command -v run-clang-tidy)" ]]; then
301- run-clang-tidy -clang-tidy-binary="$(command -v clang-tidy)" \
302- -fix -p="cmake-build" ${CXX_FILES} || rc="$?"
303- else
304- clang-tidy --fix -p="cmake-build" ${CXX_FILES} || rc="$?"
305- fi
306- rm -rf cmake-build
317+ "${CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \
318+ -p="cmake-build" ${CXX_FILES} || rc="$?"
319+ rm -rf cmake-build run-clang-tidy.py
307320 if (( rc != 0 )); then
308321 echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them."
309322 git diff --color=always || true
0 commit comments