-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (75 loc) · 2.36 KB
/
ci.yml
File metadata and controls
88 lines (75 loc) · 2.36 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 24
uses: actions/setup-java@v4
with:
java-version: '24'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '9.0.0-rc-1'
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Verify Docker installation
run: |
docker --version
docker info
docker ps
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests with Testcontainers
run: ./gradlew test --no-daemon --stacktrace --parallel
env:
# Testcontainers 配置
TESTCONTAINERS_RYUK_DISABLED: false
TESTCONTAINERS_CHECKS_DISABLE: false
# Docker 相关配置
DOCKER_HOST: unix:///var/run/docker.sock
# 提高 Testcontainers 性能
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock
TESTCONTAINERS_HOST_OVERRIDE: localhost
# 避免 Testcontainers 拉取镜像时的网络问题
TESTCONTAINERS_REUSE_ENABLE: false
# CI 环境特殊配置
CI: true
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
**/build/test-results/test/
**/build/reports/tests/test/
**/build/reports/jacoco/
- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: |
**/build/reports/jacoco/test/html/
**/build/reports/jacoco/test/jacocoTestReport.xml
- name: Cleanup Docker containers
if: always()
run: |
docker container prune -f
docker image prune -f