CI #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| tags: [v*] | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| # run every week (for --pre release tests) | |
| - cron: "0 0 * * 0" | |
| # cancel in-progress runs that use the same workflow and branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-manifest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: pipx run check-manifest | |
| test: | |
| name: ${{ matrix.platform }} (${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.platform }} | |
| env: | |
| UV_PRERELEASE: ${{ github.event_name == 'schedule' && 'allow' || 'if-necessary-or-explicit' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| platform: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: 🐍 Set up Python ${{ matrix.python-version }} | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| enable-cache: true | |
| - name: Install Dependencies | |
| run: uv sync --no-dev --group test | |
| - name: 🧪 Run Tests | |
| run: uv run pytest --cov --cov-report=xml --cov-report=term-missing | |
| # If something goes wrong with --pre tests, we can open an issue in the repo | |
| - name: 📝 Report --pre Failures | |
| if: failure() && github.event_name == 'schedule' | |
| uses: JasonEtco/create-an-issue@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PLATFORM: ${{ matrix.platform }} | |
| PYTHON: ${{ matrix.python-version }} | |
| RUN_ID: ${{ github.run_id }} | |
| TITLE: "[test-bot] pip install --pre is failing" | |
| with: | |
| filename: .github/TEST_FAIL_TEMPLATE.md | |
| update_existing: true | |
| - name: Coverage | |
| uses: codecov/codecov-action@v5 | |
| # with: | |
| # token: ${{ secrets.CODECOV_TOKEN }} | |
| build-and-inspect-package: | |
| name: Build & inspect package. | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: hynek/build-and-inspect-python-package@v2 | |
| upload-to-pypi: | |
| name: Upload package to PyPI | |
| needs: build-and-inspect-package | |
| if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # IMPORTANT: this permission is mandatory for trusted publishing on PyPi | |
| # see https://docs.pypi.org/trusted-publishers/ | |
| id-token: write | |
| # This permission allows writing releases | |
| contents: write | |
| steps: | |
| - name: Download built artifact to dist/ | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: Packages | |
| path: dist | |
| - name: 🚢 Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: './dist/*' |