Skip to content

Commit c687db9

Browse files
committed
add coverage test
1 parent d3c954c commit c687db9

File tree

8 files changed

+789
-9
lines changed

8 files changed

+789
-9
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: ci
22

33
env:
4-
CTEST_PARALLEL_LEVEL: 3
4+
CTEST_PARALLEL_LEVEL: 4
5+
CMAKE_BUILD_PARALLEL_LEVEL: 4
56
CMAKE_BUILD_TYPE: Release
67

78
on:
@@ -39,7 +40,7 @@ jobs:
3940
- name: configure examples
4041
run: cmake -S Examples -B Examples/build -Dnc4fortran_ROOT=${HOME}
4142
- name: build examples
42-
run: cmake --build Examples/build --parallel
43+
run: cmake --build Examples/build
4344
- name: Test examples
4445
run: ctest --test-dir Examples/build -V
4546

@@ -70,6 +71,36 @@ jobs:
7071
run: ctest --test-dir Examples/build -V
7172

7273

74+
linux-coverage:
75+
runs-on: ubuntu-latest
76+
timeout-minutes: 10
77+
78+
steps:
79+
- uses: actions/checkout@v2
80+
- uses: actions/setup-python@v2
81+
with:
82+
python-version: '3.x'
83+
84+
- name: install hdf5
85+
run: |
86+
sudo apt update -yq
87+
sudo apt install -yq --no-install-recommends libnetcdff-dev
88+
89+
- name: install Gcovr
90+
run: pip install gcovr
91+
92+
- run: cmake --preset coverage
93+
- run: cmake --build --preset coverage --parallel
94+
95+
- name: Code coverage
96+
run: cmake --build --preset run-coverage
97+
98+
- uses: actions/upload-artifact@v2
99+
with:
100+
name: coverage-report-html
101+
path: build-coverage/coverage/
102+
103+
73104
mac:
74105
needs: linux
75106
runs-on: macos-latest

.github/workflows/ci_meson.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99

1010
jobs:
1111

12-
meson:
12+
linux:
13+
timeout-minutes: 15
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v2
@@ -20,7 +21,7 @@ jobs:
2021
- run: pip install meson ninja
2122
- run: |
2223
sudo apt update -yq
23-
sudo apt install -yq --no-install-recommends gfortran libnetcdff-dev
24+
sudo apt install -yq --no-install-recommends libnetcdff-dev
2425
2526
- run: meson setup build
2627
- run: meson compile -C build

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ include(cmake/libraries.cmake)
3535
# --- find NetCDF4
3636

3737
if(NOT netcdf_external)
38-
find_package(NetCDF COMPONENTS Fortran)
38+
if(autobuild)
39+
find_package(NetCDF COMPONENTS Fortran)
40+
else()
41+
find_package(NetCDF COMPONENTS Fortran REQUIRED)
42+
endif()
3943
endif()
4044

4145
if(NOT NetCDF_FOUND OR netcdf_external)

CMakePresets.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@
1313
"displayName": "build all libraries",
1414
"description": "Build all external libraries without searching for existing libraries.",
1515
"cacheVariables": {
16-
"netcdf_external": "on"
16+
"netcdf_external": true
17+
}
18+
},
19+
{
20+
"name": "coverage",
21+
"binaryDir": "${sourceDir}/build-coverage",
22+
"displayName": "Code Coverage",
23+
"description": "Build with code coverage enabled.",
24+
"cacheVariables": {
25+
"CMAKE_BUILD_TYPE": "Debug",
26+
"ENABLE_COVERAGE": true,
27+
"autobuild": false
1728
}
1829
},
1930
{
@@ -35,6 +46,15 @@
3546
"name": "debug",
3647
"configurePreset": "multi",
3748
"configuration": "Debug"
49+
},
50+
{
51+
"name": "coverage",
52+
"configurePreset": "coverage"
53+
},
54+
{
55+
"name": "run-coverage",
56+
"configurePreset": "coverage",
57+
"targets": "coverage"
3858
}
3959
],
4060
"testPresets": [

0 commit comments

Comments
 (0)