From 3f1c0544c07e99d30496d1f10b8f4415c03c18e8 Mon Sep 17 00:00:00 2001 From: Gary Miguel Date: Sat, 16 Sep 2023 17:50:40 -0700 Subject: [PATCH] enable codecov in GH check (#77) Change-Id: I2ee14831a7562c5735f20ccedd13fb2e887cbcdc --- .github/workflows/check.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/ci.bazelrc | 12 ++++++++++++ 2 files changed, 43 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index bf75164..eecdee2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -40,6 +40,37 @@ jobs: --features=${{ matrix.feature }} \ //... + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: mount bazel cache + uses: actions/cache@v3 + with: + path: "~/.cache/bazel" + key: bazel-coverage + + - name: install libtinfo5 + # clang tools load libtinfo5 for color diagnostics but `ubuntu-latest` + # runners already have `libtinfo.so.6` installed. We just create a + # symlink since it's faster than installing libtinfo5. + # https://github.com/circleci/circleci-images/issues/430#issuecomment-522602495 + run: | + sudo ln -s /lib/x86_64-linux-gnu/libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.5 + + - run: | + bazel \ + --bazelrc=.github/workflows/ci.bazelrc \ + coverage \ + //... + + - uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./bazel-out/_coverage/_coverage_report.dat + fail_ci_if_error: true + build: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 5af51c3..1cbc97a 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -9,3 +9,15 @@ build --remote_download_minimal test --test_output=all test --test_verbose_timeout_warnings + +coverage --combined_report=lcov +coverage --strategy=CoverageReport=local +# At least some of this is needed for the coverage tool to work. +coverage --experimental_split_coverage_postprocessing +coverage --experimental_fetch_all_coverage_outputs +coverage --remote_download_outputs=all +coverage --experimental_remote_download_regex=.*/((testlogs/.*/_coverage/.*)|coverage.dat$|_coverage/_coverage_report.dat$) +# Not sure why it doesn't work with clang. Should be possible. +coverage --extra_toolchains=//toolchain:gcc +# Needed because our tests are in a different package than the code they test. +coverage --instrumentation_filter='//.*'