본문 바로가기
C.W.K.
Stream
Lesson 09 of 12 · published

첫 번째 진짜 워크플로

~14 min · walkthrough, starter, python

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

0에서 green Python CI까지

이번 레슨에서는 실제로 유지할 만한 첫 번째 완전한 워크플로를 만들어볼 거야. 프로젝트는 pytestruff를 쓰는 작은 Python 패키지야. 목표는 PR과 main에서 lint, type-check, 테스트를 거치는 거지.

저장소 구성

  • pyproject.toml — Python 버전 + ruff + pytest + mypy 고정.
  • src/mypkg/
  • tests/
  • .github/workflows/ci.yml — 우리가 쓸 파일.

워크플로가 하는 일

  1. PR, main 푸시, 수동 실행 조건에서 작동해.
  2. 단일 작업 quality-checksubuntu-latest에서 돌려.
  3. Checkout, Python 3.12 설정, 캐시와 함께 의존성 설치, lint, type-check, 테스트를 수행해.
  4. 같은 PR에서 진행 중인 실행은 취소해.

아래 워크플로를 한 문서처럼 읽어봐. 보면 알겠지만 모든 줄이 제 역할을 해. 군더더기는 없어.

Code

.github/workflows/ci.yml — 전체·yaml
name: ci
run-name: ci on ${{ github.actor }} / ${{ github.head_ref || github.ref_name }}

on:
  pull_request: {}
  push:
    branches: [main]
  workflow_dispatch: {}

permissions: read-all

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  quality-checks:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: pip

      - name: Install
        run: |
          python -m pip install --upgrade pip
          pip install -e '.[dev]'

      - name: Lint
        run: ruff check .

      - name: Format check
        run: ruff format --check .

      - name: Type check
        run: mypy src

      - name: Test
        run: pytest -q --cov=src --cov-report=term-missing

External links

Exercise

이 워크플로를 네 Python 저장소에 넣고, 설치와 테스트 명령을 프로젝트에 맞게 조정한 다음 푸시해. Actions 탭에서 실행 결과를 봐. 빨간색이 뜨면 워크플로가 아니라 프로젝트 코드를 고쳐야 해 — 이게 핵심이야.

Progress

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

댓글 0

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

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