|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - '**' |
| 9 | + pull_request: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.head_ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + tests: |
| 17 | + name: Python ${{ matrix.python-version }} |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + python-version: |
| 23 | + - '3.8' |
| 24 | + - '3.9' |
| 25 | + - '3.10' |
| 26 | + - '3.11' |
| 27 | + - '3.12' |
| 28 | + - '3.13' |
| 29 | + - '3.14' |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v5 |
| 33 | + |
| 34 | + - uses: actions/setup-python@v6 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + allow-prereleases: true |
| 38 | + |
| 39 | + - name: Install uv |
| 40 | + uses: astral-sh/setup-uv@v7 |
| 41 | + with: |
| 42 | + enable-cache: true |
| 43 | + |
| 44 | + - name: Run tox targets for ${{ matrix.python-version }} |
| 45 | + run: uvx --with tox-uv tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) |
| 46 | + |
| 47 | + - name: Upload coverage data |
| 48 | + uses: actions/upload-artifact@v5 |
| 49 | + with: |
| 50 | + name: coverage-data-${{ matrix.python-version }} |
| 51 | + path: '${{ github.workspace }}/.coverage.*' |
| 52 | + include-hidden-files: true |
| 53 | + if-no-files-found: error |
| 54 | + |
| 55 | + coverage: |
| 56 | + name: Coverage |
| 57 | + runs-on: ubuntu-24.04 |
| 58 | + needs: tests |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v5 |
| 61 | + |
| 62 | + - uses: actions/setup-python@v6 |
| 63 | + with: |
| 64 | + python-version: '3.13' |
| 65 | + |
| 66 | + - name: Install uv |
| 67 | + uses: astral-sh/setup-uv@v7 |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: uv pip install --system coverage[toml] |
| 71 | + |
| 72 | + - name: Download data |
| 73 | + uses: actions/download-artifact@v6 |
| 74 | + with: |
| 75 | + path: ${{ github.workspace }} |
| 76 | + pattern: coverage-data-* |
| 77 | + merge-multiple: true |
| 78 | + |
| 79 | + - name: Combine coverage and fail if it's <100% |
| 80 | + run: | |
| 81 | + python -m coverage combine |
| 82 | + python -m coverage html --skip-covered --skip-empty |
| 83 | + python -m coverage report --fail-under=100 |
| 84 | + echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY |
| 85 | + python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |
| 86 | +
|
| 87 | + - name: Upload HTML report |
| 88 | + if: ${{ failure() }} |
| 89 | + uses: actions/upload-artifact@v5 |
| 90 | + with: |
| 91 | + name: html-report |
| 92 | + path: htmlcov |
| 93 | + |
| 94 | + release: |
| 95 | + needs: [coverage] |
| 96 | + if: success() && startsWith(github.ref, 'refs/tags/') |
| 97 | + runs-on: ubuntu-24.04 |
| 98 | + environment: release |
| 99 | + |
| 100 | + permissions: |
| 101 | + contents: read |
| 102 | + id-token: write |
| 103 | + |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v5 |
| 106 | + |
| 107 | + - uses: astral-sh/setup-uv@v7 |
| 108 | + |
| 109 | + - name: Build |
| 110 | + run: uv build |
| 111 | + |
| 112 | + - uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments