From 9904755f2e49a48c3824e26408711d6b3931b8da Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 04:19:48 +0100 Subject: [PATCH 01/10] Add C++ coverage configuration and workflow - Add coverage_report.yml with LCOV/HTML report generation - Configure Bazel coverage flags in .bazelrc --- .bazelrc | 5 +++ .github/workflows/coverage_report.yml | 64 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/coverage_report.yml diff --git a/.bazelrc b/.bazelrc index 7796054..9627811 100644 --- a/.bazelrc +++ b/.bazelrc @@ -58,3 +58,8 @@ coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 coverage --cxxopt -mllvm coverage --cxxopt -runtime-counter-relocation + +# Additional coverage configuration (SCORE baselibs style) +coverage --features=coverage +coverage --cache_test_results=no + diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml new file mode 100644 index 0000000..0df6be3 --- /dev/null +++ b/.github/workflows/coverage_report.yml @@ -0,0 +1,64 @@ +# ******************************************************************************* +# Copyright (c) 2026 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +name: Code Coverage +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + +jobs: + coverage-report: + runs-on: ubuntu-22.04 + + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install lcov + run: | + sudo apt-get update + sudo apt-get install -y lcov + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.18.0 + with: + bazelisk-cache: true + disk-cache: ${{ github.workflow }} + repository-cache: true + cache-save: ${{ github.event_name != 'pull_request' }} + + - name: Run Bazel Coverage + run: | + bazel coverage -- //score/... + - name: Generate HTML Coverage Report + run: | + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ + -o=cpp_coverage \ + --show-details \ + --legend \ + --function-coverage \ + --branch-coverage + shell: bash + + - name: Upload Coverage Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}_coverage_report + path: cpp_coverage/ From e08aa699839c88aa0fb619c4f54c7caa3d01269d Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 05:24:00 +0100 Subject: [PATCH 02/10] Fixing copyright issues in coverage report --- .github/workflows/coverage_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 0df6be3..95cc11f 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -1,5 +1,5 @@ # ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation +# Copyright (c) 2025 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. From f2608089b4eeb1c18cb0221a543af242a21a7f4a Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 06:29:52 +0100 Subject: [PATCH 03/10] Comment out LLVM-specific coverage flags for GCC compatibility - LLVM flags (-mllvm, -runtime-counter-relocation) are incompatible with GCC - Comment them out to fix CI coverage build failures - Can be uncommented when using LLVM/Clang toolchain --- .bazelrc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 9627811..f3b6395 100644 --- a/.bazelrc +++ b/.bazelrc @@ -55,9 +55,10 @@ coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu # TODO set toolchain feature once possible # These compile time options are required to cover abnormal termination cases. In GCC one can use `__gcc_dump()`, but this does not work with LLVM # LLVM provided these compile-time options in combination with a specific profile setting which is enabled in bazel via `LLVM_PROFILE_CONTINUOUS_MODE` -coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 -coverage --cxxopt -mllvm -coverage --cxxopt -runtime-counter-relocation +# NOTE: Commented out for GCC compatibility - uncomment when using LLVM/Clang toolchain +# coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 +# coverage --cxxopt -mllvm +# coverage --cxxopt -runtime-counter-relocation # Additional coverage configuration (SCORE baselibs style) coverage --features=coverage From 29c4fb158a459e84826c9f2ade1f922f825e7bec Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 06:29:52 +0100 Subject: [PATCH 04/10] Comment out LLVM-specific coverage flags for GCC compatibility - LLVM flags (-mllvm, -runtime-counter-relocation) are incompatible with GCC - Comment them out to fix CI coverage build failures - Can be uncommented when using LLVM/Clang toolchain --- .github/workflows/coverage_report.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 95cc11f..45ad9ad 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -23,14 +23,14 @@ on: jobs: coverage-report: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install lcov run: | @@ -58,7 +58,8 @@ jobs: shell: bash - name: Upload Coverage Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ github.event.repository.name }}_coverage_report path: cpp_coverage/ + retention-days: 30 From 10dcabb8c69e29e91afafbf100d26afdd52142ae Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 09:12:28 +0100 Subject: [PATCH 05/10] Fix coverage configuration issue Remove LLVM-specific flags and instrumentation filter that were causing empty coverage reports. Use only the three baselibs flags: - coverage --features=coverage - coverage --combined_report=lcov - coverage --cache_test_results=no Fixes: SWP-240231 --- .bazelrc | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.bazelrc b/.bazelrc index f3b6395..8f709dc 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,22 +45,7 @@ build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_aarch64 common --extra_toolchains=@gcc_toolchain//:host_gcc_12 common --extra_toolchains=@score_toolchains_rust//toolchains/x86_64-unknown-linux-gnu:toolchain_x86_64_linux -# With this instrumentation filter for our two main components, we ensure that `bazel coverage //...` is yielding the correct results -coverage --instrumentation_filter="^//score/datarouter[/:],^//score/mw/log[/:],-//score/mw/.*/test[/:]" -coverage --experimental_generate_llvm_lcov -coverage --experimental_use_llvm_covmap -coverage --combined_report=lcov -coverage --coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main -coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu -# TODO set toolchain feature once possible -# These compile time options are required to cover abnormal termination cases. In GCC one can use `__gcc_dump()`, but this does not work with LLVM -# LLVM provided these compile-time options in combination with a specific profile setting which is enabled in bazel via `LLVM_PROFILE_CONTINUOUS_MODE` -# NOTE: Commented out for GCC compatibility - uncomment when using LLVM/Clang toolchain -# coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 -# coverage --cxxopt -mllvm -# coverage --cxxopt -runtime-counter-relocation - -# Additional coverage configuration (SCORE baselibs style) +# Coverage configuration for C++ (SCORE baselibs style) coverage --features=coverage +coverage --combined_report=lcov coverage --cache_test_results=no - From 8fab87bb3f165bff121c586a62cf09a2a5d84194 Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 09:41:17 +0100 Subject: [PATCH 06/10] Add ignore-errors flag and instrumentation filter for coverage - Add --ignore-errors empty to genhtml to handle sparse coverage --- .bazelrc | 1 + .github/workflows/coverage_report.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 8f709dc..e477bbf 100644 --- a/.bazelrc +++ b/.bazelrc @@ -49,3 +49,4 @@ common --extra_toolchains=@score_toolchains_rust//toolchains/x86_64-unknown-linu coverage --features=coverage coverage --combined_report=lcov coverage --cache_test_results=no +coverage --instrumentation_filter="^//score[/:]" diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 45ad9ad..f65f284 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -54,7 +54,8 @@ jobs: --show-details \ --legend \ --function-coverage \ - --branch-coverage + --branch-coverage \ + --ignore-errors empty shell: bash - name: Upload Coverage Artifacts From 8ef9469973b50fbc79251214a8fa431ada789ecf Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 09:56:53 +0100 Subject: [PATCH 07/10] Make coverage report generation more resilient - Add file size check before running genhtml - Add more ignore-errors flags --- .github/workflows/coverage_report.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index f65f284..73deb80 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -49,13 +49,19 @@ jobs: bazel coverage -- //score/... - name: Generate HTML Coverage Report run: | - genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ - -o=cpp_coverage \ - --show-details \ - --legend \ - --function-coverage \ - --branch-coverage \ - --ignore-errors empty + if [ -s "$(bazel info output_path)/_coverage/_coverage_report.dat" ]; then + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ + -o=cpp_coverage \ + --show-details \ + --legend \ + --function-coverage \ + --branch-coverage \ + --ignore-errors empty,source || echo "Coverage report generation failed, but continuing..." + else + echo "Coverage report is empty, skipping HTML generation" + mkdir -p cpp_coverage + echo "

