-
Notifications
You must be signed in to change notification settings - Fork 1
341 lines (305 loc) · 13.7 KB
/
ci.yaml
File metadata and controls
341 lines (305 loc) · 13.7 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: CI
on:
pull_request:
branches: [ main ]
paths:
- '.github/workflows/ci.yaml'
- '**/*.kt'
env:
GRADLE_OPTS: "-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 -Dkotlin.incremental=true -Dorg.gradle.configuration-cache=true -Dorg.gradle.build-cache=true -Dorg.gradle.caching=true -Dorg.gradle.jvmargs=\"-Xmx3g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC -XX:+UseStringDeduplication -Dfile.encoding=UTF-8\" -Dkotlin.daemon.jvmargs=\"-Xmx2g -XX:MaxMetaspaceSize=768m -XX:+UseG1GC\""
JVM_OPTS: "-Xmx3g -XX:MaxMetaspaceSize=1g -XX:+UseG1GC -XX:+UseStringDeduplication -Dfile.encoding=UTF-8"
TESTCONTAINERS_RYUK_DISABLED: false
TESTCONTAINERS_REUSE_ENABLE: true
DOCKER_BUILDKIT: 1
jobs:
quick-check:
name: Quick Check
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
cache-key: ${{ steps.cache-info.outputs.cache-key }}
gradle-cache-key: ${{ steps.cache-info.outputs.gradle-cache-key }}
java-version: ${{ steps.version-info.outputs.java-version }}
gradle-version: ${{ steps.version-info.outputs.gradle-version }}
steps:
- name: Checkout code
uses: actions/checkout@v5.0.0
with:
fetch-depth: 1
- name: Extract versions from libs.versions.toml
id: version-info
run: |
JAVA_VERSION=$(sed -n 's/^java\s*=\s*"\(.*\)"/\1/p' gradle/libs.versions.toml | head -n1)
GRADLE_VERSION=$(sed -n 's/^org-gradle\s*=\s*"\(.*\)"/\1/p' gradle/libs.versions.toml | head -n1)
echo "java-version=$JAVA_VERSION" >> $GITHUB_OUTPUT
echo "gradle-version=$GRADLE_VERSION" >> $GITHUB_OUTPUT
echo "Extracted Java version: $JAVA_VERSION"
echo "Extracted Gradle version: $GRADLE_VERSION"
- name: Set up JDK ${{ steps.version-info.outputs.java-version }}
uses: actions/setup-java@v5.0.0
with:
java-version: ${{ steps.version-info.outputs.java-version }}
distribution: 'temurin'
- name: Cache info
id: cache-info
run: |
GRADLE_CACHE_KEY="${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml', 'build-logic/**/*') }}"
DEPS_CACHE_KEY="${{ runner.os }}-deps-${{ hashFiles('gradle/libs.versions.toml', '**/build.gradle.kts') }}"
echo "cache-key=$GRADLE_CACHE_KEY" >> $GITHUB_OUTPUT
echo "gradle-cache-key=$DEPS_CACHE_KEY" >> $GITHUB_OUTPUT
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: ${{ steps.version-info.outputs.gradle-version }}
cache-read-only: false
cache-write-only: false
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
- name: Grant execute permission
run: chmod +x gradlew
- name: Quick compile
run: |
./gradlew compileKotlin compileTestKotlin \
--no-daemon \
--parallel \
--build-cache \
--configuration-cache \
--quiet
test-matrix:
name: Test
needs: quick-check
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
max-parallel: 4
matrix:
group:
- "core-foundation"
- "core-build-tools"
- "rds-light"
- "rds-heavy"
- "business-ai-pay"
- "business-oss"
- "business-communication"
- "security"
- "data-processing"
- "platform-integrations"
- "testing-tools"
- "integration-tests"
include:
- group: "core-foundation"
modules: "shared cacheable docsite"
testcontainers: false
timeout: 8
- group: "core-build-tools"
modules: "gradle-plugin version-catalog bom"
testcontainers: false
timeout: 10
- group: "rds-light"
modules: "rds:rds-shared rds:rds-flyway-migration-shared"
testcontainers: false
timeout: 8
- group: "rds-heavy"
modules: "rds:rds-crud rds:rds-jimmer-ext-postgres rds:rds-flyway-migration-postgresql rds:rds-flyway-migration-mysql8"
testcontainers: true
timeout: 25
- group: "business-ai-pay"
modules: "ai:ai-shared ai:ai-langchain4j pay:pay-shared pay:pay-wechat"
testcontainers: true
timeout: 18
- group: "business-oss"
modules: "oss:oss-shared oss:oss-minio oss:oss-aliyun-oss oss:oss-huawei-obs oss:oss-volcengine-tos"
testcontainers: true
timeout: 20
- group: "business-communication"
modules: "sms:sms-shared sms:sms-tencent surveillance:surveillance-shared surveillance:surveillance-hikvision"
testcontainers: true
timeout: 15
- group: "security"
modules: "security:security-crypto security:security-oauth2 security:security-spring"
testcontainers: false
timeout: 12
- group: "data-processing"
modules: "data:data-crawler data:data-extract"
testcontainers: true
timeout: 15
- group: "platform-integrations"
modules: "depend:depend-http-exchange depend:depend-jackson depend:depend-paho depend:depend-servlet depend:depend-springdoc-openapi depend:depend-xxl-job ksp:ksp-meta ksp:ksp-plugin ksp:ksp-shared psdk:psdk-wxpa ide:ide-idea-mcp"
testcontainers: false
timeout: 18
- group: "testing-tools"
modules: "testtoolkit:testtoolkit-shared testtoolkit:testtoolkit-testcontainers testtoolkit:testtoolkit-springmvc"
testcontainers: true
timeout: 15
- group: "integration-tests"
modules: "integrate-test:depend:jackson integrate-test:oss:minio integrate-test:cacheable"
testcontainers: true
timeout: 30
steps:
- name: Checkout code
uses: actions/checkout@v5.0.0
with:
fetch-depth: 1
- name: Set up JDK ${{ needs.quick-check.outputs.java-version }}
uses: actions/setup-java@v5.0.0
with:
java-version: ${{ needs.quick-check.outputs.java-version }}
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: ${{ needs.quick-check.outputs.gradle-version }}
cache-read-only: true
cache-write-only: false
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
- name: Grant execute permission
run: chmod +x gradlew
- name: Run tests
timeout-minutes: ${{ matrix.timeout }}
run: |
set -e
modules="${{ matrix.modules }}"
test_tasks=""
for module in $modules; do
module_path=":$module"
if [[ "$module" != *":"* ]]; then
module_path=":$module"
fi
test_tasks="$test_tasks $module_path:test"
done
echo "Running test tasks: $test_tasks"
./gradlew $test_tasks \
--no-daemon \
--parallel \
--build-cache \
--configuration-cache \
--continue \
-Dorg.gradle.workers.max=2 \
-Dorg.gradle.jvmargs="-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC" || true
env:
# TestContainers configuration
TESTCONTAINERS_RYUK_DISABLED: false
TESTCONTAINERS_REUSE_ENABLE: true
TESTCONTAINERS_STARTUP_TIMEOUT: 120
TESTCONTAINERS_CONNECT_TIMEOUT: 60
# Gradle and JVM configuration
GRADLE_OPTS: "${{ env.GRADLE_OPTS }}"
JAVA_OPTS: "${{ env.JVM_OPTS }}"
CI: true
# Parallel test configuration
JUNIT_PLATFORM_EXECUTION_PARALLEL_ENABLED: true
JUNIT_PLATFORM_EXECUTION_PARALLEL_MODE_DEFAULT: concurrent
- name: Collect test diagnostics
if: failure()
run: |
find . -name "*.log" -type f -exec echo "=== {} ===" \; -exec cat {} \; || true
if [[ "${{ matrix.testcontainers }}" == "true" ]]; then
echo "=== TestContainers Status ==="
docker ps -a --filter "label=org.testcontainers=true" || true
echo "=== TestContainers Logs ==="
for container in $(docker ps -aq --filter "label=org.testcontainers=true" 2>/dev/null || true); do
echo "--- Container $container ---"
docker logs "$container" --tail 50 2>/dev/null || echo "No logs available"
done
fi
if pgrep -f "org.gradle.launcher.daemon.bootstrap.GradleDaemon" > /dev/null; then
jps -v || true
fi
free -h || true
df -h || true
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.group }}
path: |
**/build/reports/tests/
**/build/test-results/
**/build/tmp/test/
**/*.log
retention-days: 5
- name: Cleanup TestContainers
if: always() && matrix.testcontainers == true
run: |
echo "Cleaning up TestContainers resources..."
# Clean up non-reusable TestContainers
docker container prune -f --filter "label=org.testcontainers=true" --filter "label!=org.testcontainers.reuse.enable=true" || true
docker network prune -f --filter "label=org.testcontainers=true" || true
docker volume prune -f --filter "label=org.testcontainers=true" --filter "label!=org.testcontainers.reuse.enable=true" || true
echo "TestContainers cleanup completed"
test-results:
name: Test Results Summary
needs: [ quick-check, test-matrix ]
runs-on: ubuntu-latest
if: always()
steps:
- name: Download all test results
uses: actions/download-artifact@v5.0.0
with:
path: test-results
pattern: test-results-*
- name: Generate test summary
run: |
echo "# Test Results Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Execution time:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
echo "**Test environment:** GitHub Actions (ubuntu-latest)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Module Group Test Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Module Group | Status | Container Dependencies | Duration |" >> $GITHUB_STEP_SUMMARY
echo "|--------------|--------|------------------------|----------|" >> $GITHUB_STEP_SUMMARY
declare -A group_testcontainers=(
["core-foundation"]="None"
["core-build-tools"]="None"
["rds-light"]="None"
["rds-heavy"]="TestContainers (PostgreSQL, MySQL, Redis)"
["business-ai-pay"]="TestContainers (Redis)"
["business-oss"]="TestContainers (Redis, MinIO)"
["business-communication"]="TestContainers (Redis)"
["security"]="None"
["data-processing"]="TestContainers (Redis)"
["platform-integrations"]="None"
["testing-tools"]="TestContainers (Database)"
["integration-tests"]="TestContainers (Full Stack)"
)
for group in core-foundation core-build-tools rds-light rds-heavy business-ai-pay business-oss business-communication security data-processing platform-integrations testing-tools integration-tests; do
testcontainers="${group_testcontainers[$group]}"
if [[ "${{ needs.test-matrix.result }}" == "success" ]]; then
echo "| $group | ✅ Pass | $testcontainers | - |" >> $GITHUB_STEP_SUMMARY
else
echo "| $group | ❌ Failed | $testcontainers | - |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.test-matrix.result }}" != "success" ]]; then
echo "## Failure Analysis" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Common troubleshooting:**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "1. **TestContainers startup failed**" >> $GITHUB_STEP_SUMMARY
echo " - Check Docker service status" >> $GITHUB_STEP_SUMMARY
echo " - Check network connectivity and image pulling" >> $GITHUB_STEP_SUMMARY
echo " - Timeout configuration may need adjustment" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "2. **Out of memory (OOM)**" >> $GITHUB_STEP_SUMMARY
echo " - JVM heap memory setting: 4GB" >> $GITHUB_STEP_SUMMARY
echo " - Metaspace setting: 1.5GB" >> $GITHUB_STEP_SUMMARY
echo " - Parallel worker limit: 6" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "3. **Test dependency conflicts**" >> $GITHUB_STEP_SUMMARY
echo " - Check port conflicts in parallel tests" >> $GITHUB_STEP_SUMMARY
echo " - Verify database connection pool configuration" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
- name: Check overall status
run: |
if [[ "${{ needs.quick-check.result }}" != "success" ]]; then
echo "Quick check failed"
exit 1
fi
if [[ "${{ needs.test-matrix.result }}" != "success" ]]; then
echo "Test matrix failed"
exit 1
fi
echo "All checks passed"