Spaces:
Running on Zero
Running on Zero
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.14'] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
| pip install "numpy<2.0.0" | |
| pip install pytest pytest-cov | |
| pip install -r requirements.txt | |
| - name: Run tests | |
| run: | | |
| # Run tests file-by-file for isolation to prevent mock leaks between suites. | |
| # We handle exit code 5 (no tests collected) which happens when a file | |
| # only contains 'slow' or 'gpu' tests that are filtered out. | |
| failed=0 | |
| for f in $(find tests -type f -name "test_*.py"); do | |
| echo "Running tests in $f..." | |
| if pytest -v -m "not gpu and not slow" --tb=short "$f"; then | |
| echo "Successfully ran tests in $f" | |
| else | |
| status=$? | |
| if [ $status -eq 5 ]; then | |
| echo "No tests matching filter in $f (exit code 5), continuing..." | |
| else | |
| echo "Error: tests in $f failed with exit code $status" | |
| failed=1 | |
| fi | |
| fi | |
| done | |
| if [ $failed -ne 0 ]; then | |
| echo "One or more test suites failed." | |
| exit 1 | |
| fi | |
| - name: Upload coverage report | |
| if: matrix.python-version == '3.10' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| if-no-files-found: ignore | |