Skip to content

Add Github actions for CI #1

Add Github actions for CI

Add Github actions for CI #1

Workflow file for this run

name: CI (uv)
on:
push:
branches: ["main", "master"]
pull_request:
branches: ["*"]
jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup-python
# Uses the repo's .python-version for consistency
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Cache uv
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('pyproject.toml') }}
- name: Sync dependencies (dev)
run: uv sync --group dev
- name: Ruff format (check)
run: uv run ruff format --check
- name: Ruff check
run: uv run ruff check --output-format=github
test:
name: Test (pytest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Cache uv
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('pyproject.toml') }}
- name: Sync dependencies (test)
run: uv sync --group test
- name: Run pytest
run: uv run pytest -q tests/
docs:
name: Docs (Sphinx)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Cache uv
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: ${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('pyproject.toml', 'docs/**') }}
- name: Sync dependencies (docs)
run: uv sync --group docs
- name: Build Sphinx HTML
run: uv run sphinx-build -b html docs docs/_build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html
publish-docs:
name: Publish Docs
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4