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
24 changes: 12 additions & 12 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ 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 configuration for C++
coverage --features=coverage
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`
coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1
coverage --cxxopt -mllvm
coverage --cxxopt -runtime-counter-relocation
coverage --cache_test_results=no
coverage --instrumentation_filter="^//score[/:]"

# Coverage configuration
build:blcov-x86_64-linux --incompatible_strict_action_env
Copy link
Contributor

Choose a reason for hiding this comment

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

bl stands for baselibs

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
65 changes: 65 additions & 0 deletions .github/workflows/coverage_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# *******************************************************************************
# Copyright (c) 2025 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
Copy link
Member

Choose a reason for hiding this comment

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

It's a copy-paste from baselibs. I'm actually considering to have it reusable via cicd_workflows, but I'm not sure this workflow is in the right shape to push it there.

Ideally, if it's to be reusable, it should support not only C++, but also Rust and maybe Python.
And for Rust, I'm wondering how it will mix up with the Ferrocene toolchain. @pawelrutkaq, does the rust coverage also rely on bazel 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@v6

- name: Install lcov
run: |
sudo apt-get update
sudo apt-get install -y lcov
- name: Setup Bazel
Comment on lines +38 to +39
Copy link
Contributor

Choose a reason for hiding this comment

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

please use consistent new line formatting

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 --config=blcov-x86_64-linux -- //score/... //tests/...
Copy link
Contributor

Choose a reason for hiding this comment

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

why run //tests/... when you have instrumentation filter on //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@v6
with:
name: ${{ github.event.repository.name }}_coverage_report
path: cpp_coverage/
retention-days: 30
16 changes: 13 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

If you use this, you should kick out score_toolchains_gcc and score_toolchains_qnx.
I suggest to do it in a separate PR and do not mix up with the coverage workflow.

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)
Expand Down Expand Up @@ -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")
Comment on lines +70 to +86
Copy link
Contributor

Choose a reason for hiding this comment

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

I think those 2 shouldn't coexist or only one common config should be used for build, test and coverage for x86 linux


# TRLC dependency for requirements traceability
bazel_dep(name = "trlc", version = "0.0.0", dev_dependency = True)
Expand All @@ -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",
Expand Down
Loading