Skip to content

Commit f347b30

Browse files
Added Code Coverage CI (#450)
Co-authored-by: Henry LE BERRE <[email protected]>
1 parent a0a3ef8 commit f347b30

File tree

14 files changed

+74
-35
lines changed

14 files changed

+74
-35
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: 'Benchmark'
22

3-
on:
4-
pull_request:
3+
on: pull_request
54

65
jobs:
76
self:

.github/workflows/count.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: Check Line Counts
2-
on:
3-
push:
42

5-
pull_request:
6-
7-
workflow_dispatch:
3+
on: [push, pull_request, workflow_dispatch]
84

95
jobs:
106
sz:

.github/workflows/coverage.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Coverage Check
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
run:
7+
name: Coverage Test on CodeCov
8+
runs-on: "ubuntu-latest"
9+
steps:
10+
- name: Setup Ubuntu
11+
run: |
12+
sudo apt update -y
13+
sudo apt install -y tar wget make cmake gcc g++ python3 python3-dev "openmpi-*" libopenmpi-dev
14+
15+
- name: Checkouts
16+
uses: actions/checkout@v4
17+
18+
- name: Build
19+
run: /bin/bash mfc.sh build -j $(nproc) --gcov
20+
21+
- name: Test
22+
run: /bin/bash mfc.sh test -a -j $(nproc)
23+
24+
- name: Upload coverage reports to Codecov
25+
uses: codecov/[email protected]
26+
with:
27+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/lint.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Lint
22

3-
on:
4-
push:
5-
6-
pull_request:
7-
8-
workflow_dispatch:
3+
on: [push, pull_request, workflow_dispatch]
94

105
jobs:
116
docs:

.github/workflows/pretty.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Pretty
22

3-
on:
4-
push:
5-
6-
pull_request:
7-
8-
workflow_dispatch:
3+
on: [push, pull_request, workflow_dispatch]
94

105
jobs:
116
docs:

.github/workflows/spelling.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Spell Check
2-
on:
3-
push:
4-
workflow_dispatch:
2+
3+
on: [push, workflow_dispatch]
54

65
jobs:
76
run:

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ project(MFC LANGUAGES C CXX Fortran)
1818

1919
option(MFC_MPI "Build with MPI" ON)
2020
option(MFC_OpenACC "Build with OpenACC" OFF)
21+
option(MFC_GCov "Build with GCov" OFF)
2122
option(MFC_PRE_PROCESS "Build pre_process" OFF)
2223
option(MFC_SIMULATION "Build simulation" OFF)
2324
option(MFC_POST_PROCESS "Build post_process" OFF)
@@ -106,13 +107,34 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
106107
$<$<COMPILE_LANGUAGE:Fortran>:-ffree-line-length-none>
107108
)
108109

110+
if (MFC_GCov)
111+
112+
# Warning present in gcc versions >= 12 that is treated as an error
113+
# This flag doesn't exist in gcc versions < 12
114+
if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 12)
115+
add_compile_options(
116+
-Wno-error=coverage-invalid-line-number
117+
)
118+
endif()
119+
120+
add_compile_options(
121+
$<$<COMPILE_LANGUAGE:Fortran>:-fprofile-arcs>
122+
$<$<COMPILE_LANGUAGE:Fortran>:-ftest-coverage>
123+
)
124+
125+
add_link_options(
126+
$<$<COMPILE_LANGUAGE:Fortran>:-lgcov>
127+
$<$<COMPILE_LANGUAGE:Fortran>:--coverage>
128+
)
129+
endif()
130+
109131
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
110132
add_compile_options(
111133
-fcheck=all,no-array-temps
112134
-fbacktrace
113135
-fimplicit-none
114136
#-ffpe-trap=invalid,zero,denormal,overflow
115-
)
137+
)
116138
endif()
117139

118140
if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 10)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<a href="https://lbesson.mit-license.org/">
1818
<img src="https://img.shields.io/badge/License-MIT-blue.svg" />
1919
</a>
20+
<a href="https://codecov.io/github/MFlowCode/MFC">
21+
<img src="https://codecov.io/github/MFlowCode/MFC/graph/badge.svg?token=8SY043QND4">
22+
</a>
2023
</p>
2124

2225
Welcome to the home of MFC!

docs/documentation/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ MFC can be built with support for various (compile-time) features:
177177
| **MPI** | `--mpi` | `--no-mpi` | On | Lets MFC run on multiple processors (and nodes) simultaneously. |
178178
| **GPU** | `--gpu` | `--no-gpu` | Off | Enables GPU acceleration via OpenACC. |
179179
| **Debug** | `--debug` | `--no-debug` | Off | Requests the compiler build MFC in debug mode. |
180+
| **GCov** | `--gcov` | `--no-gcov` | Off | Builds MFC with coverage flags on. |
180181

181182
_⚠️ The `--gpu` option requires that your compiler supports OpenACC for Fortran for your target GPU architecture._
182183

toolchain/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import signal, getpass, platform, itertools, dataclasses
3+
import signal, getpass, platform, itertools
44

55
from mfc import args, lock, build, bench, state, count
66
from mfc.state import ARG
@@ -21,11 +21,11 @@ def __print_greeting():
2121
MFC_SIDEBAR_LINES = [
2222
f"[bold]{host_line}[/bold]",
2323
'-' * len(host_line),
24-
f"[bold]--jobs [magenta]{ARG('jobs')}[/magenta][/bold]"
25-
] + [
26-
f"[bold]--{'' if getattr(state.gCFG, field.name) else 'no-'}{field.name}[/bold]" for field in dataclasses.fields(state.gCFG)
27-
] + [
24+
'',
25+
f"[bold]--jobs [magenta]{ARG('jobs')}[/magenta][/bold]",
26+
f"[bold]{' '.join(state.gCFG.make_options())}[/bold]",
2827
targets_line if ARG("command") != "test" else "",
28+
'',
2929
'-' * len(help_line),
3030
f"[yellow]{help_line}[/yellow]",
3131
]

0 commit comments

Comments
 (0)