From f232c7d99592017d55e12f86e7eca00a2cd04396 Mon Sep 17 00:00:00 2001 From: ado Date: Tue, 8 Aug 2023 00:43:02 +0200 Subject: [PATCH] Add coverage ci --- .github/workflows/coverage.yml | 69 ++++++++++++++++++++++++++++++++++ test/CMakeLists.txt | 2 + 2 files changed, 71 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..df70a9a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,69 @@ +name: ubuntu-latest-gcc-ci + +on: + workflow_dispatch: + + push: + branches: + - master + - feature/** + - improvement/** + - bugfix/** + + pull_request: + branches: + - master + - feature/** + - improvement/** + - bugfix/** + +jobs: + gcc_tests: + if: >- + ! contains(toJSON(github.event.commits.*.message), '[skip ci]') && + ! contains(toJSON(github.event.commits.*.message), '[skip github]') + + runs-on: ubuntu-latest + + name: "Coverage" + + container: + image: gcc:latest + options: -v /usr/local:/host_usr_local + + steps: + - uses: actions/checkout@v1 + + - uses: friendlyanon/fetch-core-count@v1 + id: cores + + - name: CMake + run: echo "/host_usr_local/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: script/ci_install_deps.sh + + - name: Configure + run: cmake -S test -B build -D CMAKE_BUILD_TYPE=Debug + + - name: Build + run: cmake --build build -j ${{steps.cores.outputs.count}} + + - name: Run + working-directory: build + run: ctest --output-on-failure -j ${{steps.cores.outputs.count}} + + - name: Generate coverage report + run: | + lcov -d . -c -o out.info --rc lcov_branch_coverage=1 --no-external + lcov -e out.info '*include/ss*hpp' -o filtered_out.info + genhtml --t "SSP Coverage" --legend --demangle-cpp -o html -s --branch-coverage -p $PWD filtered_out.info + + - name: Archive coverage report + uses: actions/upload-artifact@v3 + with: + name: code-coverage-report + path: ${{github.workspace}}/html + + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index de6b612..94c3327 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_compile_options(ssp INTERFACE -Wall -Wextra) endif() +set(CMAKE_CXX_FLAGS "-Wall -fprofile-arcs -ftest-coverage --coverage") + if (MSVC) add_compile_options(/bigobj) elseif (MINGW)