From 4c08773f868934b3fc484fb7d987a2e51ebaeb0b Mon Sep 17 00:00:00 2001 From: Gudmundur Adalsteinsson Date: Thu, 15 Jul 2021 13:21:02 +0000 Subject: [PATCH] Coveralls upload in actions --- .github/workflows/ci.yml | 32 +++++++++++++++++++++++++++++--- tests/CMakeLists.txt | 3 ++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 829e757..e3e9b69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ jobs: drafts: ["ON"] libzmq: ["4.3.4"] libzmqbuild: ["cmake"] - platform: [""] include: # older libzmq and gcc without draft - os: "ubuntu-18.04" @@ -54,6 +53,15 @@ jobs: drafts: "OFF" libzmq: "4.3.4" libzmqbuild: "cmake" + # coverage (gcc version should match gcov version) + - os: "ubuntu-latest" + cppstd: "17" + cc: "gcc-9" + cxx: "g++-9" + drafts: "ON" + libzmq: "4.3.4" + libzmqbuild: "cmake" + coverage: "-DCOVERAGE=ON" # clang - os: "ubuntu-latest" cppstd: "17" @@ -126,10 +134,9 @@ jobs: env: CMAKE_PREFIX_PATH: ${{ env.LIBZMQ }} run: | - cmake -H. -Bbuild ${{ matrix.platform}} \ + cmake -H. -Bbuild ${{ matrix.platform}} ${{ matrix.coverage }} \ -DCMAKE_BUILD_TYPE=${BUILDTYPE} \ -DENABLE_DRAFTS=${{ matrix.drafts }} \ - -DCOVERAGE=${COVERAGE} \ -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} cmake --build build --config ${BUILDTYPE} -j ${THREADS} echo "CPPZMQ=${PWD}/build" >> ${GITHUB_ENV} @@ -154,3 +161,22 @@ jobs: cmake --build build --config ${BUILDTYPE} cd build ctest -V -C ${BUILDTYPE} + + - name: lcov + if: ${{ matrix.coverage && success() }} + run: | + sudo apt install -y lcov + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info -o coverage_filtered.info \ + '/usr/include/*' \ + '/usr/local/include/*' \ + ${PWD}'/tests/*' \ + ${PWD}'/build/*' + # to generate local html: genhtml coverage_filtered.info --output-directory . + + - name: coveralls_upload + if: ${{ matrix.coverage && success() }} + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./coverage_filtered.info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ebc3c3..d0236b7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,7 +44,8 @@ OPTION (COVERAGE "Enable gcda file generation needed by lcov" OFF) if (COVERAGE) target_compile_options(unit_tests PRIVATE --coverage) - target_link_libraries(unit_tests PRIVATE --coverage) + target_link_options(unit_tests PRIVATE --coverage) + message(STATUS "Coverage enabled") endif() include(CTest)