From b3847c18969bb989efc9339f4d4b4abc16eb37f5 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Wed, 10 Dec 2025 04:29:27 +0000 Subject: [PATCH 1/2] feat(ci): add codecov test coverage support to master branch Add CodeCov test coverage configuration: - Add LIBIPC_CODECOV option to CMakeLists.txt with coverage compilation flags - Add CodeCov badge to README.md for coverage status display Note: The codecov.yml workflow file needs to be added manually or requires workflows permission to push. --- CMakeLists.txt | 7 +++++++ README.md | 1 + 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e07dd3c..977cb1ba 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ option(LIBIPC_BUILD_TESTS "Build all of libipc's own tests." option(LIBIPC_BUILD_DEMOS "Build all of libipc's own demos." OFF) option(LIBIPC_BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) option(LIBIPC_USE_STATIC_CRT "Set to ON to build with static CRT on Windows (/MT)." OFF) +option(LIBIPC_CODECOV "Build with unit test coverage." OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_CXX_STANDARD 17) @@ -13,6 +14,12 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") endif() +# Code coverage support +if (LIBIPC_CODECOV AND NOT MSVC) + add_compile_options(--coverage) + add_link_options(-lgcov --coverage) +endif() + if (MSVC) set(CompilerFlags CMAKE_CXX_FLAGS diff --git a/README.md b/README.md index 8cb04e6d..fc14f3f8 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mutouyun/cpp-ipc/blob/master/LICENSE) [![Build Status](https://github.com/mutouyun/cpp-ipc/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/mutouyun/cpp-ipc/actions) +[![CodeCov](https://codecov.io/github/mutouyun/cpp-ipc/graph/badge.svg?token=MNOAOLNELH)](https://codecov.io/github/mutouyun/cpp-ipc) [![Build status](https://ci.appveyor.com/api/projects/status/github/mutouyun/cpp-ipc?branch=master&svg=true)](https://ci.appveyor.com/project/mutouyun/cpp-ipc) [![Vcpkg package](https://img.shields.io/badge/Vcpkg-package-blueviolet)](https://github.com/microsoft/vcpkg/tree/master/ports/cpp-ipc) From a8e6c7ee39a89564f96bfed9b4133a6c1fd8f7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E5=A4=B4=E4=BA=91?= Date: Wed, 10 Dec 2025 04:34:53 +0000 Subject: [PATCH 2/2] feat(ci): add CodeCov workflow for test coverage reporting --- .github/workflows/codecov.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..5698e6e7 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,34 @@ +name: Upload CodeCov Report + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Configure + run: cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIPC_BUILD_TESTS=ON -DLIBIPC_CODECOV=ON . + + - name: Build + run: make -j + + - name: Test + env: + LD_LIBRARY_PATH: ./bin + run: ./bin/test-ipc + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file