C.W.K.
Stream
Lesson 03 of 12 · published

Job

~12 min · jobs, parallelism, dependencies

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

각 job 은 자기 VM

Job 은 단일 runner (VM 이나 container) 에서 도는 작업 단위야. 같은 workflow 의 job 들은 기본적으로 병렬 로 돔 — 작업을 여러 job 으로 나누는 주요 이유가 그거야.

중요한 결과:

  • 각 job 은 깨끗한 working directory 로 시작. 한 job 에서 만든 파일이 다른 job 에 보임. upload-artifact + download-artifact 로 명시적으로 artifact 전달.
  • 각 job 의 runner 는 새 VM. Cache 는 다시 hydrate 해야 함.
  • Job 은 needs: 선언해서 다른 job 기다리고 DAG 형성 가능.
  • Job 은 if: 조건으로 context 기반 skip 가능.

Job 의 해부

  • runs-on — 필수. Runner label (ubuntu-latest, macos-14, self-hosted 등).
  • steps — 필수. 이 runner 에서 순서대로 도는 명령/action 목록.
  • needs — 옵션. 의존하는 다른 job.
  • if — 옵션. Job 전체를 막는 expression.
  • strategy — 옵션. Matrix 확장 (나중).
  • env — 옵션. Job 범위 env var.
  • outputs — 옵션. 의존 job 으로 publish 되는 값.
  • environment — 옵션. 승인 있는 production-style gate.

Code

Job DAG 세 개: build → (test, lint) → deploy·yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with: { name: dist, path: dist/ }

  test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test

  lint:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run lint

  deploy:
    needs: [test, lint]
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with: { name: dist }
      - run: ./deploy.sh

External links

Exercise

Lint + test + build 가 한 큰 job 에 있는 workflow 가져와. 병렬 도는 세 job 으로 분할. 전후 wall-clock 시간 재. 새로 필요했던 upload-artifact / download-artifact 협력 적어.

Progress

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

댓글 0

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

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