No coverage data available

" > cpp_coverage/index.html + fi shell: bash - name: Upload Coverage Artifacts From fc1fa921b16a56c50a54fb5c057999920a04a305 Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 10:23:59 +0100 Subject: [PATCH 08/10] Fix comment in coverage configuration --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index e477bbf..e49e684 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,7 +45,7 @@ build:build_qnx8 --extra_toolchains=@toolchains_qnx_ifs//:ifs_aarch64 common --extra_toolchains=@gcc_toolchain//:host_gcc_12 common --extra_toolchains=@score_toolchains_rust//toolchains/x86_64-unknown-linux-gnu:toolchain_x86_64_linux -# Coverage configuration for C++ (SCORE baselibs style) +# Coverage configuration for C++ coverage --features=coverage coverage --combined_report=lcov coverage --cache_test_results=no From dfe07a900388f05dd71f557f622439410e9ded80 Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Wed, 28 Jan 2026 13:49:20 +0100 Subject: [PATCH 09/10] Remove placeholder logic - empty coverage should fail --- .github/workflows/coverage_report.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 73deb80..45ad9ad 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -49,19 +49,12 @@ jobs: bazel coverage -- //score/... - name: Generate HTML Coverage Report run: | - if [ -s "$(bazel info output_path)/_coverage/_coverage_report.dat" ]; then - genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ - -o=cpp_coverage \ - --show-details \ - --legend \ - --function-coverage \ - --branch-coverage \ - --ignore-errors empty,source || echo "Coverage report generation failed, but continuing..." - else - echo "Coverage report is empty, skipping HTML generation" - mkdir -p cpp_coverage - echo "

