Skip to content

Commit

Permalink
Codecov added
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPinezhaninov committed Dec 3, 2023
1 parent 9cc1630 commit ebd5fdd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build and test

on: [push]
on: push

jobs:
build:
Expand Down Expand Up @@ -62,6 +62,7 @@ jobs:
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DASYNC_PROMISE_BUILD_TESTS=ON
-DASYNC_PROMISE_CODECOV=ON
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
Expand All @@ -76,3 +77,17 @@ 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: Prepare coverage reports
if: ${{ success() && 'ubuntu-latest' == matrix.os && 'g++' == matrix.cpp_compiler }}
run: |
sudo apt update && sudo apt install -y lcov
cd ${{ steps.strings.outputs.build-output-dir }}
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info "/usr/*" "*/tests/src/*" "*/catch2/*" --output-file coverage.info
- name: Upload coverage reports to Codecov
if: ${{ success() && 'ubuntu-latest' == matrix.os && 'g++' == matrix.cpp_compiler }}
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ebd5fdd

Please sign in to comment.