From b2217111417f41cbc5ea46b260431b601d5a290d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Fu=C3=9Fberger?= Date: Fri, 18 Sep 2026 14:05:49 +0200 Subject: [PATCH 1/2] Migrate coverage pipeline to score_coverage 0.2.0 --- .github/workflows/code_coverage.yml | 2 +- MODULE.bazel | 3 ++- MODULE.bazel.lock | 2 ++ quality/coverage/BUILD | 2 +- quality/coverage/README.md | 5 +++-- quality/coverage/coverage.bazelrc | 8 ++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index ae2b486cfe..ae3d75cbe4 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -58,7 +58,7 @@ jobs: env: COVERAGE_THRESHOLD: ${{ inputs.coverage-threshold }} run: | - bazel run @score_tooling//coverage:generate_coverage_html -- \ + bazel run @score_coverage//:generate_coverage_html -- \ --yaml quality/coverage/coverage_justifications.yaml \ --archive-dir coverage_artifacts diff --git a/MODULE.bazel b/MODULE.bazel index bd2068dc86..0df3579a88 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -38,6 +38,7 @@ bazel_dep(name = "score_tooling", version = "2.2.1") bazel_dep(name = "score_rust_policies", version = "0.0.5", dev_dependency = True) bazel_dep(name = "score_cpp_policies", version = "0.1.1", dev_dependency = True) bazel_dep(name = "score_devcontainer", version = "1.11.1", dev_dependency = True) +bazel_dep(name = "score_coverage", version = "0.2.0", dev_dependency = True) bazel_dep(name = "score_process_description", version = "2.1.2") bazel_dep(name = "score_platform", version = "0.7.2") @@ -221,7 +222,7 @@ llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", llvm.toolchain( cxx_standard = {"": "c++17"}, extra_known_features = [ - "@score_tooling//coverage:enable_llvm_coverage_for_death_tests", + "@score_coverage//:enable_llvm_coverage_for_death_tests", ], llvm_version = "22.1.7", stdlib = {"": "stdc++"}, diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 9e734c85c0..a1a835504f 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1053,6 +1053,8 @@ "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_bazel_platforms/1.1.0/source.json": "9797d56e9dd68e9d3e8b674402df2d6d5e2174f84184ca4cbee78fc07dc117d9", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_communication/0.4.0/MODULE.bazel": "19e98105c4b1ca674027dfa4c5010eebbdf74d7cbd9524cb84a8fad63a8bcebe", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_communication/0.4.0/source.json": "a3378155debe445305828cfa94464ad5f53d5b7e27488b3c053b02e49801aaeb", + "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_coverage/0.2.0/MODULE.bazel": "7e2fd874ef66e5d87cfcefb3bbea121f7a375a90f3ff643945a6bbc167ba9484", + "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_coverage/0.2.0/source.json": "9fec77e9cc32a89501681e9b2d6ae5cdd3831fb3efc203db89d7f19321bb037e", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_cpp_policies/0.1.1/MODULE.bazel": "62968745a2fe77c449d4e11447b50918c58f870eeac72f0f3198c63617a2f8a2", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_cpp_policies/0.1.1/source.json": "29d45fbd6f3fae0a21487f5d652dfa0796bd2095d2a19732a5456e5b232754a9", "https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_cr_checker/0.2.2/MODULE.bazel": "dc36d9c35543db918c3fb5b93a8e684431f56c7c784cf2a1b90f35802a373c98", diff --git a/quality/coverage/BUILD b/quality/coverage/BUILD index 39430ffa34..a850d6746d 100644 --- a/quality/coverage/BUILD +++ b/quality/coverage/BUILD @@ -13,7 +13,7 @@ # Code coverage (LLVM source-based pipeline). See README.md for details. -load("@score_tooling//coverage:defs.bzl", "score_coverage_reporter", "score_coverage_scope") +load("@score_coverage//:defs.bzl", "score_coverage_reporter", "score_coverage_scope") # Declares which production targets define the coverage scope. Everything in # scope but untested shows up at 0%; everything outside is filtered out. diff --git a/quality/coverage/README.md b/quality/coverage/README.md index 031d55f1fb..b4dc419b4a 100644 --- a/quality/coverage/README.md +++ b/quality/coverage/README.md @@ -14,7 +14,8 @@ # Coverage Unified C++ + Rust code coverage via the shared LLVM source-based setup from -`@score_tooling//coverage`. The code itself lives in score_tooling; this +`@score_coverage`. The code itself lives in the standalone +[score_coverage](https://github.com/eclipse-score/coverage_tool) module; this directory only holds the repo-specific pieces. ## Usage @@ -27,7 +28,7 @@ Run the coverage build over the in-scope targets, then generate the HTML report: bazel coverage --config=llvm_cov //score/... --build_tests_only # 2. Generate the HTML report -bazel run @score_tooling//coverage:generate_coverage_html -- \ +bazel run @score_coverage//:generate_coverage_html -- \ --yaml quality/coverage/coverage_justifications.yaml \ --archive-dir coverage_artifacts diff --git a/quality/coverage/coverage.bazelrc b/quality/coverage/coverage.bazelrc index 5c10f6ece4..8ef4a0e809 100644 --- a/quality/coverage/coverage.bazelrc +++ b/quality/coverage/coverage.bazelrc @@ -15,9 +15,9 @@ # ============================================================================ # LLVM source-based coverage (Linux, Clang + Ferrocene) — unified Rust + C++. -# Canonical consumer snippet from score_tooling//coverage. Run with: +# Canonical consumer snippet from score_coverage. Run with: # bazel coverage --config=llvm_cov //score/... --build_tests_only -# bazel run @score_tooling//coverage:generate_coverage_html +# bazel run @score_coverage//:generate_coverage_html # ============================================================================ # Register the Ferrocene host/exec Rust toolchain (via _score_common). Without @@ -53,10 +53,10 @@ coverage:llvm_cov --copt=-Wno-error coverage:llvm_cov --features=-treat_warnings_as_errors coverage:llvm_cov --host_features=-treat_warnings_as_errors -# The merger lives in score_tooling (no consumer-specific wiring needed); the +# The merger lives in score_coverage (no consumer-specific wiring needed); the # reporter_wrapper is instantiated in //quality/coverage because it carries the # coverage scope and LLVM tool labels. -coverage:llvm_cov --coverage_output_generator=@score_tooling//coverage:merger +coverage:llvm_cov --coverage_output_generator=@score_coverage//:merger coverage:llvm_cov --coverage_report_generator=//quality/coverage:reporter_wrapper # Keep raw profraw files instead of converting to LCOV; the merger handles From 7757c42307918945ab939d6d163bf7efd258a65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Fu=C3=9Fberger?= Date: Thu, 24 Sep 2026 14:03:41 +0200 Subject: [PATCH 2/2] Consolidate to single coverage command --- .github/workflows/code_coverage.yml | 14 ++---------- quality/coverage/BUILD | 6 ++++++ quality/coverage/README.md | 13 +++--------- quality/coverage/run_coverage.sh | 33 +++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 22 deletions(-) create mode 100755 quality/coverage/run_coverage.sh diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index ae3d75cbe4..63fe83f5de 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -46,21 +46,11 @@ jobs: with: disk-cache-key: ${{ github.job }} - - name: Collect coverage - run: | - bazel coverage \ - --config=llvm_cov \ - --lockfile_mode=error \ - --build_tests_only \ - //score/... - - - name: Generate report and enforce threshold + - name: Generate coverage report and enforce threshold env: COVERAGE_THRESHOLD: ${{ inputs.coverage-threshold }} run: | - bazel run @score_coverage//:generate_coverage_html -- \ - --yaml quality/coverage/coverage_justifications.yaml \ - --archive-dir coverage_artifacts + bazel build //quality/coverage:run_coverage - name: Upload coverage report if: always() diff --git a/quality/coverage/BUILD b/quality/coverage/BUILD index a850d6746d..6f696f28bb 100644 --- a/quality/coverage/BUILD +++ b/quality/coverage/BUILD @@ -15,6 +15,12 @@ load("@score_coverage//:defs.bzl", "score_coverage_reporter", "score_coverage_scope") +sh_binary( + name = "run_coverage", + srcs = ["run_coverage.sh"], + visibility = ["//visibility:public"], +) + # Declares which production targets define the coverage scope. Everything in # scope but untested shows up at 0%; everything outside is filtered out. score_coverage_scope( diff --git a/quality/coverage/README.md b/quality/coverage/README.md index b4dc419b4a..8b084edf37 100644 --- a/quality/coverage/README.md +++ b/quality/coverage/README.md @@ -20,19 +20,12 @@ directory only holds the repo-specific pieces. ## Usage -Run the coverage build over the in-scope targets, then generate the HTML report: +Run the coverage build and generate the HTML report with the wrapper target: ```bash -# 1. Collect coverage -# Note: Targets with "no-coverage" tag are skipped -bazel coverage --config=llvm_cov //score/... --build_tests_only +bazel run //quality/coverage:run_coverage -# 2. Generate the HTML report -bazel run @score_coverage//:generate_coverage_html -- \ - --yaml quality/coverage/coverage_justifications.yaml \ - --archive-dir coverage_artifacts - -# 3. Open it. +# Open the report. xdg-open coverage_artifacts/coverage_linux/index.html ``` diff --git a/quality/coverage/run_coverage.sh b/quality/coverage/run_coverage.sh new file mode 100755 index 0000000000..015b88fbb7 --- /dev/null +++ b/quality/coverage/run_coverage.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# ******************************************************************************* +# 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 +# ******************************************************************************* + +set -euo pipefail + +# Switch back to BUILD_WORKSPACE_DIRECTORY when invoked via bazel +if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then + workspace_root="$BUILD_WORKSPACE_DIRECTORY" +else + workspace_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +fi +cd -- "$workspace_root" + +# 1. Collect coverage +# Note: Targets with "no-coverage" tag are skipped +bazel coverage --config=llvm_cov //score/... --lockfile_mode=error --build_tests_only + +# 2. Generate the HTML report +bazel run @score_coverage//:generate_coverage_html -- \ + --yaml quality/coverage/coverage_justifications.yaml \ + --archive-dir coverage_artifacts