Skip to content

Commit

Permalink
Run coverage in CI
Browse files Browse the repository at this point in the history
Generate a coverage report in CI with Bazel. This requires using Linux
and version of GCC that works with the Bazel GCov parser[1]. In this
case, CI uses Ubuntu 18.04 with GCC 7.

[1]: bazelbuild/bazel#11538
  • Loading branch information
oliverlee committed Nov 21, 2020
1 parent fb45ffe commit 788cb95
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,54 @@ jobs:
find include src tests \( -name "*.cc" -o -name "*.h" \) -exec clang-format -i {} \;
git update-index --really-refresh
git --no-pager diff
coverage:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2

- name: Setup Bazel
env:
BAZEL_VERSION: "3.4.1"
run: |
sysctl kernel.unprivileged_userns_clone=1
sudo apt-get update -q
sudo apt-get install libxml2-utils -y
OS=linux
URL="https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-${OS}-x86_64.sh"
wget -O install.sh "${URL}"
chmod +x install.sh
./install.sh --user
rm -f install.sh
cat .bazelrc.ci >> .bazelrc
echo "::set-env name=CXX::$CC"
- name: Checkout Submodules
run: |
git submodule update --init --recursive --recommend-shallow
- name: Build coverage report
run: |
bazel coverage //...
- name: Install lcov
run: |
sudo apt-get install -y lcov
- name: Print coverage summary
run: |
lcov --list bazel-out/_coverage/_coverage_report.dat
- uses: actions/upload-artifact@v2
with:
name: coverage-report
path: bazel-out/_coverage/_coverage_report.dat

# - uses: codecov/codecov-action@v1
# with:
# file: ./build/coverage.info
# fail_ci_if_error: true

0 comments on commit 788cb95

Please sign in to comment.