Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
62 changes: 36 additions & 26 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ permissions:

jobs:
clang-tidy:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 215
- cmake_options: all-options-abiv2-preview
warning_limit: 216
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
Expand All @@ -23,19 +31,20 @@ jobs:
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 \
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
Expand All @@ -47,42 +56,43 @@ jobs:
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: |
echo "Running cmake..."
cmake -B build \
cmake -B build-${{ matrix.cmake_options }} \
-C ./test_common/cmake/${{ matrix.cmake_options }}.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
-DWITH_OPENTRACING=OFF \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--quiet;-p;build-${{ matrix.cmake_options }}"

- name: Run clang-tidy
run: |
cmake --build build --target opentelemetry_proto
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
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) 2>&1 | tee clang-tidy-${{ matrix.cmake_options }}.log

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Logs (clang-tidy)
path: ./clang-tidy.log
name: Logs-clang-tidy-${{ matrix.cmake_options }}
path: ./clang-tidy-${{ matrix.cmake_options }}.log

- name: Count warnings
run: |
COUNT=$(grep -c "warning:" clang-tidy.log)
echo "clang-tidy reported ${COUNT} warning(s)"
COUNT=$(grep -c "warning:" clang-tidy-${{ matrix.cmake_options }}.log)
echo "clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"

readonly WARNING_LIMIT=${{ matrix.warning_limit }}

# FAIL the build if COUNT > WARNING_LIMIT
if [ $COUNT -gt $WARNING_LIMIT ] ; then
echo "clang-tidy reported ${COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'"
exit 1
# WARN in annotations if COUNT > 0
elif [ $COUNT -gt 0 ] ; then
echo "::warning::clang-tidy reported ${COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
fi

# TODO: include WITH_OTLP_GRPC flags.
51 changes: 26 additions & 25 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ permissions:
jobs:
iwyu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- cmake_options: all-options-abiv1
warning_limit: 3
- cmake_options: all-options-abiv1-preview
warning_limit: 28
- cmake_options: all-options-abiv2-preview
warning_limit: 48

steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
Expand Down Expand Up @@ -46,52 +57,42 @@ jobs:
run: |
sudo ./ci/install_iwyu.sh
- name: Prepare CMake
env:
CC: clang
CXX: clang++
run: |
TOPDIR=`pwd`
mkdir build && cd build
CC="clang" CXX="clang++" cmake \
cmake -B build-${{ matrix.cmake_options }} \
-C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \
-DCMAKE_CXX_STANDARD=14 \
-DWITH_STL=CXX14 \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
-DBUILD_TESTING=ON \
-DWITH_EXAMPLES=ON \
-DWITH_EXAMPLES_HTTP=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_OPENTRACING=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_THREAD_INSTRUMENTATION=ON \
-DWITH_ZIPKIN=ON \
-DWITH_PROMETHEUS=ON \
..
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;"

