Skip to content

Commit

Permalink
add coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Nov 21, 2021
1 parent d3c954c commit c687db9
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 9 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: ci

env:
CTEST_PARALLEL_LEVEL: 3
CTEST_PARALLEL_LEVEL: 4
CMAKE_BUILD_PARALLEL_LEVEL: 4
CMAKE_BUILD_TYPE: Release

on:
Expand Down Expand Up @@ -39,7 +40,7 @@ jobs:
- name: configure examples
run: cmake -S Examples -B Examples/build -Dnc4fortran_ROOT=${HOME}
- name: build examples
run: cmake --build Examples/build --parallel
run: cmake --build Examples/build
- name: Test examples
run: ctest --test-dir Examples/build -V

Expand Down Expand Up @@ -70,6 +71,36 @@ jobs:
run: ctest --test-dir Examples/build -V


linux-coverage:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: install hdf5
run: |
sudo apt update -yq
sudo apt install -yq --no-install-recommends libnetcdff-dev
- name: install Gcovr
run: pip install gcovr

- run: cmake --preset coverage
- run: cmake --build --preset coverage --parallel

- name: Code coverage
run: cmake --build --preset run-coverage

- uses: actions/upload-artifact@v2
with:
name: coverage-report-html
path: build-coverage/coverage/


mac:
needs: linux
runs-on: macos-latest
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci_meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:

jobs:

meson:
linux:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -20,7 +21,7 @@ jobs:
- run: pip install meson ninja
- run: |
sudo apt update -yq
sudo apt install -yq --no-install-recommends gfortran libnetcdff-dev
sudo apt install -yq --no-install-recommends libnetcdff-dev
- run: meson setup build
- run: meson compile -C build
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ include(cmake/libraries.cmake)
# --- find NetCDF4

if(NOT netcdf_external)
find_package(NetCDF COMPONENTS Fortran)
if(autobuild)
find_package(NetCDF COMPONENTS Fortran)
else()
find_package(NetCDF COMPONENTS Fortran REQUIRED)
endif()
endif()

if(NOT NetCDF_FOUND OR netcdf_external)
Expand Down
22 changes: 21 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@
"displayName": "build all libraries",
"description": "Build all external libraries without searching for existing libraries.",
"cacheVariables": {
"netcdf_external": "on"
"netcdf_external": true
}
},
{
"name": "coverage",
"binaryDir": "${sourceDir}/build-coverage",
"displayName": "Code Coverage",
"description": "Build with code coverage enabled.",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"ENABLE_COVERAGE": true,
"autobuild": false
}
},
{
Expand All @@ -35,6 +46,15 @@
"name": "debug",
"configurePreset": "multi",
"configuration": "Debug"
},
{
"name": "coverage",
"configurePreset": "coverage"
},
{
"name": "run-coverage",
"configurePreset": "coverage",
"targets": "coverage"
}
],
"testPresets": [
Expand Down
Loading

0 comments on commit c687db9

Please sign in to comment.