Skip to content

Commit 7fda99c

Browse files
committed
ci: PR 커버리지 리포트 자동화
1 parent 9f602ea commit 7fda99c

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
permissions:
1111
pull-requests: write
1212
contents: read
13+
1314
jobs:
1415
build:
1516
runs-on: ubuntu-latest
@@ -43,23 +44,44 @@ jobs:
4344
- name: 빌드
4445
run: npm run build
4546

47+
test:
48+
runs-on: ubuntu-latest
49+
if: github.event_name == 'pull_request'
50+
51+
steps:
52+
- name: 소스코드 체크아웃
53+
uses: actions/checkout@v3
54+
with:
55+
fetch-depth: 0
56+
57+
- name: Node.js 설정
58+
uses: actions/setup-node@v3
59+
with:
60+
node-version: "18"
61+
62+
- name: 커버리지 리포트
63+
uses: ArtiomTr/jest-coverage-report-action@v2
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
test-script: npm run test:coverage
67+
package-manager: npm
68+
4669
pr-checks:
47-
needs: build
70+
needs: [build]
4871
runs-on: ubuntu-latest
72+
if: always() && github.event_name == 'pull_request'
4973
steps:
5074
- name: PR CI 결과 코멘트
51-
if: always()
5275
uses: actions/github-script@v6
5376
with:
5477
script: |
55-
const pr = context.payload.pull_request;
56-
const status = '${{ job.status }}';
57-
const message = status === 'success'
58-
? '✅ CI 성공'
59-
: '❌ CI 실패';
78+
const buildResult = '${{ needs.build.result }}';
79+
const message = buildResult === 'success'
80+
? '✅ CI 성공 (빌드 & 린트 통과)'
81+
: `❌ CI 실패 (빌드: ${buildResult})`;
6082
6183
github.rest.issues.createComment({
62-
issue_number: pr.number,
84+
issue_number: context.payload.pull_request.number,
6385
owner: context.repo.owner,
6486
repo: context.repo.repo,
6587
body: message

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
setupFiles: ["./vitest.setup.ts"],
1111
coverage: {
1212
provider: "v8",
13-
reporter: ["text", "lcov"],
13+
reporter: ["text", "lcov", "json"],
1414
exclude: [
1515
"node_modules/**",
1616
".next/**",

0 commit comments

Comments
 (0)