clang-tidy.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: clang-tidy
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. permissions:
  8. contents: read
  9. jobs:
  10. clang-tidy:
  11. runs-on: ubuntu-24.04
  12. steps:
  13. - name: Harden the runner (Audit all outbound calls)
  14. uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
  15. with:
  16. egress-policy: audit
  17. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  18. with:
  19. submodules: recursive
  20. - name: Setup Environment
  21. env:
  22. PROTOBUF_VERSION: '23.3'
  23. ABSEIL_CPP_VERSION: '20230125.3'
  24. CXX_STANDARD: '14'
  25. run: |
  26. sudo apt update -y
  27. sudo apt install -y --no-install-recommends --no-install-suggests \
  28. build-essential \
  29. iwyu \
  30. cmake \
  31. libssl-dev \
  32. libcurl4-openssl-dev \
  33. libprotobuf-dev \
  34. protobuf-compiler \
  35. libgmock-dev \
  36. libgtest-dev \
  37. libbenchmark-dev
  38. if ! command -v clang-tidy &> /dev/null; then
  39. echo "clang-tidy could not be found"
  40. exit 1
  41. fi
  42. echo "Using clang-tidy version: $(clang-tidy --version)"
  43. echo "clang-tidy installed at: $(which clang-tidy)"
  44. - name: Prepare CMake
  45. env:
  46. CC: clang
  47. CXX: clang++
  48. run: |
  49. echo "Running cmake..."
  50. cmake -B build \
  51. -DCMAKE_CXX_STANDARD=14 \
  52. -DWITH_STL=CXX14 \
  53. -DWITH_OTLP_HTTP=ON \
  54. -DWITH_OTLP_FILE=ON \
  55. -DWITH_PROMETHEUS=ON \
  56. -DWITH_ZIPKIN=ON \
  57. -DWITH_ELASTICSEARCH=ON \
  58. -DWITH_OTLP_HTTP_COMPRESSION=ON \
  59. -DWITH_EXAMPLES=ON \
  60. -DWITH_EXAMPLES_HTTP=ON \
  61. -DBUILD_W3CTRACECONTEXT_TEST=ON \
  62. -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
  63. -DWITH_ASYNC_EXPORT_PREVIEW=ON \
  64. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
  65. - name: Run clang-tidy
  66. run: |
  67. cmake --build build --target opentelemetry_proto
  68. jq -r .[].file build/compile_commands.json | grep -vE '/(generated|third_party)/' | xargs -P $(nproc) -n 1 clang-tidy --quiet -p build 2>&1 | tee -a clang-tidy.log
  69. - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  70. with:
  71. name: Logs (clang-tidy)
  72. path: ./clang-tidy.log
  73. - name: Count warnings
  74. run: |
  75. COUNT=$(grep -c "warning:" clang-tidy.log)
  76. echo "clang-tidy reported ${COUNT} warning(s)"
  77. # TODO: include WITH_OTLP_GRPC flags.