CI: added code coverage workflow
This commit is contained in:
63
.github/workflows/coverage.yml
vendored
Normal file
63
.github/workflows/coverage.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
name: Code coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master", "test"]
|
||||
paths-ignore:
|
||||
- 'docker-compose/**'
|
||||
- 'docs/**'
|
||||
- 'README.md'
|
||||
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
coverage:
|
||||
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev lcov
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_COVERAGE=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool_tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd tests/build
|
||||
gunzip *.gz
|
||||
./p2pool_tests
|
||||
|
||||
- name: Run gcov
|
||||
run: |
|
||||
cd tests/build/CMakeFiles/p2pool_tests.dir/home/runner/work/p2pool/p2pool/src
|
||||
gcov-14 *.gcda
|
||||
|
||||
- name: Run lcov
|
||||
run: |
|
||||
cd tests/build/CMakeFiles/p2pool_tests.dir/home/runner/work/p2pool/p2pool/src
|
||||
lcov --gcov-tool gcov-14 --directory . --capture --output-file coverage.info
|
||||
|
||||
- name: Run genhtml
|
||||
run: |
|
||||
cd tests/build/CMakeFiles/p2pool_tests.dir/home/runner/work/p2pool/p2pool/src
|
||||
genhtml --demangle-cpp -o coverage coverage.info
|
||||
|
||||
- name: Archive coverage data
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: p2pool-coverage
|
||||
path: tests/build/CMakeFiles/p2pool_tests.dir/home/runner/work/p2pool/p2pool/src/coverage
|
||||
@@ -5,6 +5,7 @@ include(cmake/standard.cmake)
|
||||
|
||||
option(STATIC_LIBS "Use locally built libuv and libzmq static libs" OFF)
|
||||
option(WITH_LTO "Use link-time compiler optimization (if linking fails for you, run cmake with -DWITH_LTO=OFF)" ON)
|
||||
option(WITH_COVERAGE "Generate code coverage data" OFF)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
set(WARNING_FLAGS "-Wall -Wextra")
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(OPTIMIZATION_FLAGS "-O0 -g3 -ftrapv")
|
||||
set(OPTIMIZATION_FLAGS "-O0 -g3")
|
||||
if (WITH_COVERAGE)
|
||||
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} --coverage")
|
||||
endif()
|
||||
else()
|
||||
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -s")
|
||||
if (WITH_LTO)
|
||||
|
||||
Reference in New Issue
Block a user