From 12be53d718dbcfa63eba4fd180570afbdc58b8f5 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sun, 2 Jun 2024 18:11:25 +0800 Subject: [PATCH 1/3] Try adding test coverage check --- .github/workflows/codecov.yml | 34 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..e29d619 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,34 @@ +name: Upload CodeCov Report + +on: + push: + branches: [ refactoring ] + pull_request: + branches: [ refactoring ] + +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: ./lib + 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 }} diff --git a/CMakeLists.txt b/CMakeLists.txt index d1fd61d..db65c02 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.13) project(cpp-ipc) option(LIBIPC_BUILD_TESTS "Build all of libipc's own tests." OFF) @@ -6,6 +6,7 @@ option(LIBIPC_BUILD_DEMOS "Build all of libipc's own demos." option(LIBIPC_BUILD_BENCHMARK "Build all of libipc's own benchmark tests." 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) @@ -31,8 +32,15 @@ if (MSVC) endforeach() endif() else() - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -rdynamic -fsanitize=address") + add_compile_options( + "$<$:SHELL:--coverage>" + "$<$:SHELL:-DNDEBUG -O2>" + "$<$:SHELL:-g -rdynamic -fsanitize=address>" + ) + add_link_options( + "$<$:SHELL:-lgcov --coverage>" + "$<$:SHELL:-fsanitize=address>" + ) endif() set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) @@ -73,4 +81,4 @@ endif() install( DIRECTORY "include/" DESTINATION "include" -) + ) From 48fa2d9d963dd26ca0a4ac655c6adf56a1d27b8a Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sun, 2 Jun 2024 18:19:20 +0800 Subject: [PATCH 2/3] codecov badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 65fe94e..8689a04 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) [![Vcpkg package](https://img.shields.io/badge/Vcpkg-package-blueviolet)](https://github.com/microsoft/vcpkg/tree/master/ports/cpp-ipc) A high-performance inter-process communication using shared memory on Linux/Windows. From 01da1334e154a1ce1c543eb2b415a23f9b0a4691 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sun, 2 Jun 2024 18:22:27 +0800 Subject: [PATCH 3/3] Unified CI step names --- .github/workflows/c-cpp.yml | 16 +++++++++++----- .github/workflows/codecov.yml | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 46b4d84..c7744fc 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -12,10 +12,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: cmake + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Configure run: cmake -DCMAKE_BUILD_TYPE=Release -DLIBIPC_BUILD_TESTS=ON . - - name: make + + - name: Build run: make -j - - name: test - run: export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH && ./bin/test-ipc + + - name: Test + env: + LD_LIBRARY_PATH: ./lib + run: ./bin/test-ipc diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index e29d619..e10e892 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -19,8 +19,8 @@ jobs: run: cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIPC_BUILD_TESTS=ON -DLIBIPC_CODECOV=ON . - name: Build - run: make -j - + run: make -j + - name: Test env: LD_LIBRARY_PATH: ./lib