Skip to content

Commit

Permalink
coverge + fix cache (#41)
Browse files Browse the repository at this point in the history
* coverge + fix cache + badge
  • Loading branch information
teseoch authored Oct 6, 2023
1 parent 2915048 commit 7106470
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-${{ matrix.config }}-caceh
key: ${{ runner.os }}-${{ matrix.config }}-cache-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.config }}-cache

- name: Prepare ccache
run: |
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Coverage

on:
push:
branches: [main]
pull_request:

env:
CTEST_OUTPUT_ON_FAILURE: ON
CTEST_PARALLEL_LEVEL: 2

jobs:
Linux:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
threading: [TBB]
include:
- os: ubuntu-latest
name: Linux
steps:
- name: Checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 10

- name: Dependencies
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install \
libblas-dev \
libglu1-mesa-dev \
xorg-dev \
mpi \
lcov \
ccache
echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"
- name: Cache Build
id: cache-build
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-Release-${{ matrix.threading }}-cache-${{ github.sha }}
restore-keys: ${{ runner.os }}-Release-${{ matrix.threading }}-cache

- name: Prepare ccache
run: |
ccache --max-size=1.0G
ccache -V && ccache --show-stats && ccache --zero-stats
- name: Configure
run: |
mkdir -p build
cd build
cmake .. \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=Release \
-DPOLYSOLVE_CODE_COVERAGE=ON
- name: Build
run: cd build; make -j2; ccache --show-stats

- name: Run Coverage
run: |
cd build
ctest --verbose --output-on-failure
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '*tests/*.cpp' --output-file coverage.info
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
flags: polysolve # optional
files: coverage.info
name: polysolve # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ option(POLYSOLVE_WITH_TESTS "Build unit-tests" ${POLYSOLVE_TOPLEV
include(CMakeDependentOption)
cmake_dependent_option(EIGEN_WITH_MKL "Use Eigen with MKL" ON "POLYSOLVE_WITH_MKL" OFF)

option(POLYSOLVE_CODE_COVERAGE "Enable coverage reporting" OFF)

add_library(polysolve_coverage_config INTERFACE)
if(POLYSOLVE_CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
target_compile_options(polysolve_coverage_config INTERFACE
-g # generate debug info
--coverage # sets all required flags
)
target_link_options(polysolve_coverage_config INTERFACE --coverage)
endif()

# Set default minimum C++ standard
if(POLYSOLVE_TOPLEVEL_PROJECT)
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -136,6 +148,8 @@ endif()
add_library(polysolve)
add_library(polysolve::polysolve ALIAS polysolve)

target_link_libraries(polysolve PUBLIC polysolve_coverage_config)

add_subdirectory(src/polysolve)

# Public include directory for Polysolve
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# PolySolve

![Build](https://github.com/polyfem/polysolve/workflows/Build/badge.svg)
[![codecov](https://codecov.io/github/polyfem/polysolve/graph/badge.svg?token=9CTTZX9A2D)](https://codecov.io/github/polyfem/polysolve)

This library contains a cross-platform Eigen wrapper for many different external linear solvers including (but not limited to):

Expand Down

0 comments on commit 7106470

Please sign in to comment.