본문 바로가기
C.W.K.
Stream
Lesson 05 of 14 · published

Concurrency

~10 min · concurrency, cancel, groups

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

오래된 커밋에 시간 낭비하지 마

5분 동안 10번 푸시하면 기본적으로 CI가 10개 병렬로 실행돼. 시작하는 순간 9개는 이미 쓸모없어져. concurrency:그룹을 선언하면 그룹마다 실행은 하나만 활성화되고, 활성 그룹에서 새 실행을 시작할 때 어떻게 처리할지 선택할 수 있어.

두 가지 설정

  • group: — 그룹을 식별하는 문자열 템플릿이야. 흔히 쓰는 건 ${{ github.workflow }}-${{ github.ref }}로, 워크플로마다 브랜치마다 하나만 실행되게 해.
  • cancel-in-progress: — true면 새 실행을 시작하느라 돌아가는 걸 취소하고, false면 새 실행을 큐에 넣어.

알맞은 그룹 고르기

  • PR 피드백github.ref 그룹에 cancel-in-progress를 true로 설정해. 새 푸시가 이전 실행을 무효화하지.
  • 배포 — 환경 이름으로 그룹을 묶고 cancel-in-progress는 false로 해. 같은 환경에서 두 번 배포하면 직렬로 처리돼.
  • 릴리스github.workflow 그룹에 cancel-in-progress를 false로 설정해. 릴리스가 큐에 들어가서 겹치지 않아.

Code

Concurrency 전략 세 가지·yaml
# 1) PR feedback — cancel old runs
concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

# 2) Deploy — serialize, no cancel (mid-deploy cancellation is dangerous)
concurrency:
  group: deploy-${{ github.event.inputs.environment || 'staging' }}
  cancel-in-progress: false

# 3) Release — single global queue
concurrency:
  group: release
  cancel-in-progress: false

External links

Exercise

CI 워크플로에 cancel-in-progress와 함께 concurrency를 추가하고, 배포 워크플로는 직렬로만 실행되게 해. CI에 빠르게 두 번 푸시해서 첫 번째가 취소되는지 확인해. 배포를 두 번 실행시켜서 두 번째가 큐에 들어가는지 확인해.

Progress

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

댓글 0

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

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