From ab8774cf986e539ed696164eb9833f446ea63e8a Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Tue, 23 Jan 2024 15:11:06 -0800 Subject: [PATCH] Generate coverage build and upload --- .github/workflows/build-test-cplusplus.yml | 43 ++++++++++++++++------ CMakeLists.txt | 5 +++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-test-cplusplus.yml b/.github/workflows/build-test-cplusplus.yml index 07b590ebf..0a85683ef 100644 --- a/.github/workflows/build-test-cplusplus.yml +++ b/.github/workflows/build-test-cplusplus.yml @@ -3,18 +3,39 @@ name: Build and Test C++ on: push: branches: - - main + - main release: types: [published] pull_request: branches: - - '**' + - "**" concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} 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 + cmake -B ../build -DCMAKE_BUILD_TYPE=Debug -DWITH_COVERAGE=1 + cmake --build ../build -- -j 6 + ../build/RunTests + 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" valgrind: name: valgrind ubuntu runs-on: ubuntu-22.04 @@ -82,13 +103,13 @@ jobs: name: Windows Latest runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: cmake, RunTests with Windows - run: | - mkdir build-win - cd build-win - cmake .. - cmake --build . --config Release -j 6 - ctest -C Release -j 6 + - name: cmake, RunTests with Windows + run: | + mkdir build-win + cd build-win + cmake .. + cmake --build . --config Release -j 6 + ctest -C Release -j 6 diff --git a/CMakeLists.txt b/CMakeLists.txt index 77a48219c..d880dc209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,11 @@ target_link_libraries(RunTests blake3 ) +if(WITH_COVERAGE) +target_compile_options(RunTests PRIVATE --coverage) +target_link_options(RunTests PRIVATE --coverage) +endif() + find_package(Threads REQUIRED) add_library(uint128 STATIC uint128_t/uint128_t.cpp)