- name: iwyu_tool
run: |
cd build
make -k 2>&1 | tee -a iwyu.log
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) -k 2>&1 | tee -a iwyu-${{ matrix.cmake_options }}.log

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: success() || failure()
with:
name: Logs (include-what-you-use)
path: ./build/*.log
name: Logs-iwyu-${{ matrix.cmake_options }}
path: ./iwyu-${{ matrix.cmake_options }}.log

- name: count warnings
run: |
set +e
echo "include-what-you-use version:"
include-what-you-use --version
cd build
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu-${{ matrix.cmake_options }}.log`
echo "include-what-you-use reported ${WARNING_COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
# Acceptable limit, to decrease over time down to 0
readonly WARNING_LIMIT=0
readonly WARNING_LIMIT=${{ matrix.warning_limit }}
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
echo "include-what-you-use reported ${WARNING_COUNT} warning(s) exceeding the existing warning limit of ${WARNING_LIMIT} with cmake options preset '${{ matrix.cmake_options }}'"
exit 1
# WARN in annotations if WARNING_COUNT > 0
elif [ $WARNING_COUNT -gt 0 ] ; then
echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s)"
echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s) with cmake options preset '${{ matrix.cmake_options }}'"
fi
8 changes: 4 additions & 4 deletions cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ target_include_directories(
PUBLIC "$<BUILD_INTERFACE:${GENERATED_PROTOBUF_PATH}>"
"$<INSTALL_INTERFACE:include>")

# Disable include-what-you-use on generated code.
# Disable include-what-you-use and clang-tidy on generated code.
set_target_properties(opentelemetry_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE
"")
"" CXX_CLANG_TIDY "")
if(NOT Protobuf_INCLUDE_DIRS AND TARGET protobuf::libprotobuf)
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
INTERFACE_INCLUDE_DIRECTORIES)
Expand All @@ -338,9 +338,9 @@ if(WITH_OTLP_GRPC)
${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE})
set_target_version(opentelemetry_proto_grpc)

# Disable include-what-you-use on generated code.
# Disable include-what-you-use and clang-tidy on generated code.
set_target_properties(opentelemetry_proto_grpc
PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")
PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "" CXX_CLANG_TIDY "")

list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc)
target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto)
Expand Down
5 changes: 3 additions & 2 deletions examples/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ add_custom_command(
add_library(example_grpc_proto ${example_grpc_srcs} ${example_grpc_hdrs}
${example_proto_srcs} ${example_proto_hdrs})

# Disable include-what-you-use on generated code.
set_target_properties(example_grpc_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")
# Disable include-what-you-use and clang-tidy on generated code.
set_target_properties(example_grpc_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
CXX_CLANG_TIDY "")

target_include_directories(
example_grpc_proto PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
Expand Down
10 changes: 10 additions & 0 deletions test_common/cmake/all-options-abiv1-preview.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Enable all options with ABI V1 including preview features

set(WITH_ABI_VERSION_1 ON CACHE BOOL "" FORCE)
set(WITH_ABI_VERSION_2 OFF CACHE BOOL "" FORCE)

set(ENABLE_PREVIEW ON)
include(${CMAKE_CURRENT_LIST_DIR}/all-options.cmake)
10 changes: 10 additions & 0 deletions test_common/cmake/all-options-abiv1.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Enable all options with ABI V1 except preview features

set(WITH_ABI_VERSION_1 ON CACHE BOOL "" FORCE)
set(WITH_ABI_VERSION_2 OFF CACHE BOOL "" FORCE)

set(ENABLE_PREVIEW OFF)
include(${CMAKE_CURRENT_LIST_DIR}/all-options.cmake)
10 changes: 10 additions & 0 deletions test_common/cmake/all-options-abiv2-preview.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Enable all options with ABI V2 including preview features

set(WITH_ABI_VERSION_1 OFF CACHE BOOL "" FORCE)
set(WITH_ABI_VERSION_2 ON CACHE BOOL "" FORCE)

set(ENABLE_PREVIEW ON)
include(${CMAKE_CURRENT_LIST_DIR}/all-options.cmake)
10 changes: 10 additions & 0 deletions test_common/cmake/all-options-abiv2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Enable all options with ABI V2 except preview features

set(WITH_ABI_VERSION_1 OFF CACHE BOOL "" FORCE)
set(WITH_ABI_VERSION_2 ON CACHE BOOL "" FORCE)

set(ENABLE_PREVIEW OFF)
include(${CMAKE_CURRENT_LIST_DIR}/all-options.cmake)
9 changes: 9 additions & 0 deletions test_common/cmake/all-options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# All options for the opentelemetry-cpp project.

include(${CMAKE_CURRENT_LIST_DIR}/component-options.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/example-options.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/testing-options.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/preview-options.cmake)
27 changes: 27 additions & 0 deletions test_common/cmake/component-options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# All components options

if(NOT DEFINED ENABLE_COMPONENTS)
set(ENABLE_COMPONENTS ON)
endif()

set(WITH_OTLP_GRPC ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
set(WITH_OTLP_HTTP ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
set(WITH_OTLP_FILE ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)

set(WITH_OTLP_HTTP_COMPRESSION ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
set(WITH_CURL_LOGGING ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)

set(WITH_PROMETHEUS ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
set(WITH_ZIPKIN ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
set(WITH_ELASTICSEARCH ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)

if(WIN32)
set(WITH_ETW ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
endif()

if(WITH_ABI_VERSION_1)
set(WITH_OPENTRACING ${ENABLE_COMPONENTS} CACHE BOOL "" FORCE)
endif()
11 changes: 11 additions & 0 deletions test_common/cmake/example-options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# All examples options

if(NOT DEFINED ENABLE_EXAMPLES)
set(ENABLE_EXAMPLES ON)
endif()

set(WITH_EXAMPLES ${ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(WITH_EXAMPLES_HTTP ${ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
15 changes: 15 additions & 0 deletions test_common/cmake/preview-options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# All preview feature options

if(NOT DEFINED ENABLE_PREVIEW)
set(ENABLE_PREVIEW ON)
endif()

set(WITH_METRICS_EXEMPLAR_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
set(WITH_ASYNC_EXPORT_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
set(WITH_THREAD_INSTRUMENTATION_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
set(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
set(WITH_OTLP_GRPC_CREDENTIAL_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
set(WITH_OTLP_RETRY_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE)
13 changes: 13 additions & 0 deletions test_common/cmake/testing-options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# All testing options

if(NOT DEFINED ENABLE_TESTS)
set(ENABLE_TESTS ON)
endif()

set(BUILD_TESTING ${ENABLE_TESTS} CACHE BOOL "" FORCE)
set(BUILD_W3CTRACECONTEXT_TEST ${ENABLE_TESTS} CACHE BOOL "" FORCE)
set(WITH_BENCHMARK ${ENABLE_TESTS} CACHE BOOL "" FORCE)
set(WITH_FUNC_TESTS ${ENABLE_TESTS} CACHE BOOL "" FORCE)
Loading