Skip to content

fix: use gcovr version supporting merge-lines #22

fix: use gcovr version supporting merge-lines

fix: use gcovr version supporting merge-lines #22

name: CMake on multiple platforms
on:
workflow_call:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure CMake
run: >
cmake -B ${{ github.workspace }}/build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=Release
-DQUEUE_BUILD_DOCUMENTATION=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build --config Release --parallel
- name: Test
run: ctest --test-dir ${{ github.workspace }}/build --build-config Release --output-on-failure
coverage:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install gcovr
run: python -m pip install gcovr==8.4
- name: Configure coverage build
run: >
cmake -B ${{ github.workspace }}/build-coverage
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_FLAGS=--coverage
-DQUEUE_BUILD_DOCUMENTATION=OFF
-S ${{ github.workspace }}
- name: Build and test
run: |
cmake --build ${{ github.workspace }}/build-coverage --parallel
ctest --test-dir ${{ github.workspace }}/build-coverage --output-on-failure
- name: Enforce coverage
run: >
gcovr
--root ${{ github.workspace }}
--filter '${{ github.workspace }}/include/'
--merge-lines
--exclude-unreachable-branches
--exclude-throw-branches
--exclude-branches-by-pattern '.*assert\(.*'
--fail-under-line 87
--fail-under-branch 80
--fail-under-function 96
--print-summary
${{ github.workspace }}/build-coverage
sanitizers:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Configure ASan and UBSan build
run: >
cmake -B ${{ github.workspace }}/build-sanitizers
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_FLAGS=-fsanitize=address,undefined\ -fno-omit-frame-pointer
-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined
-DQUEUE_BUILD_DOCUMENTATION=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build-sanitizers --parallel
- name: Test
run: ctest --test-dir ${{ github.workspace }}/build-sanitizers --output-on-failure
env:
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1