Migration to Hatch for modern CI/CD #576
Workflow file for this run
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: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| lint-python: | |
| name: Lint Python | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.x | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| cache: "pip" | |
| - name: Install Hatch | |
| run: | | |
| pip3 --quiet install --upgrade hatch uv | |
| hatch --version | |
| uv --version | |
| - name: Run formatter check | |
| run: | | |
| hatch run lint:format-check | |
| - name: Run linter | |
| run: | | |
| hatch run lint:check | |
| test-python: | |
| name: Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint-python | |
| strategy: | |
| matrix: | |
| python-version: | |
| ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| cache: pip | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip hatch uv | |
| - name: Show environment | |
| run: | | |
| hatch test --show --python ${{ matrix.python-version }} | |
| - name: Run tests | |
| run: | | |
| hatch test --cover --python ${{ matrix.python-version }} | |
| mv .coverage ".coverage.py${{ matrix.python-version }}" | |
| - name: Upload coverage data | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "coverage-data-py${{ matrix.python-version }}" | |
| path: ".coverage.py${{ matrix.python-version }}" | |
| if-no-files-found: error | |
| include-hidden-files: true | |
| retention-days: 7 | |
| test-functional: | |
| name: Functional Tests | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint-python | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip hatch uv | |
| - name: Run functional tests | |
| run: | | |
| hatch run functional:test | |
| coverage-python: | |
| name: Check Python Coverage | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test-python | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| cache: pip | |
| - name: Install dependencies | |
| run: python -m pip install --upgrade coverage[toml] | |
| - name: Download data | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Combine coverage and fail if it's <80% | |
| run: | | |
| python -m coverage combine | |
| python -m coverage html --skip-covered --skip-empty | |
| python -m coverage report --fail-under=80 | |
| - name: Upload HTML report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov |