-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (71 loc) · 2.17 KB
/
test.yml
File metadata and controls
85 lines (71 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Test
on:
pull_request:
branches: [main, develop]
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Jest
id: jest
continue-on-error: true
run: pnpm test:ci
env:
CI: true
- name: Upload coverage
if: steps.jest.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 7
- name: PR 테스트 결과 코멘트
if: always()
uses: actions/github-script@v7
with:
script: |
const outcome = '${{ steps.jest.outcome }}';
const icon = (o) =>
o === 'success' ? '✅' : o === 'failure' ? '❌' : '⏭️';
const label = (o) =>
o === 'success' ? '통과' : o === 'failure' ? '실패' : '건너뜀';
const body = [
'## PR 테스트 결과',
'',
`${icon(outcome)} **Jest:** ${label(outcome)}`,
'',
outcome === 'success'
? '🎉 모든 테스트를 통과했습니다!'
: '⚠️ 테스트에 실패했습니다. 확인 후 수정해주세요.',
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
- name: Fail workflow if tests failed
if: always()
run: |
jest_outcome="${{ steps.jest.outcome }}"
echo "Jest: ${jest_outcome}"
if [ "${jest_outcome}" = "failure" ]; then
echo "::error::테스트 실패"
exit 1
fi