Skip to content

Commit 51f863b

Browse files
committed
[INFRA] Add Coverage CI
1 parent 93fbbaa commit 51f863b

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed

.github/workflows/ci_coverage.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
name: Coverage
6+
7+
on:
8+
push:
9+
branches:
10+
- 'main'
11+
pull_request:
12+
types:
13+
- unlabeled
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: coverage-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: ${{ github.event_name != 'push' }}
19+
20+
env:
21+
SEQAN3_NO_VERSION_CHECK: 1
22+
TZ: Europe/Berlin
23+
24+
defaults:
25+
run:
26+
shell: bash -Eeuxo pipefail {0}
27+
28+
jobs:
29+
build:
30+
runs-on: ubuntu-latest
31+
name: ${{ matrix.compiler }}
32+
if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint'
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
compiler: ["gcc-14"]
37+
container:
38+
image: ghcr.io/seqan/${{ matrix.compiler }}
39+
volumes:
40+
- /home/runner:/home/runner
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
47+
- name: Load ccache
48+
uses: actions/cache@v4
49+
with:
50+
path: /home/runner/.ccache
51+
save-always: true
52+
key: ccache-${{ runner.os }}-${{ github.workflow }}-${{ matrix.compiler }}-${{ github.ref }}
53+
54+
- name: Configure tests
55+
run: |
56+
mkdir build && cd build
57+
cmake .. -DCMAKE_BUILD_TYPE=Coverage
58+
make gtest_main
59+
60+
- name: Build tests
61+
working-directory: build
62+
run: |
63+
ccache -z
64+
make -k tests
65+
ccache -svvx
66+
67+
- name: Run tests
68+
working-directory: build
69+
run: ctest . -j --output-on-failure
70+
71+
- name: Generate coverage report
72+
run: |
73+
gcovr --root ${GITHUB_WORKSPACE} \
74+
${GITHUB_WORKSPACE}/build \
75+
--filter ${GITHUB_WORKSPACE}/include \
76+
--filter ${GITHUB_WORKSPACE}/src \
77+
--exclude-lines-by-pattern '^\s*$' \
78+
--exclude-lines-by-pattern '^\s*};$' \
79+
--exclude-lines-by-pattern '^\s*\.[^\s]* = .*[\n,]$' \
80+
--exclude-lines-by-pattern '^\s*\.[^\s]* = .*}\);$' \
81+
--exclude-lines-by-pattern '^\s*\.[^\s]* =(\s+\".*\")+' \
82+
--exclude-unreachable-branches \
83+
--exclude-throw-branches \
84+
--exclude-noncode-lines \
85+
-j \
86+
--cobertura \
87+
--output ${GITHUB_WORKSPACE}/build/coverage_report.xml
88+
89+
- name: Submit coverage report
90+
uses: codecov/[email protected]
91+
with:
92+
files: build/coverage_report.xml
93+
fail_ci_if_error: false

.github/workflows/ci_lint.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ jobs:
3434
steps:
3535
- name: "Cancel macOS"
3636
run: echo "Cancelling macOS"
37+
cancel_coverage:
38+
name: Cancel running Workflows
39+
concurrency:
40+
group: coverage-${{ github.event.pull_request.number }}
41+
cancel-in-progress: true
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: "Cancel Coverage"
45+
run: echo "Cancelling Coverage"
3746
lint:
3847
name: Lint
3948
concurrency:
4049
group: lint-${{ github.event.pull_request.number }}
4150
cancel-in-progress: true
42-
needs: [cancel_linux, cancel_macos]
51+
needs: [cancel_linux, cancel_macos, cancel_coverage]
4352
runs-on: ubuntu-latest
4453
timeout-minutes: 15
4554
steps:

cmake/test/config.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
33
# SPDX-License-Identifier: CC0-1.0
44

5+
include (test/coverage)
6+
57
CPMGetPackage (googletest)
68

79
list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") # Must be before `enable_testing ()`.

cmake/test/coverage.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: 2006-2024, Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
# Add a custom build type: Coverage
6+
set (CMAKE_CXX_FLAGS_COVERAGE
7+
"${CMAKE_CXX_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path"
8+
CACHE STRING "Flags used by the C++ compiler during coverage builds." FORCE)
9+
set (CMAKE_C_FLAGS_COVERAGE
10+
"${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path"
11+
CACHE STRING "Flags used by the C compiler during coverage builds." FORCE)
12+
set (CMAKE_EXE_LINKER_FLAGS_COVERAGE
13+
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,-lgcov"
14+
CACHE STRING "Flags used for linking binaries during coverage builds." FORCE)
15+
set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE
16+
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,-lgcov"
17+
CACHE STRING "Flags used by the shared libraries linker during coverage builds." FORCE)
18+
19+
mark_as_advanced (CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE
20+
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)

0 commit comments

Comments
 (0)