[CI] upgrade to clang-tidy 20 #3111
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: clang-tidy | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| clang-tidy: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - cmake_options: all-options-abiv1-preview | |
| warning_limit: 63 | |
| - cmake_options: all-options-abiv2-preview | |
| warning_limit: 63 | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| submodules: recursive | |
| - name: Setup Environment | |
| run: | | |
| sudo apt update -y | |
| sudo apt install -y --no-install-recommends --no-install-suggests \ | |
| build-essential \ | |
| cmake \ | |
| zlib1g-dev \ | |
| libssl-dev \ | |
| libcurl4-openssl-dev \ | |
| nlohmann-json3-dev \ | |
| libabsl-dev \ | |
| libprotobuf-dev \ | |
| libgrpc++-dev \ | |
| protobuf-compiler \ | |
| protobuf-compiler-grpc \ | |
| libgmock-dev \ | |
| libgtest-dev \ | |
| libbenchmark-dev | |
| - name: Install rapidyaml | |
| run: | | |
| sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml" | |
| - name: Install clang-tidy-20 | |
| run: | | |
| sudo apt install -y clang-tidy-20 | |
| sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200 | |
| sudo update-alternatives --config clang-tidy | |
| echo "Using clang-tidy version: $(clang-tidy --version)" | |
| echo "clang-tidy installed at: $(which clang-tidy)" | |
| # Note - if the --header-filter or --exclude-header-filter are modified please also modify the ci/do_ci.sh cmake.clang_tidy command to match | |
| - name: Prepare CMake | |
| env: | |
| CC: clang | |
| CXX: clang++ | |
| run: | | |
| echo "Running cmake..." | |
| cmake \ | |
| -S . \ | |
| -B build-${{ matrix.cmake_options }} \ | |
| -C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \ | |
| -DCMAKE_CXX_STANDARD=14 \ | |
| -DWITH_STL=CXX14 \ | |
| -DWITH_OPENTRACING=OFF \ | |
| -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--header-filter=.*/opentelemetry-cpp/.*;--exclude-header-filter=.*(internal/absl|third_party|third-party|/usr/|/opt/|.*\.pb\.h|.*\.pb\.cc)/.*;--quiet" | |
| - name: Run clang-tidy and Build | |
| id: build | |
| run: | | |
| BUILD_LOG=clang-tidy-${{ matrix.cmake_options }}.log | |
| set -o pipefail | |
| cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) 2>&1 | tee $BUILD_LOG | |
| echo "build_log=$BUILD_LOG" >> "$GITHUB_OUTPUT" | |
| - name: Analyze clang-tidy build log | |
| id: analyze | |
| run: | | |
| SCRIPT_OUTPUT=$(python3 ./ci/create_clang_tidy_report.py \ | |
| --job_name ${{ matrix.cmake_options }} \ | |
| --build_log clang-tidy-${{ matrix.cmake_options }}.log \ | |
| --output ./clang_tidy_report-${{ matrix.cmake_options }}.md) | |
| export $SCRIPT_OUTPUT | |
| echo "Found $TOTAL_WARNINGS unique warnings" | |
| echo "clang-tidy report generated at $REPORT_PATH" | |
| echo "warning_count=$TOTAL_WARNINGS" >> "$GITHUB_OUTPUT" | |
| echo "report_path=$REPORT_PATH" >> "$GITHUB_OUTPUT" | |
| cat $REPORT_PATH >> $GITHUB_STEP_SUMMARY | |
| - name: Upload build log | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: Logs-clang-tidy-${{ matrix.cmake_options }} | |
| path: ${{ steps.build.outputs.build_log }} | |
| - name: Upload warning report | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: Report-clang-tidy-${{ matrix.cmake_options }} | |
| path: ${{ steps.analyze.outputs.report_path }} | |
| - name: Check Warning Limits | |
| run: | | |
| readonly COUNT="${{ steps.analyze.outputs.warning_count }}" | |
| readonly LIMIT="${{ matrix.warning_limit }}" | |
| echo "clang-tidy reported ${COUNT} unique warning(s) with preset '${{ matrix.cmake_options }}'" | |
| echo "Limit is ${LIMIT}" | |
| if [ "$COUNT" -gt "$LIMIT" ]; then | |
| echo "::error::clang-tidy reported ${COUNT} warning(s) exceeding the limit of ${LIMIT}" | |
| exit 1 | |
| elif [ "$COUNT" -gt 0 ]; then | |
| echo "::warning::clang-tidy reported ${COUNT} warning(s) within the limit of ${LIMIT}" | |
| fi | |