|
| 1 | +--- |
| 2 | +name: Tests |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + name: Python ${{ matrix.python-version }} |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + python-version: ["3.12", "3.13", "3.14"] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - uses: astral-sh/setup-uv@v6 |
| 25 | + with: |
| 26 | + enable-cache: true |
| 27 | + cache-dependency-glob: "pyproject.toml" |
| 28 | + |
| 29 | + - name: Set up Python ${{ matrix.python-version }} |
| 30 | + run: uv python install ${{ matrix.python-version }} |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: uv venv && uv pip install -e ".[test]" |
| 34 | + |
| 35 | + - name: Run tests with coverage |
| 36 | + run: uv run pytest --cov --cov-report= |
| 37 | + |
| 38 | + - name: Rename coverage data |
| 39 | + run: mv .coverage .coverage.${{ matrix.python-version }} |
| 40 | + |
| 41 | + - name: Upload coverage data |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: coverage-data-${{ matrix.python-version }} |
| 45 | + path: .coverage.${{ matrix.python-version }} |
| 46 | + include-hidden-files: true |
| 47 | + if-no-files-found: ignore |
| 48 | + |
| 49 | + coverage: |
| 50 | + name: Combine & check coverage |
| 51 | + if: always() |
| 52 | + needs: test |
| 53 | + runs-on: ubuntu-latest |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - uses: astral-sh/setup-uv@v6 |
| 59 | + with: |
| 60 | + enable-cache: true |
| 61 | + cache-dependency-glob: "pyproject.toml" |
| 62 | + |
| 63 | + - name: Install dependencies |
| 64 | + run: uv venv && uv pip install -e ".[test]" |
| 65 | + |
| 66 | + - uses: actions/download-artifact@v4 |
| 67 | + with: |
| 68 | + pattern: coverage-data-* |
| 69 | + merge-multiple: true |
| 70 | + |
| 71 | + - name: Combine coverage & check threshold |
| 72 | + run: | |
| 73 | + uv run coverage combine |
| 74 | + uv run coverage html --skip-covered --skip-empty |
| 75 | + uv run coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |
| 76 | + uv run coverage report |
| 77 | +
|
| 78 | + - name: Upload HTML report if check failed |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: html-report |
| 82 | + path: htmlcov |
| 83 | + if: ${{ failure() }} |
0 commit comments