-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (209 loc) · 6.81 KB
/
Copy pathci.yml
File metadata and controls
218 lines (209 loc) · 6.81 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
name: CI
on:
push:
branches: [ main ]
paths-ignore:
- 'docs/PERFORMANCE.md'
- 'docs/performance/**'
pull_request:
branches: [ main ]
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Build all modules
run: mvn -B -ntp clean package -DskipTests -Drpc.registry=local
unit-tests:
name: Unit Tests & Coverage
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Run core, transport and starter unit tests
run: >-
mvn -B -ntp test
-pl rpc-core,rpc-transport-netty,rpc-spring-boot-starter -am
-Drpc.registry=local
- name: Upload unit test and coverage reports
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-test-reports
retention-days: 7
if-no-files-found: warn
path: |
**/target/surefire-reports/
**/target/site/jacoco/
rpc-integration:
name: RPC Integration
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Run local-registry Netty end-to-end test
run: >-
mvn -B -ntp test
-pl rpc-consumer -am
-Dtest=FullIntegrationTest
-Dsurefire.failIfNoSpecifiedTests=false
-Drpc.registry=local
-Drpc.protocol=netty
- name: Upload integration test reports
if: always()
uses: actions/upload-artifact@v7
with:
name: rpc-integration-reports
retention-days: 7
if-no-files-found: warn
path: '**/target/surefire-reports/'
performance-matrix:
name: RPC Performance Matrix
runs-on: ubuntu-24.04
timeout-minutes: 35
outputs:
performance_markdown: ${{ steps.performance-record.outputs.markdown }}
report_path: ${{ steps.performance-record.outputs.report_path }}
report_time_utc: ${{ steps.performance-record.outputs.report_time_utc }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Verify tc and Docker
shell: bash
run: |
command -v tc
sudo tc qdisc show dev lo
docker --version
- name: Run production-baseline performance matrix
shell: bash
run: bash .github/scripts/run-performance-matrix.sh
- name: Prepare performance record
id: performance-record
if: always()
shell: bash
run: |
matrix='rpc-consumer/target/performance-matrix/matrix.md'
meta='rpc-consumer/target/performance-matrix/report-meta.env'
if [[ ! -s "$matrix" ]]; then
echo '没有生成性能矩阵报告。' >&2
exit 1
fi
if [[ ! -s "$meta" ]]; then
echo '没有生成性能报告元数据。' >&2
exit 1
fi
source "$meta"
case "$REPORT_RELATIVE_PATH" in
docs/performance/*.md) ;;
*) echo "非法性能报告路径: $REPORT_RELATIVE_PATH" >&2; exit 1 ;;
esac
echo "report_path=$REPORT_RELATIVE_PATH" >> "$GITHUB_OUTPUT"
echo "report_time_utc=$REPORT_RUN_TIME_UTC" >> "$GITHUB_OUTPUT"
delimiter="RPC_PERFORMANCE_${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT}"
{
echo "markdown<<${delimiter}"
cat "$matrix"
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
ci-gate:
name: CI Gate
if: always()
needs: [ build, unit-tests, rpc-integration, performance-matrix ]
runs-on: ubuntu-24.04
timeout-minutes: 2
steps:
- name: Verify required checks
shell: bash
run: |
test "${{ needs.build.result }}" = "success"
test "${{ needs.unit-tests.result }}" = "success"
test "${{ needs.rpc-integration.result }}" = "success"
test "${{ needs.performance-matrix.result }}" = "success"
record-performance:
name: Record Performance
if: >-
github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
needs.ci-gate.result == 'success' &&
needs.performance-matrix.result == 'success'
needs: [ ci-gate, performance-matrix ]
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Checkout main
uses: actions/checkout@v7
with:
ref: main
fetch-depth: 0
- name: Write standalone performance report
shell: bash
env:
PERFORMANCE_MARKDOWN: ${{ needs.performance-matrix.outputs.performance_markdown }}
REPORT_PATH: ${{ needs.performance-matrix.outputs.report_path }}
REPORT_TIME_UTC: ${{ needs.performance-matrix.outputs.report_time_utc }}
run: |
test -n "$PERFORMANCE_MARKDOWN"
test -n "$REPORT_PATH"
test -n "$REPORT_TIME_UTC"
case "$REPORT_PATH" in
docs/performance/*.md) ;;
*) echo "非法性能报告路径: $REPORT_PATH" >&2; exit 1 ;;
esac
git pull --ff-only origin main
mkdir -p "$(dirname "$REPORT_PATH")"
if [[ -e "$REPORT_PATH" ]]; then
echo "性能报告已存在,不允许覆盖: $REPORT_PATH" >&2
exit 1
fi
printf '%s\n' "$PERFORMANCE_MARKDOWN" > "$REPORT_PATH"
echo "已生成独立性能报告: $REPORT_PATH"
- name: Commit performance report
shell: bash
env:
REPORT_PATH: ${{ needs.performance-matrix.outputs.report_path }}
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add "$REPORT_PATH"
if git diff --cached --quiet; then
echo "没有新的性能报告。"
exit 0
fi
git commit -m 'docs: 记录 RPC 性能测试报告 [skip ci]'
git push origin HEAD:main