ci: 규칙을 자동으로 강제하는 검사 추가
지금까지 "커밋 전 lint/test 통과"는 문서상의 약속일 뿐 강제되지 않았다. - CI(GitHub Actions) 추가 — 세 스택의 lint·test·build 와 backend e2e 를 PR 마다 실행. error-codes-sync 잡은 sync 를 재실행한 뒤 git diff 로 생성 파일 드리프트를 검사한다. 레지스트리만 고치고 sync 를 빠뜨리면 클라이언트 사전이 조용히 어긋나기 때문. - lint 스크립트에 --max-warnings 0 적용. 기존에는 경고가 있어도 통과해 "Warning 0" 규칙이 사실상 무의미했다. 자동 수정은 lint:fix 로 분리. - 문서로만 있던 규칙을 린트로 이관: any/dynamic 금지, console/print 금지, Vue 인라인 스타일·Options API 금지, Dart const 누락·await 누락, HttpException 직접 생성 차단(BusinessException 유도). - backend 에 @/ 경로 alias 설정 (tsconfig paths + jest moduleNameMapper). 공통 규칙이 요구하는 절대경로 alias 가 backend 에만 빠져 있었다. - npm audit 취약점 10건 중 9건 해결. 남은 multer(high)는 platform-express v12 가 필요해 Nest v11 생태계와 충돌하고, 파일 업로드 엔드포인트가 없어 도달 경로가 없다 — security.md 에 재검토 조건 기록. - PR 템플릿 추가. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
# 같은 브랜치에서 새 푸시가 오면 이전 실행을 취소한다
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
backend:
|
||||
name: Backend (lint · test · e2e · build)
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: backend
|
||||
# e2e 는 응답 계약을 실제 HTTP 로 검증하므로 DB 가 필요하다
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
env:
|
||||
POSTGRES_USER: ci_user
|
||||
POSTGRES_PASSWORD: ci_password
|
||||
POSTGRES_DB: ci_db
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U ci_user -d ci_db"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: npm
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- run: npm ci
|
||||
|
||||
# Warning 0 (.claude/rules/checklist.md)
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Test
|
||||
run: npm run test
|
||||
|
||||
# 표준 응답 래퍼·에러 코드·traceId 계약 검증 (.claude/rules/response-format.md)
|
||||
- name: E2E test
|
||||
run: npm run test:e2e
|
||||
env:
|
||||
NODE_ENV: test
|
||||
DB_HOST: localhost
|
||||
DB_PORT: 5432
|
||||
DB_USER: ci_user
|
||||
DB_PASSWORD: ci_password
|
||||
DB_NAME: ci_db
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
frontend:
|
||||
name: Frontend (lint · type-check · test)
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: frontend
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Type check
|
||||
run: npm run type-check
|
||||
|
||||
- name: Test
|
||||
run: npm run test:unit -- --run
|
||||
|
||||
flutter:
|
||||
name: Flutter (analyze · test)
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: flutter
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
cache: true
|
||||
|
||||
# .env 는 pubspec 의 asset 이라 없으면 analyze 가 경고를 낸다
|
||||
- name: Prepare .env
|
||||
run: cp .env.example .env
|
||||
|
||||
- run: flutter pub get
|
||||
|
||||
- name: Analyze
|
||||
run: flutter analyze
|
||||
|
||||
- name: Test
|
||||
run: flutter test
|
||||
|
||||
error-codes-sync:
|
||||
name: 에러 코드 SSOT 동기화 검사
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: npm
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- name: Install backend deps
|
||||
working-directory: backend
|
||||
run: npm ci
|
||||
|
||||
# 레지스트리만 고치고 sync 를 안 돌린 경우를 잡아낸다.
|
||||
# 생성 파일이 최신이면 diff 가 비어 있어야 한다.
|
||||
- name: Regenerate client error lexicons
|
||||
working-directory: backend
|
||||
run: npm run sync:error-codes
|
||||
|
||||
- name: Fail if generated files are stale
|
||||
run: |
|
||||
if ! git diff --exit-code -- \
|
||||
frontend/src/shared/constants/error-codes.generated.ts \
|
||||
flutter/lib/core/api/error_lexicon.g.dart; then
|
||||
echo ""
|
||||
echo "::error::에러 코드 생성 파일이 레지스트리와 어긋났습니다."
|
||||
echo "backend 에서 'npm run sync:error-codes' 를 실행하고 생성 파일을 함께 커밋하세요."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user