build/ci: Add coverage support #75
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
cp -Lpr $(bazel info output_path)/_coverage/_coverage_report.dat coverage_report.dat | |
- uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: | | |
test-results/**/test.xml | |
- uses: codecov/codecov-action@v4 | |
with: | |
file: coverage_report.dat | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |