Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add a clang-tidy build #3001

Merged
merged 32 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
091efdd
Added the CI for clang-tidy in github workflows.
msiddhu Jul 11, 2024
aeaa2be
testing
msiddhu Jul 11, 2024
337b105
testing
msiddhu Jul 11, 2024
ac8ac31
Added the CI for clang-tidy in github workflows.
msiddhu Jul 11, 2024
883598c
Added the CI for clang-tidy in github workflows.
msiddhu Jul 11, 2024
705af4f
Added the CI for clang-tidy in github workflows.
msiddhu Jul 11, 2024
42a4c7e
Trying to run CI without sh file as .sh file is not present in main.
msiddhu Jul 11, 2024
304c066
Format and remove clang installation as ubuntu24 image has it.
msiddhu Jul 11, 2024
8e8bcbd
Delete install_clang18.sh as clang18 is already included in ubuntu24 …
msiddhu Jul 11, 2024
4546b1d
markdown fix
msiddhu Jul 11, 2024
834f934
markdown fix
msiddhu Jul 11, 2024
df852b2
remove dump config.
msiddhu Jul 11, 2024
5db5c69
Resolve some comments by maintainer.
msiddhu Jul 11, 2024
e610af4
Resolve some comments by maintainer.
msiddhu Jul 11, 2024
e4b0b40
Resolve some comments by maintainer.
msiddhu Jul 11, 2024
a89117e
testing
msiddhu Jul 11, 2024
9f00e4c
testing
msiddhu Jul 11, 2024
2a450d3
testing
msiddhu Jul 11, 2024
3042338
testing
msiddhu Jul 11, 2024
154b162
testing
msiddhu Jul 11, 2024
86e166a
Merge branch 'main' into ci_clang_tidy
msiddhu Jul 12, 2024
23c4e37
Change log rewrite
msiddhu Jul 14, 2024
2233338
Removed TOPDIR
msiddhu Jul 14, 2024
516ea26
Added back multithreading make
msiddhu Jul 15, 2024
5c540cf
changes regex to exclude the opentelemetry proto
msiddhu Jul 15, 2024
952d309
Negative regex with third party
msiddhu Jul 15, 2024
0d70409
Merge branch 'main' into ci_clang_tidy
msiddhu Jul 15, 2024
f3278f2
Made changes to cmake file to exclude clang-tidy to parse warnings fr…
msiddhu Jul 16, 2024
d04b21f
Fixed opentracing=ON flag.
msiddhu Jul 16, 2024
629fbdc
changed some configs
msiddhu Jul 16, 2024
d76751f
Added missing comma
msiddhu Jul 16, 2024
ba3a6d8
Merge branch 'main' into ci_clang_tidy
marcalff Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 9 additions & 39 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Checks: >
-*,
performance-*,
portability-*,
abseil-*,
-abseil-string-find-str-contains,
bugprone-*,
Expand All @@ -13,7 +15,6 @@ Checks: >
-bugprone-unchecked-optional-access,
-bugprone-unhandled-exception-at-new,
-bugprone-unused-local-non-trivial-variable,
-bugprone-unused-return-value,
google-*,
-google-build-using-namespace,
-google-default-arguments,
Expand All @@ -29,41 +30,10 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-misc-unused-alias-decls,
-misc-use-anonymous-namespace,
performance-*,
-performance-move-const-arg,
portability-*
# readability-*,
# -readability-convert-member-functions-to-static,
# -readability-else-after-return,
# -readability-function-cognitive-complexity,
# -readability-identifier-length,
# -readability-implicit-bool-conversion,
# -readability-isolate-declaration,
# -readability-magic-numbers,
# -readability-named-parameter,
# -readability-redundant-*,
# -readability-string-compare,
# cppcoreguidelines-*,
# -cppcoreguidelines-avoid-c-arrays,
# -cppcoreguidelines-avoid-magic-numbers,
# -cppcoreguidelines-init-variables,
# -cppcoreguidelines-macro-usage,
# -cppcoreguidelines-non-private-member-variables-in-classes,
# -cppcoreguidelines-pro-*,
# modernize-*,
# -modernize-use-default-member-init,
# -modernize-use-nodiscard,
# -modernize-use-trailing-return-type,
# -modernize-avoid-c-arrays,
# -modernize-use-using

# Use existing clang-format for formatting the code
# FormatStyle: 'file'

# TODO: include checks: readability, cppcoreguidelines, modernize , google-readability-namespace-comments, google-readability-avoid-underscore-in-googletest-name, performance-move-const-arg






cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-*
84 changes: 84 additions & 0 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: clang-tidy

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
clang-tidy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Environment
env:
PROTOBUF_VERSION: '23.3'
ABSEIL_CPP_VERSION: '20230125.3'
CXX_STANDARD: '14'
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends --no-install-suggests \
build-essential \
iwyu \
cmake \
libssl-dev \
libcurl4-openssl-dev \
libprotobuf-dev \
protobuf-compiler \
libgmock-dev \
libgtest-dev \
libbenchmark-dev

if ! command -v clang-tidy &> /dev/null; then
echo "clang-tidy could not be found"
exit 1
fi
echo "Using clang-tidy version: $(clang-tidy --version)"
echo "clang-tidy installed at: $(which clang-tidy)"


- name: Prepare CMake
env:
CC: clang
CXX: clang++
run: |
mkdir -p build && cd build
echo "Running cmake..."
cmake .. \
-DCMAKE_CXX_STANDARD=14 \
-DWITH_STL=CXX14 \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_PROMETHEUS=ON \
-DWITH_ZIPKIN=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_EXAMPLES=ON \
-DWITH_EXAMPLES_HTTP=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy"

- name: Run clang-tidy
run: |
cd build
make -j$(nproc) 2>&1 | tee -a clang-tidy.log || exit 1

- uses: actions/upload-artifact@v4
with:
name: Logs (clang-tidy)
path: ./build/clang-tidy.log

- name: Count warnings
run: |
cd build
COUNT=$(grep -c "warning:" clang-tidy.log)
echo "clang-tidy reported ${COUNT} warning(s)"

# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Increment the:

## [Unreleased]

* [CI] Add a clang-tidy build
[#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001)

## [1.16.1 2024-07-17]

* [BUILD] Add bazel missing BUILD file
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,12 @@ if(WITH_PROMETHEUS)
message(STATUS "Trying to use local prometheus-cpp from submodule")
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
set(ENABLE_TESTING OFF)
set(CMAKE_CXX_CLANG_TIDY "")
add_subdirectory(third_party/prometheus-cpp)
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY})
else()
message(
FATAL_ERROR
Expand Down Expand Up @@ -444,7 +447,10 @@ if(WITH_OTLP_GRPC
include(CMakeDependentOption)

message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
set(CMAKE_CXX_CLANG_TIDY "")
include(cmake/opentelemetry-proto.cmake)
set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY})
endif()

#
Expand Down