From d47a1904ad7094c20683aa9e221b21d392b4fe89 Mon Sep 17 00:00:00 2001 From: Rello Date: Mon, 31 Aug 2026 13:21:09 +0200 Subject: [PATCH] fix(ci): reuse Clang build for clang-tidy Export compile commands from the existing Linux Clang build, then run the changed-line clang-tidy analysis after its test suite. Remove the standalone workflow that rebuilt the same source tree. Signed-off-by: Rello Assisted-by: Codex:GPT-5 --- .github/workflows/clang-tidy-review.yml | 44 ------------------- .../workflows/linux-clang-compile-tests.yml | 19 +++++++- 2 files changed, 17 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/clang-tidy-review.yml diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml deleted file mode 100644 index 34c28b254079b..0000000000000 --- a/.github/workflows/clang-tidy-review.yml +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors -# SPDX-License-Identifier: GPL-2.0-or-later -name: clang-tidy-review - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - clang-tidy: - runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-sid-6.10.2-2 - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - fetch-depth: 2 - - name: Prepare compile_commands.json - run: | - cmake -G Ninja -B build -DQT_MAJOR_VERSION=6 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 - cd build && ninja - - name: Create results directory - run: | - mkdir clang-tidy-result - - name: Analyze - run: | - /usr/bin/git config --global --add safe.directory "$GITHUB_WORKSPACE" - # Header-only test helper: clang-tidy-diff has no target compile command for it. - # Its consumer test targets compile it with the required GUI include paths. - /usr/bin/git diff -U0 HEAD^ -- ':(exclude)test/macOS/*' ':(exclude)test/systraysynccontroltesthelper.h' ':(exclude)*macOS*' | clang-tidy-diff-21.py -checks='-*,modernize-use-auto,modernize-use-using,modernize-use-nodiscard,modernize-use-nullptr,modernize-use-override,cppcoreguidelines-pro-type-static-cast-downcast' -p1 -path build -regex '^(?!.*/macOS/)(?!.*/MacOSX/).*\.(cpp|cc|cxx|c|h|hpp|hxx)$' -export-fixes clang-tidy-result/fixes.yml - - name: Run clang-tidy-pr-comments action - uses: platisd/clang-tidy-pr-comments@28cfb84edafa771c044bde7e4a2a3fae57463818 # v1.6.1 # >1.4.3 switches to composite method w/ a forced python version and breaks things: https://github.com/actions/setup-python/issues/871 - with: - python_path: "/usr/bin/python3" - # The GitHub token (or a personal access token) - github_token: ${{ secrets.GITHUB_TOKEN }} - # The path to the clang-tidy fixes generated previously - clang_tidy_fixes: clang-tidy-result/fixes.yml - # Optionally set to true if you want the Action to request - # changes in case warnings are found - request_changes: true - # Optionally set the number of comments per review - # to avoid GitHub API timeouts for heavily loaded - # pull requests - suggestions_per_comment: 10 diff --git a/.github/workflows/linux-clang-compile-tests.yml b/.github/workflows/linux-clang-compile-tests.yml index 613522f2f5a5a..0d21a23e4315f 100644 --- a/.github/workflows/linux-clang-compile-tests.yml +++ b/.github/workflows/linux-clang-compile-tests.yml @@ -12,12 +12,12 @@ jobs: steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: - fetch-depth: 1 + fetch-depth: 2 - name: Configure and compile run: | mkdir build cd build - cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror + cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ninja - name: Run tests run: | @@ -25,3 +25,18 @@ jobs: useradd -m -s /bin/bash test chown -R test:test . su -c 'xvfb-run ctest --output-on-failure' test + - name: Analyze changed C++ code with clang-tidy + run: | + mkdir clang-tidy-result + /usr/bin/git config --global --add safe.directory "$GITHUB_WORKSPACE" + # Header-only test helper: clang-tidy-diff has no target compile command for it. + # Its consumer test targets compile it with the required GUI include paths. + /usr/bin/git diff -U0 HEAD^ -- ':(exclude)test/macOS/*' ':(exclude)test/systraysynccontroltesthelper.h' ':(exclude)*macOS*' | clang-tidy-diff-21.py -checks='-*,modernize-use-auto,modernize-use-using,modernize-use-nodiscard,modernize-use-nullptr,modernize-use-override,cppcoreguidelines-pro-type-static-cast-downcast' -p1 -path build -regex '^(?!.*/macOS/)(?!.*/MacOSX/).*\.(cpp|cc|cxx|c|h|hpp|hxx)$' -export-fixes clang-tidy-result/fixes.yml + - name: Publish clang-tidy review + uses: platisd/clang-tidy-pr-comments@28cfb84edafa771c044bde7e4a2a3fae57463818 # v1.6.1 # >1.4.3 switches to composite method w/ a forced python version and breaks things: https://github.com/actions/setup-python/issues/871 + with: + python_path: "/usr/bin/python3" + github_token: ${{ secrets.GITHUB_TOKEN }} + clang_tidy_fixes: clang-tidy-result/fixes.yml + request_changes: true + suggestions_per_comment: 10