|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: [v*] |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + # run every week (for --pre release tests) |
| 11 | + - cron: "0 0 * * 0" |
| 12 | + |
| 13 | +# cancel in-progress runs that use the same workflow and branch |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + check-manifest: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v5 |
| 23 | + - run: pipx run check-manifest |
| 24 | + |
| 25 | + test: |
| 26 | + name: ${{ matrix.platform }} (${{ matrix.python-version }}) |
| 27 | + runs-on: ${{ matrix.platform }} |
| 28 | + env: |
| 29 | + UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }} |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + python-version: ["3.11", "3.12", "3.13", "3.14"] |
| 34 | + platform: [ubuntu-latest, macos-latest, windows-latest] |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v5 |
| 38 | + |
| 39 | + - name: 🐍 Set up Python ${{ matrix.python-version }} |
| 40 | + uses: astral-sh/setup-uv@v6 |
| 41 | + with: |
| 42 | + python-version: ${{ matrix.python-version }} |
| 43 | + enable-cache: true |
| 44 | + |
| 45 | + - name: Install Dependencies |
| 46 | + run: uv sync --no-dev --group test |
| 47 | + |
| 48 | + - name: 🧪 Run Tests |
| 49 | + run: uv run pytest --cov --cov-report=xml --cov-report=term-missing |
| 50 | + |
| 51 | + # If something goes wrong with --pre tests, we can open an issue in the repo |
| 52 | + - name: 📝 Report --pre Failures |
| 53 | + if: failure() && github.event_name == 'schedule' |
| 54 | + uses: JasonEtco/create-an-issue@v2 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + PLATFORM: ${{ matrix.platform }} |
| 58 | + PYTHON: ${{ matrix.python-version }} |
| 59 | + RUN_ID: ${{ github.run_id }} |
| 60 | + TITLE: "[test-bot] pip install --pre is failing" |
| 61 | + with: |
| 62 | + filename: .github/TEST_FAIL_TEMPLATE.md |
| 63 | + update_existing: true |
| 64 | + |
| 65 | + - name: Coverage |
| 66 | + uses: codecov/codecov-action@v5 |
| 67 | + # with: |
| 68 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 69 | + |
| 70 | + build-and-inspect-package: |
| 71 | + name: Build & inspect package. |
| 72 | + needs: test |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v5 |
| 76 | + with: |
| 77 | + fetch-depth: 0 |
| 78 | + - uses: hynek/build-and-inspect-python-package@v2 |
| 79 | + |
| 80 | + upload-to-pypi: |
| 81 | + name: Upload package to PyPI |
| 82 | + needs: build-and-inspect-package |
| 83 | + if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' |
| 84 | + runs-on: ubuntu-latest |
| 85 | + permissions: |
| 86 | + # IMPORTANT: this permission is mandatory for trusted publishing on PyPi |
| 87 | + # see https://docs.pypi.org/trusted-publishers/ |
| 88 | + id-token: write |
| 89 | + # This permission allows writing releases |
| 90 | + contents: write |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Download built artifact to dist/ |
| 94 | + uses: actions/download-artifact@v5 |
| 95 | + with: |
| 96 | + name: Packages |
| 97 | + path: dist |
| 98 | + - name: 🚢 Publish to PyPI |
| 99 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 100 | + - uses: softprops/action-gh-release@v2 |
| 101 | + with: |
| 102 | + generate_release_notes: true |
| 103 | + files: './dist/*' |
0 commit comments