Skip to content

chore(ci): ignore local .wheelhouse; CI uploads wheels as artifact #4

chore(ci): ignore local .wheelhouse; CI uploads wheels as artifact

chore(ci): ignore local .wheelhouse; CI uploads wheels as artifact #4

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test:
name: Tests and checks
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Cache pip wheels & pre-commit
uses: actions/cache@v4
with:
path: |
~/.cache/pip/wheels
.wheelhouse
~/.cache/pre-commit
key: ${{ runner.os }}-pip-wheels-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-wheels-${{ matrix.python-version }}-
- name: Install uv and create venv
run: |
python -m pip install --upgrade pip
pip install uv
# create a fresh .venv using uv immediately so subsequent steps use uv
uv venv
- name: Build wheelhouse for project and dev deps (via uv)
run: |
# Install build tools and build backend into the uv-managed venv
uv pip install --upgrade pip setuptools wheel hatchling
# Build wheels for the project and development extras into .wheelhouse
# Use --no-build-isolation so the installed hatchling is visible to the build
uv pip wheel -w .wheelhouse --no-build-isolation ".[dev]"
- name: Install project dev dependencies into venv from wheelhouse
run: |
# Install using only the local wheels for reproducibility / speed
uv pip install --no-index --find-links .wheelhouse ".[dev]"
- name: Run ruff (via uv)
run: uv run ruff check .
- name: Check formatting with Black (via uv)
run: uv run python -m black --check .
- name: Run mypy (via uv)
run: uv run python -m mypy .
- name: Run pre-commit hooks (all files) via uv
run: |
uv run pre-commit install
uv run pre-commit run --all-files
- name: Run tests (with coverage) via uv
run: |
uv run pytest -q --cov=python_project_deployment --cov-report=xml:coverage.xml --cov-report=html:htmlcov
- name: Upload coverage xml
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
- name: Upload coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
- name: Build Sphinx docs via uv
run: |
uv run python -m sphinx -b html docs docs/_build/html || true
- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: docs-html
path: docs/_build/html
deploy-docs:
name: Publish docs to GitHub Pages
runs-on: ubuntu-latest
needs: test
# Only deploy on pushes to main (avoid publishing from PRs)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: docs-html
path: docs/_build/html
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: docs/_build/html
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v1
with: {}