Skip to content

Commit

Permalink
add/fix support for bazel coverage (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobithiel authored Oct 11, 2023
1 parent 6430f82 commit e2a3469
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ jobs:
bazel test --config ci --config ${{ matrix.sanitizer }} //tests/sanitizers:${{ matrix.sanitizer }}_test
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
coverage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: bazelbuild/setup-bazelisk@v2
- name: Test Coverage
run: |
./.github/workflows/configurebb.sh
bazel coverage --config ci //examples/hello_world_cpp:hello_world_cpp_test
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
rbe:
if: (github.ref == 'refs/heads/main' || contains(github.head_ref, 'rbe'))
strategy:
Expand Down
6 changes: 6 additions & 0 deletions examples/hello_world_cpp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ cc_binary(
data = ["names.txt"],
)

cc_test(
name = "hello_world_cpp_test",
srcs = ["main.cpp"],
data = ["names.txt"],
)

platform_transition_filegroup(
name = "hello_world_cpp_linux_aarch64",
srcs = [":hello_world_cpp"],
Expand Down
22 changes: 22 additions & 0 deletions toolchain/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ filegroup(
visibility = ["//visibility:public"],
)
filegroup(
name = "coverage_files",
srcs = [":gcov"],
visibility = ["//visibility:public"],
)
[
filegroup(
name = bin,
Expand All @@ -516,6 +522,7 @@ filegroup(
for bin in [
"ar",
"as",
"gcov",
"ld",
"ld.bfd",
"nm",
Expand Down Expand Up @@ -575,6 +582,7 @@ cc_toolchain(
linker_files = ":linker_files",
objcopy_files = ":objcopy_files",
strip_files = ":strip_files",
coverage_files = ":coverage_files",
supports_param_files = 0,
toolchain_config = ":cc_toolchain_config",
toolchain_identifier = "gcc-toolchain",
Expand All @@ -598,6 +606,7 @@ filegroup(
":ar_files",
":as_files",
":compiler_files",
":coverage_files",
":dwp_files",
":linker_files",
":objcopy_files",
Expand Down Expand Up @@ -662,6 +671,14 @@ filegroup(
],
)
filegroup(
name = "coverage_files",
srcs = [
"@{toolchain_files_repository_name}//:coverage_files",
":gcov",
],
)
filegroup(
name = "gcc",
srcs = [
Expand All @@ -671,6 +688,11 @@ filegroup(
],
)
filegroup(
name = "gcov",
srcs = ["bin/gcov"],
)
filegroup(
name = "gfortran",
srcs = ["bin/gfortran"],
Expand Down

0 comments on commit e2a3469

Please sign in to comment.