Skip to content

Commit

Permalink
Coverage (#1)
Browse files Browse the repository at this point in the history
* Update actions/coverage

* Update actions/coverage

* Update actions/coverage

* Update actions/coverage

* Update actions/coverage

* Update actions/coverage

* Update actions/coverage

* Update actions/coverage
  • Loading branch information
agievich authored May 10, 2024
1 parent c265ac6 commit 99d8102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@ name: coverage

on:
push:
branches: coverage
branches: master
pull_request:
branches: coverage
branches: master

jobs:
run:
name: Measure code coverage
runs-on: ubuntu-latest
steps:
- name: Install lcov
run: sudo apt install -y lcov
- name: Install llvm
run: sudo apt install -y llvm
- name: Get source
uses: actions/checkout@v3
- name: Configure CMake
run: >
CXX=g++-13 cmake -B ${{github.workspace}}/build
CXX=clang cmake -B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=Coverage
- name: Build
run: cmake --build ${{github.workspace}}/build
- name: Run tests
working-directory: ${{github.workspace}}/build
run: |
lcov -c -i -d .. -o coverage_base.info
export LLVM_PROFILE_FILE=./gf2.profraw
test/testgf2
llvm-profdata merge -sparse gf2.profraw -o gf2.profdata
llvm-cov show ./test/testgf2 -instr-profile=gf2.profdata > coverage.txt
- name: Upload coverage reports to Codecov
working-directory: ${{github.workspace}}/build
run: |
lcov -c -d .. -o coverage_test.info
lcov -a coverage_base.info -a coverage_test.info -o coverage.info
bash <(curl -s https://codecov.io/bash) -f coverage.info
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
run:
bash <(curl -s https://codecov.io/bash) -f coverage.txt
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(CMAKE_COMPILER_IS_CLANG)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -O0 -g3 \
--coverage")
-fprofile-instr-generate -fcoverage-mapping")
set(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_ASAN} -fno-common -O3 \
-fsanitize=address -fsanitize=undefined -fno-sanitize-recover \
-fsanitize-undefined-trap-on-error")
Expand All @@ -79,13 +79,6 @@ if(CMAKE_COMPILER_IS_MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
endif(CMAKE_COMPILER_IS_MSVC)

if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-fprofile-arcs -ftest-coverage")
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
Expand Down

0 comments on commit 99d8102

Please sign in to comment.