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
14 changes: 2 additions & 12 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_tooling//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()
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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++"},
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion quality/coverage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

# 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")

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.
Expand Down
16 changes: 5 additions & 11 deletions quality/coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,18 @@
# 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

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_tooling//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
```

Expand Down
8 changes: 4 additions & 4 deletions quality/coverage/coverage.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions quality/coverage/run_coverage.sh
Original file line number Diff line number Diff line change
@@ -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
Loading