C.W.K.
Stream
Lesson 01 of 13 · published

Python CI

~13 min · python, pytest, setup-python

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

The default Python pipeline in 2026

The Python ecosystem in 2026 looks different from five years ago. uv (Astral) replaces pip + virtualenv for most workflows. ruff replaces flake8/isort/black. pyright or mypy for types. pytest remains the standard test runner. pyproject.toml centralizes config.

The default Python CI shape:

  1. Checkout.
  2. Install uv (fast, single binary).
  3. uv sync — install deps from pyproject.toml + lockfile.
  4. ruff check + ruff format --check — lint and format gate.
  5. mypy or pyright — type-check.
  6. pytest — run tests with coverage.

Pinning matters more than convenience

Always pin Python: python-version: '3.12', not '3.x' or blank. Pin uv too: astral-sh/setup-uv@v3 with a specific version. CI that drifts when an underlying tool ships a new release is CI you cannot trust on a Friday afternoon.

Code

Python CI with uv (2026 standard)·yaml
name: ci
on: { pull_request: {}, push: { branches: [main] } }
permissions: read-all
concurrency: { group: ci-${{ github.ref }}, cancel-in-progress: true }

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v3
        with:
          version: '0.5.x'
          enable-cache: true
      - name: Install Python
        run: uv python install 3.12
      - name: Sync deps
        run: uv sync --all-extras --dev
      - name: Lint
        run: uv run ruff check .
      - name: Format check
        run: uv run ruff format --check .
      - name: Type check
        run: uv run mypy src
      - name: Test
        run: uv run pytest -q --cov=src --cov-report=xml

External links

Exercise

If your project still uses pip in CI, swap it for uv. Time both before and after the migration. The difference on a project with ~50 deps is usually 30–60 seconds per run.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.