No coverage data available

" > cpp_coverage/index.html - fi + genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ + -o=cpp_coverage \ + --show-details \ + --legend \ + --function-coverage \ + --branch-coverage shell: bash - name: Upload Coverage Artifacts From 34bbd76f4408684e7f844d1acdec7cda7aa1ac31 Mon Sep 17 00:00:00 2001 From: "rahul.singh" Date: Thu, 29 Jan 2026 09:38:29 +0100 Subject: [PATCH 10/10] Fix coverage measurement using score_bazel_cpp_toolchains --- .bazelrc | 8 ++++++++ .github/workflows/coverage_report.yml | 4 ++-- MODULE.bazel | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index e49e684..4addcc5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -50,3 +50,11 @@ coverage --features=coverage coverage --combined_report=lcov coverage --cache_test_results=no coverage --instrumentation_filter="^//score[/:]" + +# Coverage configuration +build:blcov-x86_64-linux --incompatible_strict_action_env +build:blcov-x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix +build:blcov-x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0-posix +test:blcov-x86_64-linux --build_tests_only +test:blcov-x86_64-linux --test_tag_filters=-manual +test:blcov-x86_64-linux --test_output=errors diff --git a/.github/workflows/coverage_report.yml b/.github/workflows/coverage_report.yml index 45ad9ad..aa29f24 100644 --- a/.github/workflows/coverage_report.yml +++ b/.github/workflows/coverage_report.yml @@ -23,7 +23,7 @@ on: jobs: coverage-report: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: contents: read @@ -46,7 +46,7 @@ jobs: - name: Run Bazel Coverage run: | - bazel coverage -- //score/... + bazel coverage --config=blcov-x86_64-linux -- //score/... //tests/... - name: Generate HTML Coverage Report run: | genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" \ diff --git a/MODULE.bazel b/MODULE.bazel index dfb0154..6d453d2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -26,7 +26,7 @@ bazel_dep(name = "buildifier_prebuilt", version = "7.3.1") bazel_dep(name = "platforms", version = "1.0.0") # S-CORE process rules -bazel_dep(name = "score_bazel_platforms", version = "0.0.3") +bazel_dep(name = "score_bazel_platforms", version = "0.0.4") bazel_dep(name = "score_docs_as_code", version = "2.2.0") bazel_dep(name = "score_tooling", version = "1.0.4") bazel_dep(name = "score_rust_policies", version = "0.0.3") @@ -35,6 +35,7 @@ bazel_dep(name = "score_process", version = "1.4.0", dev_dependency = True) bazel_dep(name = "score_platform", version = "0.5.1", dev_dependency = True) # This is main score repo # Toolchains and extensions +bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.0", dev_dependency = True) bazel_dep(name = "score_toolchains_gcc", version = "0.5", dev_dependency = True) bazel_dep(name = "score_toolchains_qnx", version = "0.0.6", dev_dependency = True) bazel_dep(name = "rust_qnx8_toolchain", version = "1.2.0", dev_dependency = True) @@ -66,12 +67,23 @@ archive_override( # Extensions +gcc_cpp = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", dev_dependency = True) +gcc_cpp.toolchain( + name = "score_gcc_x86_64_toolchain", + target_cpu = "x86_64", + target_os = "linux", + use_default_package = True, + version = "12.2.0", +) +use_repo(gcc_cpp, "score_gcc_x86_64_toolchain") + gcc = use_extension("@score_toolchains_gcc//extentions:gcc.bzl", "gcc", dev_dependency = True) gcc.toolchain( sha256 = "457f5f20f57528033cb840d708b507050d711ae93e009388847e113b11bf3600", strip_prefix = "x86_64-unknown-linux-gnu", url = "https://github.com/eclipse-score/toolchains_gcc_packages/releases/download/0.0.1/x86_64-unknown-linux-gnu_gcc12.tar.gz", ) +use_repo(gcc, "gcc_toolchain", "gcc_toolchain_gcc") # TRLC dependency for requirements traceability bazel_dep(name = "trlc", version = "0.0.0", dev_dependency = True) @@ -81,8 +93,6 @@ git_override( remote = "https://github.com/bmw-software-engineering/trlc.git", ) -use_repo(gcc, "gcc_toolchain", "gcc_toolchain_gcc") - toolchains_qnx = use_extension("@score_toolchains_qnx//:extensions.bzl", "toolchains_qnx", dev_dependency = True) toolchains_qnx.sdp( sha256 = "f2e0cb21c6baddbcb65f6a70610ce498e7685de8ea2e0f1648f01b327f6bac63",