diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 7477bff7c..c89d761f1 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -16,6 +16,31 @@ concurrency: cancel-in-progress: true jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Collect coverage data + run: | + sudo apt-get update + sudo apt-get install lcov -y + sudo apt-get install snap -y + sudo snap install cmake --classic + hash -r + cmake -B ../build -DCMAKE_BUILD_TYPE=Debug -DWITH_COVERAGE=1 -DBUILD_BLS_PYTHON_BINDINGS=0 -DBUILD_BLS_BENCHMARKS=0 + cmake --build ../build -- -j 6 + ../build/src/runtest + lcov --directory ../build --capture --output-file lcov.info + lcov --remove lcov.info '*_deps/*' '/usr/*' --output-file lcov.info + - name: Upload to Coveralls + uses: coverallsapp/github-action@v2 + if: always() + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + with: + path-to-lcov: './lcov.info' + build_wheels: name: Build and Test on ${{ matrix.os }} CPython ${{ matrix.python }} runs-on: ${{ matrix.os }} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 76f2f4568..62e325202 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,6 +52,10 @@ if(BUILD_BLS_TESTS) Catch2::Catch2 Threads::Threads ) + if(WITH_COVERAGE) + target_compile_options(runtest PRIVATE --coverage) + target_link_options(runtest PRIVATE --coverage) + endif() endif() if(BUILD_BLS_BENCHMARKS)