Skip to content

Commit 4c09330

Browse files
committed
Also add test coverage for Python tests
Signed-off-by: Julien Jerphanion <[email protected]>
1 parent 95f56f1 commit 4c09330

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

.github/workflows/coverage.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,26 @@ jobs:
4040
- uses: hendrikmuhs/ccache-action@main
4141
with:
4242
variant: sccache
43-
key: ${{ github.job }}-${{ github.runner.os }}-coverage
43+
key: ${{ github.job }}-${{ github.runner.os }}
4444
restore-keys: |
45-
ccache-libmamba-${{ github.runner.os }}-coverage
45+
ccache-libmamba-${{ github.runner.os }}
4646
- name: Build mamba with coverage
4747
run: |
4848
cmake -B build/ -G Ninja \
4949
--preset mamba-unix-shared-debug \
5050
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
5151
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
5252
-D MAMBA_WARNING_AS_ERROR=ON \
53-
-D BUILD_LIBMAMBAPY=OFF \
53+
-D BUILD_LIBMAMBAPY=ON \
54+
-D BUILD_MICROMAMBA=ON \
5455
-D ENABLE_MAMBA_ROOT_PREFIX_FALLBACK=OFF \
5556
-D CMAKE_BUILD_TYPE=Debug \
56-
-D CMAKE_CXX_FLAGS_DEBUG="-g -O0 --coverage" \
57-
-D CMAKE_C_FLAGS_DEBUG="-g -O0 --coverage"
57+
-D CMAKE_CXX_FLAGS_DEBUG="-g -O0 -fno-omit-frame-pointer --coverage" \
58+
-D CMAKE_C_FLAGS_DEBUG="-g -O0 -fno-omit-frame-pointer --coverage"
5859
cmake --build build/ --parallel
5960
- name: Show build cache statistics
6061
run: sccache --show-stats
61-
- name: Run tests with coverage
62+
- name: Run C++ tests with coverage
6263
run: |
6364
unset CONDARC # Interferes with tests
6465
./build/libmamba/ext/solv-cpp/tests/test_solv_cpp
@@ -67,13 +68,27 @@ jobs:
6768
run: |
6869
sudo apt-get update
6970
sudo apt-get install -y lcov
70-
- name: Generate coverage report
71+
- name: Generate C++ coverage report
7172
run: |
72-
lcov --directory . --capture --output-file coverage.info
73-
lcov --remove coverage.info '*/tests/*' --output-file coverage.info
73+
lcov --directory . --capture --output-file cpp_coverage.info
74+
lcov --remove cpp_coverage.info '/usr/*' '*/tests/*' '*/build/*' --output-file cpp_coverage.info --ignore-errors unused
75+
lcov --summary cpp_coverage.info --ignore-errors mismatch
76+
- name: Install libmambapy
77+
run: |
78+
cmake --install build/ --prefix "${CONDA_PREFIX}"
79+
python -m pip install --no-deps --no-build-isolation ./libmambapy
80+
- name: Run Python tests with coverage
81+
run: |
82+
# Run libmambapy tests with coverage
83+
python -m pytest libmambapy/tests/ --cov=libmambapy --cov-report=xml --cov-report=term-missing
84+
# Run micromamba tests with coverage
85+
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/mamba
86+
python -m pytest micromamba/tests/ --cov=micromamba --cov-report=xml --cov-report=term-missing
7487
- name: Upload coverage to Codecov
7588
uses: codecov/codecov-action@v4
7689
with:
77-
file: ./coverage.info
90+
files: |
91+
./cpp_coverage.info
92+
./coverage.xml
7893
fail_ci_if_error: true
7994
token: ${{ secrets.CODECOV_TOKEN }}

dev/environment-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies:
3232
- pytest-timeout
3333
- pytest-xprocess
3434
- pytest-rerunfailures
35+
- pytest-cov
3536
- memory_profiler
3637
- requests
3738
- sel(win): pywin32

0 commit comments

Comments
 (0)