Skip to content

Commit 12be53d

Browse files
committed
Try adding test coverage check
1 parent a401d3f commit 12be53d

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

.github/workflows/codecov.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Upload CodeCov Report
2+
3+
on:
4+
push:
5+
branches: [ refactoring ]
6+
pull_request:
7+
branches: [ refactoring ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v2
17+
18+
- name: Configure
19+
run: cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIPC_BUILD_TESTS=ON -DLIBIPC_CODECOV=ON .
20+
21+
- name: Build
22+
run: make -j
23+
24+
- name: Test
25+
env:
26+
LD_LIBRARY_PATH: ./lib
27+
run: ./bin/test-ipc
28+
29+
- name: Upload coverage to Codecov
30+
uses: codecov/[email protected]
31+
with:
32+
verbose: true
33+
env:
34+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
cmake_minimum_required(VERSION 3.11)
1+
cmake_minimum_required(VERSION 3.13)
22
project(cpp-ipc)
33

44
option(LIBIPC_BUILD_TESTS "Build all of libipc's own tests." OFF)
55
option(LIBIPC_BUILD_DEMOS "Build all of libipc's own demos." OFF)
66
option(LIBIPC_BUILD_BENCHMARK "Build all of libipc's own benchmark tests." OFF)
77
option(LIBIPC_BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
88
option(LIBIPC_USE_STATIC_CRT "Set to ON to build with static CRT on Windows (/MT)." OFF)
9+
option(LIBIPC_CODECOV "Build with unit test coverage." OFF)
910

1011
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1112
set(CMAKE_CXX_STANDARD 17)
@@ -31,8 +32,15 @@ if (MSVC)
3132
endforeach()
3233
endif()
3334
else()
34-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
35-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -rdynamic -fsanitize=address")
35+
add_compile_options(
36+
"$<$<BOOL:${LIBIPC_CODECOV}>:SHELL:--coverage>"
37+
"$<$<CONFIG:Release>:SHELL:-DNDEBUG -O2>"
38+
"$<$<CONFIG:Debug>:SHELL:-g -rdynamic -fsanitize=address>"
39+
)
40+
add_link_options(
41+
"$<$<BOOL:${LIBIPC_CODECOV}>:SHELL:-lgcov --coverage>"
42+
"$<$<CONFIG:Debug>:SHELL:-fsanitize=address>"
43+
)
3644
endif()
3745

3846
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
@@ -73,4 +81,4 @@ endif()
7381
install(
7482
DIRECTORY "include/"
7583
DESTINATION "include"
76-
)
84+
)

0 commit comments

Comments
 (0)