-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (146 loc) · 4.93 KB
/
ci.yml
File metadata and controls
169 lines (146 loc) · 4.93 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: testpassword
MYSQL_DATABASE: closetnangam_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test --stacktrace
env:
SPRING_PROFILES_ACTIVE: test
DB_USERNAME: root
DB_PASSWORD: testpassword
JWT_SECRET: test-secret-key-for-ci-environment-minimum-32chars
KAKAO_CLIENT_ID: test
KAKAO_CLIENT_SECRET: test
GOOGLE_CLIENT_ID: test
GOOGLE_CLIENT_SECRET: test
NAVER_CLIENT_ID: test
NAVER_CLIENT_SECRET: test
GEMINI_API_KEY: test-gemini-key
WEATHER_API_KEY: test-weather-key
- name: Upload test report
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-report
path: build/reports/tests/test/
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: build/test-results/test/**/*.xml
- name: Post Korean test summary
if: always() && github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 << 'PYTHON'
import os
import glob
import xml.etree.ElementTree as ET
xml_files = glob.glob("build/test-results/test/**/*.xml", recursive=True)
total = 0
passed = 0
failed = 0
skipped = 0
errors = 0
failed_tests = []
for xml_file in xml_files:
try:
tree = ET.parse(xml_file)
root = tree.getroot()
suites = [root] if root.tag == 'testsuite' else root.findall('testsuite')
for suite in suites:
total += int(suite.get('tests', 0))
failed += int(suite.get('failures', 0))
errors += int(suite.get('errors', 0))
skipped += int(suite.get('skipped', 0))
for tc in suite.findall('testcase'):
if tc.find('failure') is not None or tc.find('error') is not None:
failed_tests.append(f"- `{tc.get('classname')}.{tc.get('name')}`")
except Exception:
pass
passed = total - failed - errors - skipped
all_passed = (failed + errors) == 0
if all_passed:
icon = "✅"
status = "모든 테스트 통과"
else:
icon = "❌"
status = "테스트 실패"
lines = [
f"## {icon} 테스트 결과: {status}",
"",
f"| 항목 | 수 |",
f"|---|---|",
f"| 전체 | {total} |",
f"| 통과 | {passed} |",
f"| 실패 | {failed + errors} |",
f"| 건너뜀 | {skipped} |",
]
if failed_tests:
lines += ["", "### 실패한 테스트"] + failed_tests[:10]
if len(failed_tests) > 10:
lines.append(f"_... 외 {len(failed_tests) - 10}건_")
body = "\n".join(lines)
pr_number = os.environ.get("PR_NUMBER", "")
with open("/tmp/test_summary.md", "w") as f:
f.write(body)
PYTHON
gh pr comment ${{ github.event.number }} --body "$(cat /tmp/test_summary.md)"
- name: Build
run: ./gradlew build -x test
env:
SPRING_PROFILES_ACTIVE: test
DB_USERNAME: root
DB_PASSWORD: testpassword
JWT_SECRET: test-secret-key-for-ci-environment-minimum-32chars
KAKAO_CLIENT_ID: test
KAKAO_CLIENT_SECRET: test
GOOGLE_CLIENT_ID: test
GOOGLE_CLIENT_SECRET: test
NAVER_CLIENT_ID: test
NAVER_CLIENT_SECRET: test
GEMINI_API_KEY: test-gemini-key
WEATHER_API_KEY: test-weather-key