diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7a59411..649b1ef 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -62,6 +62,7 @@ jobs: run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} -DASYNC_PROMISE_BUILD_TESTS=ON + -DASYNC_PROMISE_CODECOV_TESTS=ON -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} @@ -76,3 +77,10 @@ jobs: # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest --build-config ${{ matrix.build_type }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + gcov: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fa7934..74d71ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,12 +21,13 @@ project(async_promise LANGUAGES CXX VERSION 1.0.0) option(ASYNC_PROMISE_BUILD_EXAMPLE "Build example" OFF) option(ASYNC_PROMISE_BUILD_TESTS "Build tests" OFF) +option(ASYNC_PROMISE_CODECOV "Add test coverage" OFF) if(ASYNC_PROMISE_BUILD_EXAMPLE) add_subdirectory(example) endif() -if (ASYNC_PROMISE_BUILD_TESTS) +if(ASYNC_PROMISE_BUILD_TESTS) enable_testing() add_subdirectory(tests) endif() @@ -51,4 +52,13 @@ target_link_libraries(${TARGET} INTERFACE Threads::Threads ) +if(ASYNC_PROMISE_CODECOV AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(${TARGET} INTERFACE -O0 -g --coverage) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + target_link_options(${TARGET} INTERFACE --coverage) + else() + target_link_libraries(${TARGET} INTERFACE --coverage) + endif() +endif() + install(FILES ${HEADERS} DESTINATION include) diff --git a/README.md b/README.md index 87f5da0..cf3188e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # async::promise -![Build and test](https://github.com/IvanPinezhaninov/async_promise/actions/workflows/build-and-test.yml/badge.svg) +[![build and test](https://github.com/IvanPinezhaninov/async_promise/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/IvanPinezhaninov/async_promise/actions/workflows/build-and-test.yml) [![MIT License](https://img.shields.io/badge/license-mit-blue.svg?style=flat)](http://opensource.org/licenses/MIT) ## Overview