Skip to content

Code Coverage

Code Coverage #11

Workflow file for this run

name: Code Coverage
on:
pull_request:
types: [opened, reopened, synchronize]
merge_group:
types: [checks_requested]
workflow_dispatch:
jobs:
test_with_coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: install latest cmake and Ninja
uses: lukka/get-cmake@latest
- name: install gcovr
uses: threeal/gcovr-action@v1.2.0
- name: Setup jq
uses: dcarbone/install-jq-action@v3
- name: test
run: |
echo 'testing'
cmake -E env CXXFLAGS="--coverage" cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j $(nproc) --target tests/all
ctest --test-dir build --output-on-failure
gcovr -r . --exclude='.*external.*' --exclude='.*catch2.*' --exclude='.*build.*' --exclude='.*tests.*' --exclude=cmake --gcov-ignore-errors=output_error --json-summary -o test_out.json
echo "================================================================================"
echo "Covered files:"
jq '.files[] | .filename ' test_out.json
echo "================================================================================"
curl -Os https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov --verbose upload-process --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f test_out.json