Python CI: uv setup, ruff lint+format, mypy type check (warn), pytest Runs on docker-x64 runner (forgejo-runner on Talos).
56 lines
1.7 KiB
YAML
56 lines
1.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker-x64
|
|
container:
|
|
image: python:3.12-slim
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install system deps
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends git build-essential
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
- name: Install uv (fast Python package manager)
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Setup Python
|
|
run: |
|
|
uv python install 3.12
|
|
uv venv --python 3.12 .venv
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
if [ -f pyproject.toml ]; then
|
|
uv pip install --python .venv/bin/python -e ".[dev]" 2>/dev/null || \
|
|
uv pip install --python .venv/bin/python -e .
|
|
if [ -f requirements.txt ]; then
|
|
uv pip install --python .venv/bin/python -r requirements.txt
|
|
fi
|
|
elif [ -f requirements.txt ]; then
|
|
uv pip install --python .venv/bin/python -r requirements.txt
|
|
fi
|
|
uv pip install --python .venv/bin/python ruff mypy pytest pytest-asyncio pytest-cov
|
|
|
|
- name: Lint (ruff)
|
|
run: source .venv/bin/activate && ruff check . && ruff format --check .
|
|
|
|
- name: Type check (mypy)
|
|
run: source .venv/bin/activate && mypy . --ignore-missing-imports || true
|
|
continue-on-error: true
|
|
|
|
- name: Test (pytest)
|
|
run: source .venv/bin/activate && pytest --maxfail=1 -x -q 2>&1 || true
|
|
continue-on-error: true
|