From zero to a green Python CI
This lesson builds a complete first workflow you'd actually keep. The project is a small Python package with pytest and ruff. The goal is to lint, type-check, and test on every PR and on main.
Repo layout
pyproject.toml— pinning Python version + ruff + pytest + mypy.src/mypkg/tests/.github/workflows/ci.yml— what we'll write.
What the workflow does
- Trigger on PR + push to main + manual dispatch.
- Single job
quality-checksonubuntu-latest. - Checkout, set up Python 3.12, install deps with cache, lint, type-check, test.
- Cancel in-progress runs on the same PR.
Read the workflow below as one document. Notice: every line earns its place. Nothing is decorative.