chore: vitest 초기 세팅 및 샘플 테스트 추가 #378
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main, develop] | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 소스코드 체크아웃 | |
| uses: actions/checkout@v3 | |
| - name: Node.js 설정 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "20" | |
| - name: npm 캐시 설정 | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: 의존성 설치 | |
| run: npm install --frozen-lockfile | |
| - name: 린트 | |
| run: npm run lint | |
| - name: 빌드 | |
| run: npm run build | |
| test: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: 소스코드 체크아웃 | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Node.js 설정 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "20" | |
| - name: npm 캐시 설정 | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: PR 브랜치 의존성 설치 | |
| run: npm install --frozen-lockfile | |
| - name: PR 브랜치 커버리지 생성 | |
| run: npm run test:coverage | |
| - name: PR 커버리지 백업 | |
| run: cp coverage/coverage-final.json /tmp/head-coverage.json | |
| - name: Base 브랜치 체크아웃 | |
| run: git checkout -f ${{ github.base_ref }} | |
| - name: Base 브랜치 의존성 설치 | |
| run: npm install --frozen-lockfile | |
| - name: Base 브랜치 커버리지 생성 | |
| run: npm run test:coverage | |
| continue-on-error: true | |
| - name: Base 커버리지 백업 | |
| run: | | |
| if [ -f coverage/coverage-final.json ]; then | |
| cp coverage/coverage-final.json /tmp/base-coverage.json | |
| else | |
| cp /tmp/head-coverage.json /tmp/base-coverage.json | |
| fi | |
| - name: 커버리지 리포트 PR 코멘트 | |
| uses: ArtiomTr/jest-coverage-report-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| skip-step: all | |
| coverage-file: /tmp/head-coverage.json | |
| base-coverage-file: /tmp/base-coverage.json | |
| pr-checks: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: always() && github.event_name == 'pull_request' | |
| steps: | |
| - name: PR CI 결과 코멘트 | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const buildResult = '${{ needs.build.result }}'; | |
| const message = buildResult === 'success' | |
| ? '✅ CI 성공 (빌드 & 린트 통과)' | |
| : `❌ CI 실패 (빌드: ${buildResult})`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.payload.pull_request.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: message | |
| }); |