Add unit tests to increase coverage #1707
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################################################## | |
| # GitHub Actions Workflow for volesti to build tests with GCC | |
| # | |
| # Copyright (c) 2020-2025 Vissarion Fisikopoulos | |
| # | |
| # Licensed under GNU LGPL.3, see LICENCE file | |
| ############################################################################## | |
| name: cmake-gcc | |
| on: [push, pull_request] | |
| jobs: | |
| build: | |
| name: ${{ matrix.config.os }} - ${{ matrix.config.compiler }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - {os: ubuntu-22.04, compiler: g++-9} | |
| - {os: ubuntu-22.04, compiler: g++-10} | |
| - {os: ubuntu-22.04, compiler: g++-11} | |
| - {os: ubuntu-22.04, compiler: g++-12} | |
| #- {os: ubuntu-22.04, compiler: g++-13} | |
| runs-on: ${{ matrix.config.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: sudo apt-get update || true; | |
| sudo apt-get install ${{ matrix.config.compiler }} lp-solve libopenblas-dev liblapack-dev; | |
| rm -rf build; | |
| mkdir build; | |
| cd build; | |
| cmake -D CMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -D DISABLE_NLP_ORACLES=ON -D USE_MKL=OFF ../test; | |
| make -j$(nproc); | |
| ctest -j$(nproc) --verbose; | |
| coverage: | |
| name: Coverage (gcc) | |
| runs-on: ubuntu-22.04 | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build and test with coverage | |
| run: | | |
| sudo apt-get update || true | |
| sudo apt-get install -y g++-12 gcov-12 lp-solve libopenblas-dev liblapack-dev | |
| sudo apt-get install -y gcovr 2>/dev/null || pip install gcovr 2>/dev/null || pip install --break-system-packages gcovr 2>/dev/null || true | |
| rm -rf build | |
| mkdir build | |
| cd build | |
| cmake -D CMAKE_CXX_COMPILER=g++-12 -D DISABLE_NLP_ORACLES=ON -D USE_MKL=OFF -D CODE_COVERAGE=ON ../test | |
| make -j$(nproc) | |
| ctest -j$(nproc) --verbose -E "crhmc_polytope_test_preparation|crhmc_test_polytope_sampling" --timeout 300 || true | |
| - name: Generate coverage report | |
| if: success() || failure() | |
| run: | | |
| cd build | |
| echo "=== gcda files found ===" | |
| find . -name '*.gcda' | wc -l | |
| echo "=== Running gcov on all gcda ===" | |
| for gcda in $(find . -name '*.gcda'); do | |
| dir=$(dirname $gcda) | |
| gcov -o $dir $(echo $gcda | sed 's/\.gcda/.gcno/') 2>&1 | grep -E "File|Lines" | head -2 | |
| done || true | |
| echo "=== Generating Cobertura XML ===" | |
| gcovr --gcov-executable gcov-12 --root .. --exclude '.*external.*' --exclude '.*test.*' --exclude '.*_deps.*' --xml -o coverage.xml 2>&1 || true | |
| head -20 coverage.xml 2>&1 || true | |
| - name: Upload coverage to Codecov | |
| if: success() || failure() | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: build/coverage.xml | |
| flags: unittests | |
| fail_ci_if_error: false | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |