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