Skip to content

Add Codecov integration #22

Add Codecov integration

Add Codecov integration #22

Workflow file for this run

name: C++ tests
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Catch2
run: |
git clone https://github.com/catchorg/Catch2.git
cd Catch2
git checkout "v3.4.0"
mkdir build && cd build
cmake .. -DBUILD_TESTING=Off
make -j $(nproc)
sudo make install
- name: Install lcov
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install lcov
- name: Install gcovr
if: runner.os == 'Linux'
run: |
sudo apt install pipx
pipx install gcovr
- name: Configure
run: |
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_MEX=False -DBUILD_TESTS=True
- name: Build
run: |
cmake --build build
- name: Run tests
working-directory: ./build
run: |
ctest -C Release --output-on-failure --verbose
- name: Generate coverage report
working-directory: ./build
run: |
make coverage
gcovr -r .. . --txt-metric branch --cobertura > coverage.xml
- uses: codecov/codecov-action@v5
with:
if: runner.os == 'Linux'
working-directory: ./build
files: coverage.xml
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}