|
17 | 17 | matrix: |
18 | 18 | include: |
19 | 19 | - cmake_options: all-options-abiv1-preview |
20 | | - warning_limit: 63 |
| 20 | + warning_limit: 595 |
21 | 21 | - cmake_options: all-options-abiv2-preview |
22 | | - warning_limit: 63 |
| 22 | + warning_limit: 597 |
| 23 | + env: |
| 24 | + CC: /usr/bin/clang-18 |
| 25 | + CXX: /usr/bin/clang++-18 |
| 26 | + CXX_STANDARD: '14' # Run clang-tidy on the minimum supported c++ standard |
23 | 27 | steps: |
24 | 28 | - name: Harden the runner (Audit all outbound calls) |
25 | 29 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 |
@@ -53,52 +57,64 @@ jobs: |
53 | 57 | run: | |
54 | 58 | sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml" |
55 | 59 |
|
56 | | - - name: Check clang-tidy |
| 60 | + - name: Install clang-tidy-20 |
57 | 61 | run: | |
58 | | - if ! command -v clang-tidy &> /dev/null; then |
59 | | - echo "clang-tidy could not be found" |
60 | | - exit 1 |
61 | | - fi |
| 62 | + sudo apt install -y clang-tidy-20 |
| 63 | + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200 |
| 64 | + sudo update-alternatives --config clang-tidy |
62 | 65 | echo "Using clang-tidy version: $(clang-tidy --version)" |
63 | 66 | echo "clang-tidy installed at: $(which clang-tidy)" |
64 | 67 |
|
65 | | - - name: Prepare CMake |
| 68 | + - name: Build and run clang-tidy |
| 69 | + id: build |
66 | 70 | env: |
67 | | - CC: clang |
68 | | - CXX: clang++ |
| 71 | + OTELCPP_CMAKE_CACHE_FILE: ${{ matrix.cmake_options }}.cmake |
| 72 | + BUILD_DIR: build-${{ matrix.cmake_options }} |
69 | 73 | run: | |
70 | | - echo "Running cmake..." |
71 | | - cmake -B build-${{ matrix.cmake_options }} \ |
72 | | - -C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \ |
73 | | - -DCMAKE_CXX_STANDARD=14 \ |
74 | | - -DWITH_STL=CXX14 \ |
75 | | - -DWITH_OPENTRACING=OFF \ |
76 | | - -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \ |
77 | | - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
78 | | - -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--quiet;-p;build-${{ matrix.cmake_options }}" |
| 74 | + ./ci/do_ci.sh cmake.clang_tidy.test |
| 75 | + echo "build_log=${BUILD_DIR}/opentelemetry-cpp-clang-tidy.log" >> "$GITHUB_OUTPUT" |
79 | 76 |
|
80 | | - - name: Run clang-tidy |
| 77 | + - name: Analyze clang-tidy output |
| 78 | + id: analyze |
81 | 79 | run: | |
82 | | - cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) 2>&1 | tee clang-tidy-${{ matrix.cmake_options }}.log |
| 80 | + SCRIPT_OUTPUT=$(python3 ./ci/create_clang_tidy_report.py \ |
| 81 | + --build_log ${{ steps.build.outputs.build_log }} \ |
| 82 | + --output ./clang_tidy_report-${{ matrix.cmake_options }}.md) |
| 83 | + export $SCRIPT_OUTPUT |
| 84 | + echo "Found $TOTAL_WARNINGS unique warnings" |
| 85 | + echo "clang-tidy report generated at $REPORT_PATH" |
| 86 | + echo "warning_count=$TOTAL_WARNINGS" >> "$GITHUB_OUTPUT" |
| 87 | + echo "report_path=$REPORT_PATH" >> "$GITHUB_OUTPUT" |
| 88 | + cat $REPORT_PATH >> $GITHUB_STEP_SUMMARY |
83 | 89 |
|
| 90 | +<<<<<<< HEAD |
84 | 91 | - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 92 | +======= |
| 93 | + - name: Upload build log |
| 94 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 95 | +>>>>>>> 5fc4707a8b7820f6bdbc782ccdffac7ccafbe80d |
85 | 96 | with: |
86 | 97 | name: Logs-clang-tidy-${{ matrix.cmake_options }} |
87 | | - path: ./clang-tidy-${{ matrix.cmake_options }}.log |
| 98 | + path: ${{ steps.build.outputs.build_log }} |
| 99 | + |
| 100 | + - name: Upload warning report |
| 101 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 102 | + with: |
| 103 | + name: Report-clang-tidy-${{ matrix.cmake_options }} |
| 104 | + path: ${{ steps.analyze.outputs.report_path }} |
88 | 105 |
|
89 | | - - name: Count warnings |
| 106 | + - name: Check Warning Limits |
90 | 107 | run: | |
91 | | - COUNT=$(grep -c "warning:" clang-tidy-${{ matrix.cmake_options }}.log) |
92 | | - echo "clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'" |
| 108 | + readonly COUNT="${{ steps.analyze.outputs.warning_count }}" |
| 109 | + readonly LIMIT="${{ matrix.warning_limit }}" |
93 | 110 |
|
94 | | - readonly WARNING_LIMIT=${{ matrix.warning_limit }} |
| 111 | + echo "clang-tidy reported ${COUNT} unique warning(s) with preset '${{ matrix.cmake_options }}'" |
| 112 | + echo "Limit is ${LIMIT}" |
95 | 113 |
|
96 | | - # FAIL the build if COUNT > WARNING_LIMIT |
97 | | - if [ $COUNT -gt $WARNING_LIMIT ] ; then |
98 | | - echo "clang-tidy reported ${COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'" |
| 114 | + if [ "$COUNT" -gt "$LIMIT" ]; then |
| 115 | + echo "::error::clang-tidy reported ${COUNT} warning(s) exceeding the limit of ${LIMIT}" |
99 | 116 | exit 1 |
100 | | - # WARN in annotations if COUNT > 0 |
101 | | - elif [ $COUNT -gt 0 ] ; then |
102 | | - echo "::warning::clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'" |
| 117 | + elif [ "$COUNT" -gt 0 ]; then |
| 118 | + echo "::warning::clang-tidy reported ${COUNT} warning(s) within the limit of ${LIMIT}" |
103 | 119 | fi |
104 | 120 |
|
0 commit comments