Skip to content

Commit 3497947

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

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+
paths:
8+
- .github/workflows/*.yml
9+
- '**CMakeLists.txt'
10+
- 'cmake/**'
11+
- 'examples/**'
12+
- 'src/**'
13+
- '!**Makefile'
14+
- '!**md'
15+
pull_request:
16+
branches:
17+
- main
18+
paths:
19+
- .github/workflows/*.yml
20+
- '**CMakeLists.txt'
21+
- 'cmake/**'
22+
- 'examples/**'
23+
- 'src/**'
24+
- '!**Makefile'
25+
- '!**md'
26+
27+
#env:
28+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
29+
30+
defaults:
31+
run:
32+
shell: bash
33+
34+
jobs:
35+
36+
coverage:
37+
name: Coverage Build
38+
# Use GNU compilers
39+
40+
# The CMake configure and build commands are platform agnostic and should work equally
41+
# well on Windows or Mac. You can convert this to a matrix build if you need
42+
# cross-platform coverage.
43+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
44+
runs-on: ${{ matrix.os }}
45+
timeout-minutes: 5
46+
47+
env:
48+
BUILD_TYPE: Debug
49+
FFLAGS: ${{ matrix.fflags }}
50+
51+
strategy:
52+
fail-fast: true
53+
matrix:
54+
os: [ ubuntu-latest ]
55+
fflags: [
56+
"-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -fimplicit-none -frecursive -fopenmp" ]
57+
# Better flags but not used by now:
58+
# "-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -Werror=conversion -fimplicit-none -frecursive -fcheck=all",
59+
# "-Wall -Wno-unused-dummy-argument -Wno-unused-variable -Wno-unused-label -Werror=conversion -fimplicit-none -frecursive -fcheck=all -fopenmp" ]
60+
61+
steps:
62+
63+
- name: Checkout SLICOT
64+
uses: actions/checkout@v4.2.2
65+
66+
- name: Install basics (Ubuntu)
67+
if: ${{ matrix.os == 'ubuntu-latest' }}
68+
run: |
69+
sudo apt update
70+
sudo apt install -y cmake liblapack-dev libblas-dev gcovr
71+
72+
- name: Configure CMake
73+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
74+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
75+
run: >
76+
cmake -B build -G Ninja
77+
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
78+
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/lapack_install
79+
-D SLICOT_TESTING:BOOL=ON
80+
-D BUILD_SHARED_LIBS:BOOL=ON
81+
-D ENABLE_COVERAGE:BOOL=ON
82+
83+
- name: Build
84+
working-directory: ${{github.workspace}}/build
85+
run: ninja
86+
87+
- name: Test
88+
working-directory: ${{github.workspace}}/build
89+
run: ninja test
90+
- name: Collect coverage results
91+
working-directory: ${{github.workspace}}/build
92+
run: ninja gcov
93+
94+
95+
- name: Generate HTML Report
96+
uses: threeal/gcovr-action@v1.2.0
97+
with:
98+
html-out: coverage.html
99+
xml-out: cobertura.xml
100+
coveralls-out: coveralls.json
101+
print-summary: true
102+
root: ${{github.workspace}}
103+
104+
- name: Produce the coverage report
105+
uses: insightsengineering/coverage-action@v3
106+
with:
107+
# Path to the Cobertura XML report.
108+
path: ./cobertura.xml
109+
# Minimum total coverage, if you want to the
110+
# workflow to enforce it as a standard.
111+
# This has no effect if the `fail` arg is set to `false`.
112+
threshold: 45.00
113+
# Fail the workflow if the minimum code coverage
114+
# reuqirements are not satisfied.
115+
fail: true
116+
# Publish the rendered output as a PR comment
117+
publish: true
118+
exclude-detailed-coverage: true
119+
# Create a coverage diff report.
120+
diff: true
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)