Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ jobs:

code_coverage:
name: Code coverage
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@6c3c2f2c1c457b00c10c4848d6f5491db3b629df # v2.18.0
Expand All @@ -1096,15 +1096,16 @@ jobs:
with:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
run: |
sudo -E ./ci/setup_ci_environment.sh
- name: install dependencies
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release
- name: run tests and generate report
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-13
CXX: /usr/bin/g++-13
OTELCPP_CMAKE_BUILD_ARGS: "--parallel 2" # Limit parallelism to avoid hitting runner limits
run: ./ci/do_ci.sh code.coverage
- name: upload report
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ Increment the:
* Enable ENABLE_OTLP_RETRY_PREVIEW for bazel
[#4010](https://github.com/open-telemetry/opentelemetry-cpp/pull/4010)

* [CI] Build third-party dependencies in release with ninja
[#3995](https://github.com/open-telemetry/opentelemetry-cpp/pull/3995)

* [CI] Update ci scripts and documentation
[#4000](https://github.com/open-telemetry/opentelemetry-cpp/pull/4000)

* [CI] Update code.coverage job to report on all components and features
[#4002](https://github.com/open-telemetry/opentelemetry-cpp/pull/4002)

Important changes:

* Enable WITH_OTLP_RETRY_PREVIEW by default
Expand Down
9 changes: 8 additions & 1 deletion ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,21 @@ BUILD_DIR=$HOME/build
BUILD_TYPE=Debug|Release|RelWithDebInfo|MinSizeRel
CXX_STANDARD=14|17|20|23
BUILD_SHARED_LIBS=ON|OFF
OTELCPP_CMAKE_VERBOSE_BUILD=ON|OFF
OTELCPP_CMAKE_BUILD_ARGS=<cmake-build-args>
OTELCPP_CMAKE_CACHE_FILE=<cache-file-name>
```

`OTELCPP_CMAKE_CACHE_FILE` should be the basename of a cache file from
`test_common/cmake`, for example `all-options-abiv1-preview.cmake` or
`all-options-abiv2.cmake`.

`OTELCPP_CMAKE_BUILD_ARGS` overrides the default `cmake --build` arguments
(`--parallel`). For example, to limit parallelism and enable verbose output:

```sh
OTELCPP_CMAKE_BUILD_ARGS="--parallel 2 --verbose" ./ci/do_ci.sh code.coverage
```

## Targets

### Formatting and coverage
Expand Down
33 changes: 24 additions & 9 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ fi
CMAKE_OPTIONS+=("-DCMAKE_CXX_STANDARD_REQUIRED=ON")
CMAKE_OPTIONS+=("-DCMAKE_CXX_EXTENSIONS=OFF")

CMAKE_BUILD_ARGS=(--parallel)

if [[ "${OTELCPP_CMAKE_VERBOSE_BUILD:-OFF}" =~ ^(1|ON|on|TRUE|true|YES|yes)$ ]]; then
CMAKE_BUILD_ARGS+=(--verbose)
if [ -n "${OTELCPP_CMAKE_BUILD_ARGS}" ]; then
read -ra CMAKE_BUILD_ARGS <<< "${OTELCPP_CMAKE_BUILD_ARGS}"
else
CMAKE_BUILD_ARGS=(--parallel)
fi

if command -v ninja >/dev/null 2>&1; then
Expand Down Expand Up @@ -618,14 +618,29 @@ elif [[ "$1" == "code.coverage" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake "${CMAKE_OPTIONS[@]}" \
-DCMAKE_CXX_FLAGS="-Werror --coverage $CXXFLAGS" \
-DCMAKE_CXX_FLAGS="-Werror --coverage -fprofile-update=atomic $CXXFLAGS" \
-C "${SRC_DIR}/test_common/cmake/all-options-abiv2-preview.cmake" \
-DWITH_EXAMPLES=OFF \
-DWITH_EXAMPLES_HTTP=OFF \
-DWITH_BENCHMARK=OFF \
"${SRC_DIR}"

cmake --build . "${CMAKE_BUILD_ARGS[@]}"
ctest --output-on-failure
lcov --directory $PWD --capture --output-file coverage.info
# removing test http server coverage from the total coverage. We don't use this server completely.
lcov --remove coverage.info '*/ext/http/server/*'> tmp_coverage.info 2>/dev/null
cp tmp_coverage.info coverage.info

lcov --directory "$PWD" --capture \
--include "${SRC_DIR}/*" \
--exclude "${SRC_DIR}/third_party/*" \
--exclude "${SRC_DIR}/test_common/*" \
--exclude "${SRC_DIR}/*/test/*" \
--exclude "${SRC_DIR}/functional/*" \
--exclude "${SRC_DIR}/semconv/*" \
--exclude "${SRC_DIR}/examples/*" \
Copy link
Copy Markdown
Member

@marcalff marcalff Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also exclude '/ext/http/server/' as before, the http server is test code, not a deliverable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. I can see ext/http/server headers are only used in tests and an example. They are installed for public use at the moment though. I'll move them to test_common in a separate PR.

--ignore-errors unused \
--output-file coverage.info

echo "Code coverage output file generated at ${BUILD_DIR}/coverage.info. To generate an HTML report run:"
echo "genhtml ${BUILD_DIR}/coverage.info -o coverage_html"
exit 0
fi

Expand Down
Loading