Skip to content

Commit

Permalink
chore: refine coverage support
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <msclock@qq.com>
  • Loading branch information
msclock committed Mar 9, 2024
1 parent e471cf2 commit 23a0530
Show file tree
Hide file tree
Showing 28 changed files with 878 additions and 231 deletions.
63 changes: 62 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,70 @@ jobs:
exit 1 \
)
checks:
runs-on: ${{ matrix.prests.os.name }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
presets:
- {os: {name: ubuntu-latest, type: linux}, compiler: {name: gcc, type: gcc}}
- {os: {name: ubuntu-latest, type: linux}, compiler: {name: llvm, type: clang}}
- {os: {name: macos-latest, type: osx}, compiler: {name: gcc, type: gcc}}
- {os: {name: macos-latest, type: osx}, compiler: {name: llvm, type: clang}}
- {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}}
arch:
- {name: x64, type: x64}
vcpkg:
- true
- false

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.presets.compiler.name }}
vcvarsall: ${{ contains(matrix.presets.os.type, 'windows' )}}
cmake: true
ninja: true
vcpkg: ${{ matrix.vcpkg }}
ccache: true
doxygen: true
graphviz: true
python: true
gcovr: true
opencppcoverage: true

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Configure CMake
run: |
cmake -S . --preset=${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DBUILD_TESTING=ON
- name: Coverage
run: |
cmake --build out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} --target ccov-all
- name: Upload coverage report
uses: codecov/codecov-action@v4.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage/coverage.xml
flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}
name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}-coverage

pass:
if: always()
needs: [pre-commit, consistency]
needs: [pre-commit, consistency, checks]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
Expand Down
18 changes: 0 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
cmake_minimum_required(VERSION 3.20)
message(STATUS "CMAKE VERSION:${CMAKE_VERSION}")

# Vcpkg build environment
if(DEFINED ENV{VCPKG_ROOT})
message(STATUS "VCPKG_ROOT:$ENV{VCPKG_ROOT}")
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}")
else()
message(
FATAL_ERROR "Missing VCPKG_ROOT, please check the existence of VCPKG_ROOT")
endif()

# set cmake tool chain
file(TO_CMAKE_PATH ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
vcpkg_toolchain_file)
set(CMAKE_TOOLCHAIN_FILE ${vcpkg_toolchain_file})

set(VCPKG_VERBOSE
ON
CACHE BOOL "Vcpkg VCPKG_VERBOSE")

# Project settings
project(
ss-cpp
Expand Down
223 changes: 11 additions & 212 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,216 +1,15 @@
{
"version": 6,
"configurePresets": [
{
"name": "default",
"displayName": "Basic Config",
"description": "Basic build using Ninja generator",
"generator": "Ninja",
"hidden": true,
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_VERBOSE_MAKEFILE": "FALSE"
}
},
{
"name": "x64",
"architecture": {
"value": "x64",
"strategy": "external"
},
"hidden": true
},
{
"name": "x86",
"architecture": {
"value": "x86",
"strategy": "external"
},
"hidden": true
},
{
"name": "Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"hidden": true
},
{
"name": "Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"hidden": true
},
{
"name": "MSVC",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "Clang",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "ClangCL",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "GNUC",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "x64-Debug-MSVC",
"description": "MSVC for x64 (Debug)",
"inherits": [
"default",
"x64",
"Debug",
"MSVC"
]
},
{
"name": "x64-Release-MSVC",
"description": "MSVC for x64 (Release)",
"inherits": [
"default",
"x64",
"Release",
"MSVC"
]
},
{
"name": "x64-Debug-Clang",
"description": "Clang/LLVM for x64 (Debug)",
"inherits": [
"default",
"x64",
"Debug",
"Clang"
]
},
{
"name": "x64-Release-Clang",
"description": "Clang/LLVM for x64 (Release)",
"inherits": [
"default",
"x64",
"Release",
"Clang"
]
},
{
"name": "x64-Debug-ClangCL",
"description": "Clang/LLVM for x64 (Debug)",
"inherits": [
"default",
"x64",
"Debug",
"ClangCL"
]
},
{
"name": "x64-Release-ClangCL",
"description": "ClangCL/LLVM for x64 (Release)",
"inherits": [
"default",
"x64",
"Release",
"ClangCL"
]
},
{
"name": "x64-Debug-GNUC",
"description": "GNUC for x64 (Debug)",
"inherits": [
"default",
"x64",
"Debug",
"GNUC"
]
},
{
"name": "x64-Release-GNUC",
"description": "GNUC for x64 (Release)",
"inherits": [
"default",
"x64",
"Release",
"GNUC"
]
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true,
"timeout": 180,
"jobs": 8
}
}
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"include": [
"cmake/presets/x64-windows-msvc.json",
"cmake/presets/x64-linux-clang.json",
"cmake/presets/x64-linux-gcc.json",
"cmake/presets/x64-osx-clang.json",
"cmake/presets/x64-osx-gcc.json"
]
}
46 changes: 46 additions & 0 deletions cmake/presets/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": 6,
"include": [
"generators/ninja.json",
"toolchains/vcpkg.json"
],
"configurePresets": [
{
"name": "base",
"hidden": true,
"inherits": [
"ninja-multi-config",
"vcpkg"
],
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"CMAKE_VERBOSE_MAKEFILE": "FALSE"
}
}
],
"buildPresets": [
{
"name": "base",
"hidden": true,
"inherits": "ninja-multi-config",
"configurePreset": "base"
}
],
"testPresets": [
{
"name": "base",
"hidden": true,
"inherits": "ninja-multi-config",
"configurePreset": "base",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
}
]
}
13 changes: 13 additions & 0 deletions cmake/presets/compilers/clang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 6,
"configurePresets": [
{
"name": "clang",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
}
]
}
13 changes: 13 additions & 0 deletions cmake/presets/compilers/gcc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 6,
"configurePresets": [
{
"name": "gcc",
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
}
]
}
Loading

0 comments on commit 23a0530

Please sign in to comment.