본문 바로가기
C.W.K.
Stream
Lesson 01 of 13 · published

Python CI

~13 min · python, pytest, setup-python

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

2026년 기본 Python 파이프라인

2026년 Python 생태계는 5년 전과 완전히 다르게 흘러갔어. 대부분의 워크플로에서 uv (Astral)가 pip와 virtualenv를 대체했고, ruff가 flake8, isort, black 자리를 차지했지. 타입 검사는 pyrightmypy를 쓰고, 테스트 러너는 pytest가 표준이 됐어. 설정 파일은 pyproject.toml로 모두 중앙화하지.

기본 Python CI는 대략 이런 구조야:

  1. Checkout.
  2. uv 설치 (빠르고 단일 바이너리).
  3. uv syncpyproject.toml과 lockfile에서 의존성 설치.
  4. ruff check + ruff format --check — 린트와 포맷팅 검사.
  5. mypy 또는 pyright — 타입 검사.
  6. pytest — 커버리지와 함께 테스트.

편의보다 버전 고정이 중요해

Python은 항상 버전을 고정해: python-version: '3.12'처럼 쓰고, '3.x'나 공백은 절대 안 돼. uv도 마찬가지로 astral-sh/setup-uv@v3처럼 특정 버전을 고정해. 하위 도구들이 새 릴리스를 내보낼 때마다 변화가 생기는 CI는 금요일 오후에 믿을 수 없어.

Code

uv 기반 Python CI (2026 표준)·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

프로젝트가 아직 CI에서 pip를 쓰고 있다면 uv로 바꿔봐. 마이그레이션 전후의 시간을 재봐. 의존성이 50개 정도인 프로젝트에서는 보통 실행당 30-60초 차이가 나.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.