|
| 1 | +name: Code Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - feat/* |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - feat/* |
| 12 | + paths-ignore: |
| 13 | + - "docs/**" |
| 14 | + - "**.md" |
| 15 | + merge_group: |
| 16 | + types: [checks_requested] |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + coverage: |
| 24 | + name: Code Coverage |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout mamba repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Create build environment |
| 30 | + uses: mamba-org/setup-micromamba@v2 |
| 31 | + with: |
| 32 | + environment-file: ./dev/environment-dev.yml |
| 33 | + environment-name: build_env |
| 34 | + cache-environment: true |
| 35 | + - uses: hendrikmuhs/ccache-action@main |
| 36 | + with: |
| 37 | + variant: sccache |
| 38 | + key: ${{ github.job }}-${{ github.runner.os }} |
| 39 | + restore-keys: | |
| 40 | + ccache-libmamba-${{ github.runner.os }} |
| 41 | + - name: Build mamba with coverage |
| 42 | + run: | |
| 43 | + cmake -B build/ -G Ninja \ |
| 44 | + --preset mamba-unix-shared-debug \ |
| 45 | + -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ |
| 46 | + -D CMAKE_C_COMPILER_LAUNCHER=sccache \ |
| 47 | + -D MAMBA_WARNING_AS_ERROR=ON \ |
| 48 | + -D BUILD_LIBMAMBAPY=OFF \ |
| 49 | + -D ENABLE_MAMBA_ROOT_PREFIX_FALLBACK=OFF \ |
| 50 | + -D CMAKE_BUILD_TYPE=Debug \ |
| 51 | + -D CMAKE_CXX_FLAGS_DEBUG="-g -O0 --coverage" \ |
| 52 | + -D CMAKE_C_FLAGS_DEBUG="-g -O0 --coverage" |
| 53 | + cmake --build build/ --parallel |
| 54 | + - name: Show build cache statistics |
| 55 | + run: sccache --show-stats |
| 56 | + - name: Run tests with coverage |
| 57 | + run: | |
| 58 | + unset CONDARC # Interferes with tests |
| 59 | + ./build/libmamba/ext/solv-cpp/tests/test_solv_cpp |
| 60 | + ./build/libmamba/tests/test_libmamba |
| 61 | + - name: Install lcov |
| 62 | + run: | |
| 63 | + sudo apt-get update |
| 64 | + sudo apt-get install -y lcov |
| 65 | + - name: Generate coverage report |
| 66 | + run: | |
| 67 | + lcov --directory . --capture --output-file coverage.info |
| 68 | + lcov --remove coverage.info '/usr/*' '*/tests/*' '*/build/*' --output-file coverage.info |
| 69 | + - name: Upload coverage to Codecov |
| 70 | + uses: codecov/codecov-action@v4 |
| 71 | + with: |
| 72 | + file: ./coverage.info |
| 73 | + fail_ci_if_error: true |
| 74 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments