Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of code coverage badge #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ jobs:
run: cmake --build build
- name: test
run: cd build && ctest --output-on-failure

ci_test_coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: cmake
run: cmake -S . -B build
- name: build
run: cmake --build build --target ci_test_coverage
- name: archive coverage report
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()
option(AMC_ENABLE_TESTS "Build the unit tests" ${MAIN_PROJECT})
option(AMC_ENABLE_BENCHMARKS "Build the benchmarks" ${MAIN_PROJECT})
option(AMC_ENABLE_ASAN "Compile with AddressSanitizer" ${ASAN_BUILD})
option(AMC_ENABLE_GCOV "Compile for gcov" OFF)

# Activate all warnings, in all build modes
if(MAIN_PROJECT)
Expand All @@ -36,10 +37,14 @@ endif(MAIN_PROJECT)

if(AMC_ENABLE_ASAN)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize-recover=all")
add_compile_options(-g -fsanitize=address -fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize-recover=all)
endif()
endif()

if(AMC_ENABLE_GCOV)
add_compile_options(-fprofile-arcs -fprofile-abs-path -ftest-coverage)
endif(AMC_ENABLE_GCOV)

# Create interface library for header files
add_library(amc INTERFACE)
add_library(amc::amc ALIAS amc)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Ubuntu](https://github.com/AmadeusITGroup/amc/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/AmadeusITGroup/amc/actions/workflows/ubuntu.yml)
[![Windows](https://github.com/AmadeusITGroup/amc/actions/workflows/windows.yml/badge.svg)](https://github.com/AmadeusITGroup/amc/actions/workflows/windows.yml)
[![MacOS](https://github.com/AmadeusITGroup/amc/actions/workflows/macos.yml/badge.svg)](https://github.com/AmadeusITGroup/amc/actions/workflows/macos.yml)
[![Coverage Status](https://coveralls.io/repos/github/AmadeusITGroup/amc/badge.svg)](https://coveralls.io/github/AmadeusITGroup/amc)

# AMadeus (C++) Containers

Expand Down
3 changes: 3 additions & 0 deletions src/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ function(add_bench name)
target_include_directories(${name} PRIVATE ../include)
target_include_directories(${name} PRIVATE ../test)
target_link_libraries(${name} PRIVATE benchmark::benchmark)
if(AMC_ENABLE_GCOV)
target_link_libraries(${name} PRIVATE gcov)
endif(AMC_ENABLE_GCOV)
endfunction()

add_bench(
Expand Down
3 changes: 3 additions & 0 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function(add_unit_test name)
add_executable(${name} ${MY_UNPARSED_ARGUMENTS})
target_link_libraries(${name} PRIVATE gtest gmock gmock_main)
target_include_directories(${name} PRIVATE ../include)
if(AMC_ENABLE_GCOV)
target_link_libraries(${name} PRIVATE gcov)
endif(AMC_ENABLE_GCOV)

add_test(NAME ${name} COMMAND ${name})
set_tests_properties(${name} PROPERTIES
Expand Down