From edaeb6ab235d2f9578a500606679a05fc44edc77 Mon Sep 17 00:00:00 2001 From: Tobias Thiel Date: Tue, 26 Sep 2023 21:57:04 -0700 Subject: [PATCH 1/4] add support for bazel coverage --- toolchain/defs.bzl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 32ba805..0991f63 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -503,6 +503,12 @@ filegroup( visibility = ["//visibility:public"], ) +filegroup( + name = "coverage_files", + srcs = [":gcov"], + visibility = ["//visibility:public"], +) + [ filegroup( name = bin, @@ -516,6 +522,7 @@ filegroup( for bin in [ "ar", "as", + "gcov", "ld", "ld.bfd", "nm", @@ -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", @@ -598,6 +606,7 @@ filegroup( ":ar_files", ":as_files", ":compiler_files", + ":coverage_files", ":dwp_files", ":linker_files", ":objcopy_files", @@ -662,6 +671,14 @@ filegroup( ], ) +filegroup( + name = "coverage_files", + srcs = [ + "@{toolchain_files_repository_name}//:coverage_files", + ":gcov", + ], +) + filegroup( name = "gcc", srcs = [ @@ -671,6 +688,11 @@ filegroup( ], ) +filegroup( + name = "gcov", + srcs = ["bin/gcov"], +) + filegroup( name = "gfortran", srcs = ["bin/gfortran"], From 07f847daa05e43f73f3e027f923133d8c06174f5 Mon Sep 17 00:00:00 2001 From: Tobias Thiel Date: Tue, 26 Sep 2023 22:16:22 -0700 Subject: [PATCH 2/4] add test target --- examples/hello_world_cpp/BUILD.bazel | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/hello_world_cpp/BUILD.bazel b/examples/hello_world_cpp/BUILD.bazel index 72deece..929d11d 100644 --- a/examples/hello_world_cpp/BUILD.bazel +++ b/examples/hello_world_cpp/BUILD.bazel @@ -22,6 +22,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", target_platform = "//platforms:aarch64_linux", From fe16cd68dd7446d2b0537163bde0a8c3d13a91e6 Mon Sep 17 00:00:00 2001 From: Tobias Thiel Date: Thu, 28 Sep 2023 22:10:27 -0700 Subject: [PATCH 3/4] attempt to run coverage in CI --- .github/workflows/default.yaml | 20 +++++++++++++++++++- .github/workflows/engflow.sh | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index a6a6c09..58ba22e 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - uses: bazelbuild/setup-bazelisk@v2 - name: Test - run: ./.github/workflows/engflow.sh --config engflow //... + run: ./.github/workflows/engflow.sh test --config engflow //... env: ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }} ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }} @@ -41,6 +41,7 @@ jobs: - name: Test run: |- ./.github/workflows/engflow.sh \ + test \ --config engflow \ --compilation_mode ${{ matrix.compilation_mode }} \ //... @@ -63,12 +64,28 @@ jobs: - name: Test ${{ matrix.sanitizer }} run: |- ./.github/workflows/engflow.sh \ + test \ --config engflow \ --config ${{ matrix.sanitizer }} \ //tests/sanitizers:${{ matrix.sanitizer }}_test env: ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }} ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }} + coverage: + if: ${{ github.ref == 'refs/heads/main' }} or ${{ github.event.label.name == 'ci-test' }} + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: bazelbuild/setup-bazelisk@v2 + - name: Test Coverage + run: |- + ./.github/workflows/engflow.sh \ + coverage \ + --config engflow \ + //examples/hello_world_cpp:hello_world_cpp_test + env: + ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }} + ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }} rbe: if: ${{ github.ref == 'refs/heads/main' }} or ${{ github.event.label.name == 'ci-test' }} strategy: @@ -83,6 +100,7 @@ jobs: - name: Test with RBE run: |- ./.github/workflows/engflow.sh \ + test \ --config rbe \ --config engflow \ --config engflow_rbe \ diff --git a/.github/workflows/engflow.sh b/.github/workflows/engflow.sh index 6202e48..88ed60b 100755 --- a/.github/workflows/engflow.sh +++ b/.github/workflows/engflow.sh @@ -23,7 +23,7 @@ function on_exit { trap on_exit EXIT -bazel test \ +bazel "$1" \ --tls_client_certificate="${crt_file}" \ --tls_client_key="${key_file}" \ - "$@" + "${@:2}" From 30f59a47f01ce000dbcaf56aea1dc2b94b6ab504 Mon Sep 17 00:00:00 2001 From: Tobias Thiel Date: Tue, 10 Oct 2023 20:44:03 -0700 Subject: [PATCH 4/4] remove unnedded workflow settings --- .github/workflows/default.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index a3d5eb1..f920c2c 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -63,18 +63,11 @@ jobs: env: BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} coverage: - strategy: - matrix: - sanitizer: - - asan - - lsan - - tsan - - ubsan runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - uses: bazelbuild/setup-bazelisk@v2 - - name: Test ${{ matrix.sanitizer }} + - name: Test Coverage run: | ./.github/workflows/configurebb.sh bazel coverage --config ci //examples/hello_world_cpp:hello_world_cpp_test