|
| 1 | +name: Tests |
| 2 | + |
| 3 | +# Test organization: |
| 4 | +# - Unit tests: Run on all PRs and pushes, no external data required |
| 5 | +# - Integration tests with data: Run on PRs, download and cache test data |
| 6 | +# - GPU tests (segmentation): Excluded from CI (requires CUDA), run locally |
| 7 | +# |
| 8 | +# Test markers: |
| 9 | +# - requires_data: Tests that need external data downloads |
| 10 | +# - slow: Tests that are computationally intensive or require GPU |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + branches: [ main ] |
| 15 | + push: |
| 16 | + branches: [ main ] |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 25 | + python-version: ['3.10', '3.11', '3.12'] |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install -e . |
| 39 | + pip install pytest pytest-cov |
| 40 | +
|
| 41 | + - name: Run unit tests (no data required) |
| 42 | + run: | |
| 43 | + pytest tests/ -v -m "not requires_data and not slow" --cov=src/physiomotion4d --cov-report=xml |
| 44 | +
|
| 45 | + - name: Upload coverage to Codecov |
| 46 | + uses: codecov/codecov-action@v4 |
| 47 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' |
| 48 | + with: |
| 49 | + file: ./coverage.xml |
| 50 | + flags: unittests |
| 51 | + name: codecov-umbrella |
| 52 | + fail_ci_if_error: false |
| 53 | + |
| 54 | + test-with-data: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + if: github.event_name == 'pull_request' |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Set up Python 3.10 |
| 62 | + uses: actions/setup-python@v5 |
| 63 | + with: |
| 64 | + python-version: '3.10' |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + python -m pip install --upgrade pip |
| 69 | + pip install -e . |
| 70 | + pip install pytest pytest-cov |
| 71 | +
|
| 72 | + - name: Cache test data |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: | |
| 76 | + tests/data/ |
| 77 | + tests/results/ |
| 78 | + key: test-data-${{ hashFiles('tests/test_*.py') }}-v2 |
| 79 | + restore-keys: | |
| 80 | + test-data- |
| 81 | +
|
| 82 | + - name: Run data download tests |
| 83 | + run: | |
| 84 | + pytest tests/test_download_heart_data.py -v --cov=src/physiomotion4d --cov-report=xml |
| 85 | + continue-on-error: true |
| 86 | + |
| 87 | + - name: Run data conversion tests |
| 88 | + run: | |
| 89 | + pytest tests/test_convert_nrrd_4d_to_3d.py -v --cov=src/physiomotion4d --cov-append --cov-report=xml |
| 90 | + continue-on-error: true |
| 91 | + |
| 92 | + - name: Run contour tools tests |
| 93 | + run: | |
| 94 | + pytest tests/test_contour_tools.py -v -m "not slow" --cov=src/physiomotion4d --cov-append --cov-report=xml |
| 95 | + continue-on-error: true |
| 96 | + |
| 97 | + - name: Run USD conversion tests |
| 98 | + run: | |
| 99 | + pytest tests/test_convert_vtk_4d_to_usd_polymesh.py -v -m "not slow" --cov=src/physiomotion4d --cov-append --cov-report=xml |
| 100 | + continue-on-error: true |
| 101 | + |
| 102 | + - name: Run existing USD tests |
| 103 | + run: | |
| 104 | + pytest tests/test_usd_merge.py tests/test_usd_time_preservation.py -v --cov=src/physiomotion4d --cov-append --cov-report=xml |
| 105 | + continue-on-error: true |
| 106 | + |
| 107 | + - name: Upload coverage |
| 108 | + uses: codecov/codecov-action@v4 |
| 109 | + with: |
| 110 | + file: ./coverage.xml |
| 111 | + flags: integration-tests |
| 112 | + fail_ci_if_error: false |
| 113 | + |
| 114 | + # Note: Slow and GPU-dependent tests are excluded from CI |
| 115 | + # These tests should be run locally: |
| 116 | + # - tests/test_register_images_ants.py (slow, computationally intensive) |
| 117 | + # - tests/test_register_images_icon.py (requires CUDA for ICON) |
| 118 | + # - tests/test_transform_tools.py (depends on slow registration tests) |
| 119 | + # - tests/test_segment_chest_total_segmentator.py (requires CUDA for TotalSegmentator) |
| 120 | + # - tests/test_segment_chest_vista_3d.py (requires CUDA for VISTA-3D) |
| 121 | + # |
| 122 | + # To run slow/GPU tests locally: |
| 123 | + # pytest tests/ -v -m "slow" # Run all slow tests |
| 124 | + # pytest tests/test_register_images_ants.py -v -s |
| 125 | + # pytest tests/test_register_images_icon.py -v -s |
| 126 | + # pytest tests/test_transform_tools.py -v -s |
| 127 | + # pytest tests/test_segment_chest_total_segmentator.py -v -s |
| 128 | + # pytest tests/test_segment_chest_vista_3d.py -v -s |
0 commit comments