diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 8722292..352d4ff 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -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: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..c0d598e --- /dev/null +++ b/.github/workflows/coverage.yml @@ -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) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 83bff37..bbf763b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 17) @@ -141,6 +153,10 @@ add_library(polysolve) add_library(polysolve::polysolve ALIAS polysolve) add_subdirectory(src/polysolve/nonlinear) +target_link_libraries(polysolve_linear PUBLIC polysolve_coverage_config) +target_link_libraries(polysolve PUBLIC polysolve_coverage_config) + + target_compile_features(polysolve_linear PUBLIC cxx_std_17) target_compile_features(polysolve PUBLIC cxx_std_17) diff --git a/README.md b/README.md index 921da95..a600d49 100644 --- a/README.md +++ b/README.md @@ -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): diff --git a/cmake/recipes/blas.cmake b/cmake/recipes/blas.cmake index f7e37f3..314fb98 100644 --- a/cmake/recipes/blas.cmake +++ b/cmake/recipes/blas.cmake @@ -19,8 +19,11 @@ if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" OR "${CMAKE_OSX_ARCHITECTURES}" M # Use Accelerate on macOS M1 set(BLA_VENDOR Apple) find_package(BLAS REQUIRED) -else() - # Use MKL on other platforms +elseif(POLYSOLVE_WITH_MKL) + # Use MKL if enabled include(mkl) add_library(BLAS::BLAS ALIAS mkl::mkl) +else() + # otherwise find system version + find_package(BLAS REQUIRED) endif() diff --git a/cmake/recipes/lapack.cmake b/cmake/recipes/lapack.cmake index fb372bc..f559182 100644 --- a/cmake/recipes/lapack.cmake +++ b/cmake/recipes/lapack.cmake @@ -19,8 +19,11 @@ if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" OR "${CMAKE_OSX_ARCHITECTURES}" M # Use Accelerate on macOS M1 set(BLA_VENDOR Apple) find_package(LAPACK REQUIRED) -else() - # Use MKL on other platforms +elseif(POLYSOLVE_WITH_MKL) + # Use MKL if enabled include(mkl) add_library(LAPACK::LAPACK ALIAS mkl::mkl) +else() + # otherwise find system version + find_package(LAPACK REQUIRED) endif()