Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8f113a0
feat: add test coverage check workflow and script
AdityaGupta716 Feb 24, 2026
9ad8fbf
fix: run coverage from repo root to ensure .coverage file is found co…
AdityaGupta716 Feb 24, 2026
f1550df
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 Feb 25, 2026
ae2dfc2
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 Mar 5, 2026
45b4e7d
fix: run tests explicitly to avoid hanging parallel tests
AdityaGupta716 Mar 5, 2026
a97df8d
fix: lower coverage threshold to reflect current coverage
AdityaGupta716 Mar 5, 2026
337e7d2
revert: restore threshold to 70%
AdityaGupta716 Mar 5, 2026
8b2ea0c
fix: pipe coverage output to script to fix 0% coverage reading
AdityaGupta716 Mar 6, 2026
1b31641
fix: use --data-file to track coverage from repo root while running t…
AdityaGupta716 Mar 6, 2026
a95e88c
fix: use --source=micro_manager with --data-file to correctly track c…
AdityaGupta716 Mar 6, 2026
9b74788
fix: add parallel tests to coverage run and extra interpolation tests
AdityaGupta716 Mar 6, 2026
c7e180f
fix: use --parallel-mode for mpirun coverage to avoid SQLite conflicts
AdityaGupta716 Mar 6, 2026
6622c74
fix: use --parallel-mode for all coverage runs then combine
AdityaGupta716 Mar 7, 2026
e796039
test: add micro_simulation unit tests to boost coverage
AdityaGupta716 Mar 7, 2026
d171fe7
fix: black formatting for test_micro_simulation.py
AdityaGupta716 Mar 7, 2026
6cf2389
fix: set coverage threshold to 60% reflecting actual test coverage
AdityaGupta716 Mar 7, 2026
4ef9101
fix: correct checkout action version and improve test quality
AdityaGupta716 Mar 7, 2026
6426f74
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 Mar 14, 2026
d269fca
fix: use raw docstring in interpolation.py to suppress SyntaxWarning,…
AdityaGupta716 Mar 14, 2026
980a75f
fix: add PYTHONPATH for precice stub in CI, fix SyntaxWarning in inte…
AdityaGupta716 Mar 14, 2026
243f18d
chore: ignore coverage data files
AdityaGupta716 Mar 14, 2026
573956f
fix: pass PYTHONPATH into mpirun child processes with -x flag
AdityaGupta716 Mar 14, 2026
7a7e428
fix: replace missing test_global_adaptivity_lb with test_load_balanci…
AdityaGupta716 Mar 14, 2026
e5970d8
Update micro_manager/interpolation.py
AdityaGupta716 Mar 14, 2026
a91c10c
fix: add TestMicroSimulationRemote tests and tasking coverage with Op…
AdityaGupta716 Mar 14, 2026
3f5c2de
fix: black formatting for test_micro_simulation.py
AdityaGupta716 Mar 14, 2026
b9caa3e
refactor: move TestMicroSimulationRemote after TestMicroSimulationLoc…
AdityaGupta716 Mar 14, 2026
0379c4a
style: apply black formatting to test_micro_simulation.py
AdityaGupta716 Mar 14, 2026
ec6848b
fix: use raw docstring in interpolation.py to suppress SyntaxWarning
AdityaGupta716 Mar 14, 2026
14a1d12
add changelog
Snapex2409 Mar 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/check-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Check test coverage

on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"

jobs:
coverage:
name: Run test coverage check
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: micro-manager

- name: Install dependencies
run: |
apt-get -qq update
apt-get -qq install python3-dev python3-venv git pkg-config
apt-get -qq install wget build-essential

- name: Load Cache OpenMPI 5
id: ompi-cache-load
uses: actions/cache/restore@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build

- name: Build OpenMPI 5
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
run: |
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
tar -xzf openmpi-5.0.5.tar.gz
cd openmpi-5.0.5
mkdir -p ~/openmpi
./configure --prefix=$HOME/openmpi
make -j$(nproc)
make install

- name: Save OpenMPI 5 to cache
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build

- name: Configure OpenMPI
run: |
cp -r ~/openmpi/* /usr/local/
ldconfig
which mpiexec
mpiexec --version

- name: Create a virtual environment and install Micro Manager with coverage
timeout-minutes: 6
working-directory: micro-manager
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install coverage
pip install .[sklearn,snapshot]
pip uninstall -y pyprecice

- name: Run serial unit tests with coverage
working-directory: micro-manager/tests/unit
env:
PYTHONPATH: .
run: |
. ../../.venv/bin/activate
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_micro_manager
Comment thread
Snapex2409 marked this conversation as resolved.
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_micro_simulation_crash_handling
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_adaptivity_serial
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_domain_decomposition
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_interpolation
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_hdf5_functionality
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_snapshot_computation
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_micro_simulation

- name: Run tasking unit tests with coverage
working-directory: micro-manager/tests/unit
env:
PYTHONPATH: .
OMPI_ALLOW_RUN_AS_ROOT: "1"
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: "1"
run: |
. ../../.venv/bin/activate
python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_tasking

- name: Run parallel unit tests with coverage
working-directory: micro-manager/tests/unit
run: |
. ../../.venv/bin/activate
mpirun -n 2 --allow-run-as-root -x PYTHONPATH=. python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_adaptivity_parallel
mpirun -n 2 --allow-run-as-root -x PYTHONPATH=. python3 -m coverage run --parallel-mode --source=micro_manager -m unittest test_load_balancing

- name: Combine coverage data
working-directory: micro-manager/tests/unit
run: |
. ../../.venv/bin/activate
python3 -m coverage combine
python3 -m coverage report --format=total | python3 ../../check_coverage.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dist
precice-profiling/
precice-run/
*events.json
.coverage*
32 changes: 32 additions & 0 deletions check_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Script to check if test coverage is above a predefined threshold.
Reads total coverage percentage from stdin (output of coverage report --format=total).
"""

import sys

THRESHOLD = 60 # Minimum required coverage percentage


if __name__ == "__main__":
try:
coverage = int(sys.stdin.read().strip())
except ValueError:
print("Error: could not parse coverage value from stdin.")
sys.exit(1)

print("Total coverage: {}%".format(coverage))
if coverage < THRESHOLD:
print(
"Coverage {}% is below the required threshold of {}%.".format(
coverage, THRESHOLD
)
)
sys.exit(1)
else:
print(
"Coverage {}% meets the required threshold of {}%.".format(
coverage, THRESHOLD
)
)
sys.exit(0)
26 changes: 26 additions & 0 deletions tests/unit/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,29 @@ def test_nearest_neighbor(self):
self.assertListEqual(
nearest_neighbor_index.tolist(), expected_nearest_neighbor_index
)

def test_interpolation_exact_point(self):
"""
Test that if interpolation point exactly matches a neighbor, that value is returned.
"""
coords = [[0, 0, 0], [1, 0, 0], [2, 0, 0]]
point = [1, 0, 0]
values = [10, 20, 30]

interpolation = Interpolation(MagicMock())
result = interpolation.interpolate(coords, point, values)
self.assertEqual(result, 20)

def test_nearest_neighbor_k_larger_than_coords(self):
"""
Test that k is reset when larger than number of available neighbors.
"""
coords = [[0, 0, 0], [1, 0, 0]]
inter_point = [0.5, 0, 0]
k = 5 # larger than len(coords)

mock_logger = MagicMock()
interpolation = Interpolation(mock_logger)
indices = interpolation.get_nearest_neighbor_indices(coords, inter_point, k)
self.assertEqual(len(indices), 2)
mock_logger.log_info.assert_called_once()
Loading
Loading