diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..93fc040 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,5 @@ +# xref: https://docs.codecov.io/docs/codecovyml-reference + +# Disable annotations (annoying!) +github_checks: + annotations: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 383dc54..8f92e19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} @@ -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() }} diff --git a/.gitignore b/.gitignore index 526dca8..d2acefe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ +build-coverage/ install/ *.dat diff --git a/CMakeLists.txt b/CMakeLists.txt index eaf2034..8beaa92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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() diff --git a/README.md b/README.md index f1b92dc..94712d2 100644 --- a/README.md +++ b/README.md @@ -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