Skip to content

build/ci: Add coverage support #71

build/ci: Add coverage support

build/ci: Add coverage support #71

Workflow file for this run

name: CI
on:
push:
tags:
- v*
branches:
- main
pull_request:
merge_group:
# none-all, which doesn't exist, but
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow
# implies that the token still gets created. Elsewhere we learn that any
# permission not mentioned here gets turned to `none`.
permissions:
actions: none
jobs:
test:
strategy:
matrix:
compiler: [ gcc, clang ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install dependencies
run: |
sudo apt-get install -y \
curl \
scons \
bison \
flex \
dejagnu \
lcov \
${{ matrix.compiler }}
- name: test
run: scons coverage=yes check coverage.info
env:
CC: ${{ matrix.compiler }}
- uses: codecov/codecov-action@v4
with:
file: coverage.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: distcheck
run: scons distcheck
env:
CC: ${{ matrix.compiler }}
bazel_test:
runs-on: ubuntu-latest
permissions:
# publish-unit-test-result-action
# writes a comment to the PR
pull-requests: write
# and writes to the checks API
checks: write
steps:
- uses: actions/checkout@v4
- name: mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel
- name: install dependencies
run: |
sudo apt-get install -y \
dejagnu \
gcc \
llvm
dpkg -S llvm-cov
- name: bazel test
run: bazel coverage --explain=explain.out -s --test_env=VERBOSE_COVERAGE=1 --test_env=DISPLAY_LCOV_CMD=1 --test_output=all --combined_report=lcov --instrument_test_targets --nocache_test_results --instrumentation_filter="^//" //...
- name: copy test results into workspace
if: always()
run: cp -Lpr $(bazel info bazel-testlogs)/ test-results
- run: cat explain.out
if: always()
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test-results/**/test.xml
- uses: codecov/codecov-action@v4
with:
file: bazel-out/_coverage/_coverage_report.dat
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}