-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add CI workflow to check test coverage #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+545
−1
Merged
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 9ad8fbf
fix: run coverage from repo root to ensure .coverage file is found co…
AdityaGupta716 f1550df
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 ae2dfc2
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 45b4e7d
fix: run tests explicitly to avoid hanging parallel tests
AdityaGupta716 a97df8d
fix: lower coverage threshold to reflect current coverage
AdityaGupta716 337e7d2
revert: restore threshold to 70%
AdityaGupta716 8b2ea0c
fix: pipe coverage output to script to fix 0% coverage reading
AdityaGupta716 1b31641
fix: use --data-file to track coverage from repo root while running t…
AdityaGupta716 a95e88c
fix: use --source=micro_manager with --data-file to correctly track c…
AdityaGupta716 9b74788
fix: add parallel tests to coverage run and extra interpolation tests
AdityaGupta716 c7e180f
fix: use --parallel-mode for mpirun coverage to avoid SQLite conflicts
AdityaGupta716 6622c74
fix: use --parallel-mode for all coverage runs then combine
AdityaGupta716 e796039
test: add micro_simulation unit tests to boost coverage
AdityaGupta716 d171fe7
fix: black formatting for test_micro_simulation.py
AdityaGupta716 6cf2389
fix: set coverage threshold to 60% reflecting actual test coverage
AdityaGupta716 4ef9101
fix: correct checkout action version and improve test quality
AdityaGupta716 6426f74
Merge branch 'develop' into ci-test-coverage
AdityaGupta716 d269fca
fix: use raw docstring in interpolation.py to suppress SyntaxWarning,…
AdityaGupta716 980a75f
fix: add PYTHONPATH for precice stub in CI, fix SyntaxWarning in inte…
AdityaGupta716 243f18d
chore: ignore coverage data files
AdityaGupta716 573956f
fix: pass PYTHONPATH into mpirun child processes with -x flag
AdityaGupta716 7a7e428
fix: replace missing test_global_adaptivity_lb with test_load_balanci…
AdityaGupta716 e5970d8
Update micro_manager/interpolation.py
AdityaGupta716 a91c10c
fix: add TestMicroSimulationRemote tests and tasking coverage with Op…
AdityaGupta716 3f5c2de
fix: black formatting for test_micro_simulation.py
AdityaGupta716 b9caa3e
refactor: move TestMicroSimulationRemote after TestMicroSimulationLoc…
AdityaGupta716 0379c4a
style: apply black formatting to test_micro_simulation.py
AdityaGupta716 ec6848b
fix: use raw docstring in interpolation.py to suppress SyntaxWarning
AdityaGupta716 14a1d12
add changelog
Snapex2409 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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 | ||
| 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 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ dist | |
| precice-profiling/ | ||
| precice-run/ | ||
| *events.json | ||
| .coverage* | ||
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
| 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) |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.