CollabOps

기본 CI 파이프라인

린트, 테스트, 빌드를 수행하는 기본 CI 파이프라인 예제

Node.js 프로젝트의 린트, 테스트, 빌드를 수행하는 기본 CI 파이프라인입니다.

전체 코드

# Workflow 이름 — 대시보드에 표시됩니다
name: basic-ci

# 트리거: main 브랜치에 push할 때 실행
triggers:
  push:
    branches: [main]

jobs:
  # ─────────────────────────────────────────
  # 1단계: 소스코드 체크아웃
  # ─────────────────────────────────────────
  checkout:
    phase: source
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"

  # ─────────────────────────────────────────
  # 2단계: 린트 (checkout 완료 후 실행)
  # ─────────────────────────────────────────
  lint:
    phase: test
    needs: [checkout]           # checkout이 완료되어야 실행
    steps:
      - name: eslint
        run: npm run lint       # ESLint 실행
        image: node:18          # Node.js 18 이미지 사용

  # ─────────────────────────────────────────
  # 3단계: 테스트 (checkout 완료 후 실행, lint와 병렬)
  # ─────────────────────────────────────────
  test:
    phase: test
    needs: [checkout]           # lint와 병렬로 실행됨
    steps:
      - name: unit-test
        run: npm test           # Jest/Vitest 등 단위 테스트 실행
        image: node:18
        env:
          CI: "true"            # CI 환경임을 명시 (테스트 프레임워크가 참조)

  # ─────────────────────────────────────────
  # 4단계: 빌드 (lint + test 모두 완료 후 실행)
  # ─────────────────────────────────────────
  build:
    phase: build
    needs: [lint, test]         # lint와 test 모두 성공해야 실행
    steps:
      - name: compile
        run: npm run build      # 프로덕션 빌드
        image: node:18

실행 흐름

checkout
   ├── lint      (병렬)
   └── test      (병렬)
         └── build  (lint + test 완료 후)

포인트

checkout을 별도 Job으로 분리하여 소스코드를 먼저 준비합니다.

linttestneeds: [checkout]만 있으므로 병렬로 실행됩니다.

buildneeds: [lint, test]로 두 Job이 모두 성공해야 실행됩니다.

phase 메타데이터로 대시보드에서 단계를 시각적으로 구분합니다.

목차