-
Notifications
You must be signed in to change notification settings - Fork 1
277 lines (228 loc) · 8.64 KB
/
ci.yml
File metadata and controls
277 lines (228 loc) · 8.64 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
name: CI/CD Pipeline
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17, 21]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Run unit tests
run: ./gradlew test --info
- name: Run integration tests
run: ./gradlew test --tests "*IntegrationTest*"
- name: Run performance tests
run: ./gradlew test --tests "*StressTest*" --info
continue-on-error: true # Performance tests may have timing variations
- name: Generate test report
run: ./gradlew test jacocoTestReport
if: always()
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-java-${{ matrix.java-version }}
path: |
build/reports/tests/
build/reports/jacoco/
build/test-results/
build/reports/performance/
- name: Check test coverage
run: |
# Extract coverage percentage from JaCoCo report
COVERAGE=$(grep -oP 'Total.*?instruction.*?>\K\d+(?:\.\d+)?' build/reports/jacoco/test/html/index.html | head -1)
echo "Test coverage: $COVERAGE%"
# Fail if coverage is below 80%
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "❌ Test coverage too low: $COVERAGE% (minimum: 80%)"
exit 1
else
echo "✅ Test coverage acceptable: $COVERAGE%"
fi
performance-analysis:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download performance reports
uses: actions/download-artifact@v4
with:
name: test-results-java-17
path: build/reports/
- name: Analyze performance metrics
run: |
echo "📊 Performance Analysis Report"
echo "================================"
# Check if performance reports exist
if [ -d "build/reports/performance" ]; then
echo "✅ Performance reports found"
ls -la build/reports/performance/
# Analyze latest performance report
LATEST_REPORT=$(find build/reports/performance -name "*.txt" -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")
if [ -n "$LATEST_REPORT" ]; then
echo "📈 Latest Performance Report: $LATEST_REPORT"
echo "---"
cat "$LATEST_REPORT"
echo "---"
# Check for performance issues
if grep -q "❌ Poor" "$LATEST_REPORT"; then
echo "🚨 CRITICAL: Performance regression detected!"
exit 1
elif grep -q "⚠️" "$LATEST_REPORT"; then
echo "⚠️ WARNING: Performance issues detected"
else
echo "✅ Performance within acceptable limits"
fi
fi
else
echo "⚠️ No performance reports found - running basic performance test"
# Run a quick performance test if no reports exist
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet
fi
build:
runs-on: ubuntu-latest
needs: [test, performance-analysis]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build plugin JAR
run: ./gradlew build -x test # Skip tests since we already ran them
- name: Verify JAR contents
run: |
echo "📦 Plugin JAR contents:"
java -jar build/libs/Matchbox-*.jar --version 2>/dev/null || echo "JAR created successfully"
echo "📊 JAR file details:"
ls -la build/libs/
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: matchbox-plugin
path: build/libs/Matchbox-*.jar
release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: matchbox-plugin
path: build/libs/
- name: Create release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
name: Matchbox v${{ github.run_number }}
body: |
## 🚀 Automated Release
This release has been automatically built and tested.
### ✅ Quality Assurance
- All unit tests passed
- Integration tests completed
- Performance tests validated
- Code coverage requirements met
### 📦 Assets
- Plugin JAR file attached
### 🔗 Links
- [Full Changelog](CHANGELOG.md)
- [API Documentation](MatchboxAPI_Docs.md)
draft: false
prerelease: false
files: build/libs/Matchbox-*.jar
# Performance regression detection for PRs
performance-regression-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Run baseline performance test
run: |
echo "📊 Running baseline performance test on ${{ github.base_ref }}"
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet --info > baseline_performance.log 2>&1
# Extract key metrics from baseline
BASELINE_TIME=$(grep "Session.*created in" baseline_performance.log | grep -oP '\d+ ms' | awk '{sum+=$1} END {print sum/NR}')
echo "BASELINE_AVG_TIME=$BASELINE_TIME" >> $GITHUB_ENV
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Run PR performance test
run: |
echo "📊 Running PR performance test on ${{ github.head_ref }}"
./gradlew test --tests "SessionStressTest.shouldHandleTenConcurrentSessions" --quiet --info > pr_performance.log 2>&1
# Extract key metrics from PR
PR_TIME=$(grep "Session.*created in" pr_performance.log | grep -oP '\d+ ms' | awk '{sum+=$1} END {print sum/NR}')
echo "PR_AVG_TIME=$PR_TIME" >> $GITHUB_ENV
- name: Compare performance
run: |
echo "📈 Performance Comparison"
echo "========================"
echo "Baseline (${{ github.base_ref }}): ${{ env.BASELINE_AVG_TIME }}ms average"
echo "PR (${{ github.head_ref }}): ${{ env.PR_AVG_TIME }}ms average"
# Calculate performance change
if [ -n "${{ env.BASELINE_AVG_TIME }}" ] && [ -n "${{ env.PR_AVG_TIME }}" ]; then
BASELINE="${{ env.BASELINE_AVG_TIME }}"
PR="${{ env.PR_AVG_TIME }}"
# Calculate percentage change
if (( $(echo "$BASELINE > 0" | bc -l) )); then
CHANGE=$(echo "scale=2; (($PR - $BASELINE) / $BASELINE) * 100" | bc -l)
echo "Performance change: ${CHANGE}%"
# Check for significant regression
if (( $(echo "$CHANGE > 25" | bc -l) )); then
echo "🚨 SIGNIFICANT PERFORMANCE REGRESSION: +${CHANGE}% slower"
echo "This PR introduces a performance regression that should be addressed."
exit 1
elif (( $(echo "$CHANGE < -10" | bc -l) )); then
echo "✅ PERFORMANCE IMPROVEMENT: ${CHANGE}% faster"
else
echo "✅ Performance change within acceptable range: ${CHANGE}%"
fi
fi
else
echo "⚠️ Could not calculate performance change - missing metrics"
fi