name: CI

on:
  # main 은 Deploy 워크플로가 테스트+빌드를 수행하므로 CI 중복 실행 제외(배포 시간 단축).
  push:
    branches: [dev]
  pull_request:
    branches: [main, dev]

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

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      # 린트는 결과만 보고하고 빌드를 막지 않음 (--fix 없이 검사만)
      - name: Lint (report only)
        continue-on-error: true
        run: |
          npx oxlint .
          npx eslint .

      # 단위/컴포넌트 테스트 — 실패 시 빌드/배포 차단(게이트)
      - name: Test
        run: npm test

      - name: Build
        run: npm run build

      - name: Upload build output
        uses: actions/upload-artifact@v3
        with:
          name: dist
          path: dist
          retention-days: 7
