Skip to content

Commit 0617447

Browse files
Add coverage building to github
1 parent a631735 commit 0617447

2 files changed

Lines changed: 140 additions & 44 deletions

File tree

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Coverage Report
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- gcovr_github
8+
paths:
9+
- .github/workflows/*.yml
10+
- '**CMakeLists.txt'
11+
- 'cmake/**'
12+
- 'examples/**'
13+
- 'src/**'
14+
- '!**Makefile'
15+
- '!**md'
16+
pull_request:
17+
branches:
18+
- main
19+
paths:
20+
- .github/workflows/*.yml
21+
- '**CMakeLists.txt'
22+
- 'cmake/**'
23+
- 'examples/**'
24+
- 'src/**'
25+
- '!**Makefile'
26+
- '!**md'
27+
28+
#env:
29+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
30+
31+
defaults:
32+
run:
33+
shell: bash
34+
35+
jobs:
36+
37+
coverage:
38+
name: Coverage Build
39+
# Use GNU compilers
40+
41+
# The CMake configure and build commands are platform agnostic and should work equally
42+
# well on Windows or Mac. You can convert this to a matrix build if you need
43+
# cross-platform coverage.
44+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
45+
runs-on: ${{ matrix.os }}
46+
timeout-minutes: 5
47+
48+
env:
49+
BUILD_TYPE: Debug
50+
FFLAGS: ${{ matrix.fflags }}
51+
52+
strategy:
53+
fail-fast: true
54+
matrix:
55+
os: [ ubuntu-latest ]
56+
fflags: [
57+
"-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -fimplicit-none -frecursive -fopenmp" ]
58+
# Better flags but not used by now:
59+
# "-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -Werror=conversion -fimplicit-none -frecursive -fcheck=all",
60+
# "-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -Werror=conversion -fimplicit-none -frecursive -fcheck=all -fopenmp" ]
61+
62+
steps:
63+
64+
- name: Checkout SLICOT
65+
uses: actions/checkout@v4.2.2
66+
67+
- name: Install basics (Ubuntu)
68+
if: ${{ matrix.os == 'ubuntu-latest' }}
69+
run: |
70+
sudo apt update
71+
sudo apt install -y cmake liblapack-dev libblas-dev gcovr
72+
73+
- name: Configure CMake
74+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
75+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
76+
run: >
77+
cmake -B build -G Ninja
78+
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
79+
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/lapack_install
80+
-D SLICOT_TESTING:BOOL=ON
81+
-D BUILD_SHARED_LIBS:BOOL=ON
82+
-D ENABLE_COVERAGE:BOOL=ON
83+
84+
- name: Build
85+
working-directory: ${{github.workspace}}/build
86+
run: ninja
87+
88+
- name: Test
89+
working-directory: ${{github.workspace}}/build
90+
run: ninja test
91+
- name: Collect coverage results
92+
working-directory: ${{github.workspace}}/build
93+
run: ninja gcov
94+
95+
96+
- name: Generate HTML Report
97+
uses: threeal/gcovr-action@v1.2.0
98+
with:
99+
html-out: coverage.html
100+
xml-out: cobertura.xml
101+
coveralls-out: coveralls.json
102+
print-summary: true
103+
root: ${{github.workspace}}
104+
105+
- name: Produce the coverage report
106+
uses: insightsengineering/coverage-action@v3
107+
with:
108+
# Path to the Cobertura XML report.
109+
path: ./cobertura.xml
110+
# Minimum total coverage, if you want to the
111+
# workflow to enforce it as a standard.
112+
# This has no effect if the `fail` arg is set to `false`.
113+
threshold: 45.00
114+
# Fail the workflow if the minimum code coverage
115+
# reuqirements are not satisfied.
116+
fail: true
117+
# Publish the rendered output as a PR comment
118+
publish: true
119+
# Create a coverage diff report.
120+
diff: false
121+
# Branch to diff against.
122+
# Compare the current coverage to the coverage
123+
# determined on this branch.
124+
diff-branch: main
125+
# This is where the coverage reports for the
126+
# `diff-branch` are stored.
127+
# Branch is created if it doesn't already exist'.
128+
diff-storage: _xml_coverage_reports
129+
# A custom title that can be added to the code
130+
# coverage summary in the PR comment.
131+
coverage-summary-title: "Code Coverage Summary"
132+
# Failure modes for coverage regression detection:
133+
# Fail if any changed file has more uncovered lines (pycobertura exit code 2)
134+
uncovered-statements-increase-failure: false
135+
# Fail if new uncovered statements are introduced despite overall improvement (pycobertura exit code 3)
136+
new-uncovered-statements-failure: false
137+
# Fail if the overall coverage percentage decreases (more forgiving approach)
138+
coverage-rate-reduction-failure: true
139+

.github/workflows/build-unix.yml

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -116,50 +116,7 @@ jobs:
116116
- name: Install
117117
run: cmake --build build --target install -j2
118118

119-
coverage:
120-
runs-on: ubuntu-latest
121-
env:
122-
BUILD_TYPE: Coverage
123-
FFLAGS: "-fopenmp"
124-
steps:
125-
126-
- name: Checkout SLICOT
127-
uses: actions/checkout@v4.2.2
128-
129-
- name: Install ninja-build tool
130-
uses: seanmiddleditch/gha-setup-ninja@v6
131-
132-
- name: Install basics
133-
run: |
134-
sudo apt update
135-
sudo apt install -y cmake liblapack-dev libblas-dev
136-
137-
138-
- name: Configure CMake
139-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
140-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
141-
run: >
142-
cmake -B build -G Ninja
143-
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
144-
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/lapack_install
145-
-D SLICOT_BUILD_TESTING:BOOL=ON
146-
-D SLICOT_BUILD_SHARED_LIBS:BOOL=ON
147-
148-
- name: Build
149-
# Execute tests defined by the CMake configuration.
150-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
151-
run: cmake --build build --config ${{env.BUILD_TYPE}}
152-
153-
- name: Test with OpenMP
154-
working-directory: ${{github.workspace}}/build
155-
run: ctest -C ${{env.BUILD_TYPE}} --schedule-random -j1 --output-on-failure --timeout 100
156-
157-
- name: Generate HTML Report
158-
uses: threeal/gcovr-action@v1.1.0
159-
with:
160-
html-out: coverage.html
161-
162-
# memory-check:
119+
# memory-check:
163120
# runs-on: ubuntu-latest
164121
# env:
165122
# BUILD_TYPE: Debug

0 commit comments

Comments
 (0)