Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage during CI testing #13

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# xref: https://docs.codecov.io/docs/codecovyml-reference

# Disable annotations (annoying!)
github_checks:
annotations: false
37 changes: 36 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
test:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: ${{ matrix.os }} - ${{ matrix.compiler }} - ${{ github.event_name }}
name: ${{ matrix.os }} - ${{ matrix.compiler }} - ${{ matrix.test_type }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -36,10 +36,17 @@ jobs:
- gfortran-13
shell:
- bash
test_type:
- regular
include:
- os: windows-latest
compiler: gfortran
shell: 'msys2 {0}'
test_type: regular
- os: ubuntu-latest
compiler: gfortran-13
shell: bash
test_type: coverage
defaults:
run:
shell: ${{ matrix.shell }}
Expand Down Expand Up @@ -69,6 +76,34 @@ jobs:
- name: Run test
run: |
install/bin/smesh_run
install/bin/smesh_run smesh_example.cfg
install/bin/smesh_run smesh_test.cfg
- name: Run tests for coverage
if: ${{ matrix.test_type == 'coverage' }}
run: |
sudo apt-get install -y lcov
mkdir build-coverage
cd build-coverage
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_COVERAGE=ON
cmake --build .
cd ..
cmake --build build-coverage/ --target reset-coverage
build-coverage/smesh_run
build-coverage/smesh_run smesh_example.cfg
build-coverage/smesh_run smesh_test.cfg
cmake --build build-coverage/ --target process-coverage
- uses: codecov/codecov-action@v3
if: ${{ matrix.test_type == 'coverage' }}
with:
files: ./build-coverage/lcov.info
flags: unittests
name: codecov-umbrella
- name: Coveralls
if: ${{ matrix.test_type == 'coverage' }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build-coverage/lcov.info
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session for debugging
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && always() }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
build-coverage/
install/
*.dat
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.5.1)
cmake_minimum_required (VERSION 3.13.0)

# Get project version from `VERSION` file
file(READ "${CMAKE_SOURCE_DIR}/VERSION" version_file)
Expand Down Expand Up @@ -43,3 +43,21 @@ target_compile_options(smesh_io PRIVATE -Wall -Wextra -Werror -std=f2018)
target_compile_options(smesh_run PRIVATE -Wall -Wextra -Werror -std=f2018)

install(TARGETS smesh smesh_io smesh_run)

# Handle code coverage generation
option(WITH_COVERAGE "Generate code coverage" OFF)
if (WITH_COVERAGE)
target_compile_options(smesh PRIVATE -g --coverage -O0)
target_compile_options(smesh_io PRIVATE -g --coverage -O0)
target_compile_options(smesh_run PRIVATE -g --coverage -O0)
target_link_options(smesh PRIVATE --coverage)
target_link_options(smesh_io PRIVATE --coverage)
target_link_options(smesh_run PRIVATE --coverage)

add_custom_target(reset-coverage
COMMAND lcov --directory . --zerocounters
)
add_custom_target(process-coverage
COMMAND lcov --directory . --capture --output-file lcov.info
)
endif()
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# smesh

[![Build Status](https://github.com/trixi-framework/smesh/workflows/CI/badge.svg)](https://github.com/trixi-framework/smesh/actions?query=workflow%3ACI)
[![Coveralls](https://coveralls.io/repos/github/trixi-framework/smesh/badge.svg)](https://coveralls.io/github/trixi-framework/smesh)
[![Codecov](https://codecov.io/gh/trixi-framework/smesh/branch/main/graph/badge.svg)](https://codecov.io/gh/trixi-framework/smesh)
[![License: MIT](https://img.shields.io/badge/License-MIT-success.svg)](https://opensource.org/license/mit/)

A simple Fortran package for generating and handling unstructured triangular and polygonal
Expand Down
Loading