-
Notifications
You must be signed in to change notification settings - Fork 2
328 lines (288 loc) · 11.7 KB
/
ci.yml
File metadata and controls
328 lines (288 loc) · 11.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
name: PXF CI
on:
push:
branches: [ main, MDB_STABLE ]
pull_request:
branches: [ main, MDB_STABLE ]
jobs:
build_gpdb_debs:
name: Build open-gpdb Debian Packages
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
target: # make targets
- 'deb-gpdb-bionic'
- 'deb-gpdb-jammy'
steps:
- name: Get Date
id: get-date
run: echo "week=$(/bin/date -u '+%U')" >> "$GITHUB_OUTPUT"
- name: database deb files caching
id: cache-debs
uses: actions/cache@v4
with:
path: ./downloads/*.deb
# save per-os with 7 days TTL
key: ${{ runner.os }}-${{ matrix.target }}-${{ steps.get-date.outputs.week }}
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Build open-gpdb
if: steps.cache-debs.outputs.cache-hit != 'true'
run: make -C package ${{ matrix.target }}
build_pxf_debs:
name: Build PXF Debian Packages
runs-on: ubuntu-22.04
needs: [build_gpdb_debs]
strategy:
fail-fast: false
matrix:
target: # make targets
- pxf: 'deb-pxf6-gpdb-bionic'
db-cache-key-sfx: 'deb-gpdb-bionic'
- pxf: 'deb-pxf6-gpdb-jammy'
db-cache-key-sfx: 'deb-gpdb-jammy'
steps:
- name: Get Date
id: get-date
run: echo "week=$(/bin/date -u '+%U')" >> "$GITHUB_OUTPUT"
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: (restore) database deb files caching
id: cache-debs
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: ./downloads/*.deb
key: ${{ runner.os }}-${{ matrix.target.db-cache-key-sfx }}-${{ steps.get-date.outputs.week }}
- name: Build PXF6
run: make -C package ${{ matrix.target.pxf }}
- name: (save) PXF debs in cache
uses: actions/cache/save@v4
id: cache
with:
path: ./downloads/*pxf*.deb
key: ${{ runner.os }}-${{ matrix.target.pxf }}-${{ github.sha }}
pxf-test:
name: Automation tests
runs-on: ubuntu-22.04
needs: [build_pxf_debs]
strategy:
fail-fast: false
matrix:
target:
- pxf: 'deb-pxf6-gpdb-bionic'
db-cache-key-sfx: 'deb-gpdb-bionic'
test_group:
- cli
- external-table
- sanity
- smoke
- hdfs
- hcatalog
- hcfs
- hive
- hbase
- profile
- jdbc
- proxy
- unused
- s3
- features
- gpdb
steps:
- name: Get Date
id: get-date
run: echo "week=$(/bin/date -u '+%U')" >> "$GITHUB_OUTPUT"
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: (restore) database deb files caching
id: cache-debs-db
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: ./downloads/*.deb
key: ${{ runner.os }}-${{ matrix.target.db-cache-key-sfx }}-${{ steps.get-date.outputs.week }}
- name: (restore) PXF deb files caching
id: cache-debs-pxf
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: ./downloads/*pxf*.deb
key: ${{ runner.os }}-${{ matrix.target.pxf }}-${{ github.sha }}
- name: Use PXF builds
run: ls -lah ./downloads/
- name: Build automation images
if: matrix.target.pxf == 'deb-pxf6-gpdb-bionic' # FIXME: support other PXF versions
continue-on-error: true
timeout-minutes: 120
run: |
echo "Building automation images..."
cd automation
make copy-debs
docker compose build singlecluster
docker compose build universe
docker compose up -d
docker exec universe bash -lc "/entrypoint.sh"
- name: Run Test - ${{ matrix.test_group }}
id: run_test
continue-on-error: true
timeout-minutes: 120
run: |
docker exec universe bash -lc "/run_tests.sh ${{ matrix.test_group }}"
- name: Collect artifacts and generate stats
if: always()
id: collect_artifacts
run: |
mkdir -p artifacts/logs
TEST_GROUP="${{ matrix.test_group }}"
TEST_RESULT="${{ steps.run_test.outcome }}"
# Initialize counters
TOTAL=0
PASSED=0
FAILED=0
SKIPPED=0
# Copy test artifacts
docker exec universe bash -c "cp -r /home/gpadmin/workspace/pxf/automation/automation_logs/ /tmp/pxf-logs/ 2>/dev/null || true" || true
docker exec universe bash -c "cp -r /home/gpadmin/workspace/pxf/automation/log/ /tmp/pxf-logs/ 2>/dev/null || true" || true
docker exec universe bash -c "cp -r /home/gpadmin/workspace/pxf/automation/sqlrepo/ /tmp/pxf-logs/ 2>/dev/null || true" || true
docker exec universe bash -c "cp -r /home/gpadmin/workspace/pxf/automation/target/surefire-reports/ /tmp/pxf-logs/ 2>/dev/null || true" || true
docker exec universe bash -c "cp -r /home/gpadmin/workspace/singlecluster/storage/logs/ /tmp/pxf-logs/ 2>/dev/null || true" || true
docker cp universe:/tmp/pxf-logs artifacts/logs/ 2>/dev/null || true
# Parse surefire reports for automation tests
if [[ "$TEST_GROUP" != "cli" && "$TEST_GROUP" != "server" ]]; then
for xml in artifacts/logs/pxf-logs/surefire-reports/TEST-*.xml; do
if [ -f "$xml" ]; then
tests=$(grep -oP 'tests="\K\d+' "$xml" 2>/dev/null | head -1 || echo "0")
failures=$(grep -oP 'failures="\K\d+' "$xml" 2>/dev/null | head -1 || echo "0")
errors=$(grep -oP 'errors="\K\d+' "$xml" 2>/dev/null | head -1 || echo "0")
skipped=$(grep -oP 'skipped="\K\d+' "$xml" 2>/dev/null | head -1 || echo "0")
TOTAL=$((TOTAL + tests))
FAILED=$((FAILED + failures + errors))
SKIPPED=$((SKIPPED + skipped))
fi
done
PASSED=$((TOTAL - FAILED - SKIPPED))
fi
# Generate stats JSON
cat > artifacts/test_stats.json <<EOF
{
"group": "$TEST_GROUP",
"result": "$TEST_RESULT",
"total": $TOTAL,
"passed": $PASSED,
"failed": $FAILED,
"skipped": $SKIPPED
}
EOF
echo "failed_count=$FAILED" >> $GITHUB_OUTPUT
echo "skipped_count=$SKIPPED" >> $GITHUB_OUTPUT
echo "Test stats for $TEST_GROUP: total=$TOTAL, passed=$PASSED, failed=$FAILED, skipped=$SKIPPED"
- name: Cleanup containers
if: always()
run: |
docker compose -f automation/docker-compose.yml down -v || true
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.test_group }}
path: artifacts/**
if-no-files-found: ignore
retention-days: 7
- name: Check test result
if: always()
run: |
FAILED_COUNT="${{ steps.collect_artifacts.outputs.failed_count || 0 }}"
SKIPPED_COUNT="${{ steps.collect_artifacts.outputs.skipped_count || 0 }}"
if [ "${{ steps.run_test.outcome }}" == "failure" ] || [ "$FAILED_COUNT" -gt 0 ] || [ "$SKIPPED_COUNT" -gt 0 ]; then
echo "Test group ${{ matrix.test_group }} failed (Failures: $FAILED_COUNT, Skipped: $SKIPPED_COUNT)"
exit 1
fi
# Stage 3: Summary job
test-summary:
name: Test Summary
needs: [pxf-test]
if: always()
runs-on: ubuntu-22.04
steps:
- name: Download all test artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
pattern: test-results-*
- name: Generate summary
run: |
echo "## PXF Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Overall counters
OVERALL_TOTAL=0
OVERALL_PASSED=0
OVERALL_FAILED=0
OVERALL_SKIPPED=0
GROUPS_PASSED=0
GROUPS_FAILED=0
FAILED_GROUP_NAMES=""
# Collect all test stats
declare -A GROUP_STATS
for dir in all-artifacts/test-results-*; do
if [ -d "$dir" ] && [ -f "$dir/test_stats.json" ]; then
group=$(cat "$dir/test_stats.json" | grep -oP '"group":\s*"\K[^"]+' || basename "$dir" | sed 's/test-results-//')
result=$(cat "$dir/test_stats.json" | grep -oP '"result":\s*"\K[^"]+' || echo "unknown")
total=$(cat "$dir/test_stats.json" | grep -oP '"total":\s*\K\d+' || echo "0")
passed=$(cat "$dir/test_stats.json" | grep -oP '"passed":\s*\K\d+' || echo "0")
failed=$(cat "$dir/test_stats.json" | grep -oP '"failed":\s*\K\d+' || echo "0")
skipped=$(cat "$dir/test_stats.json" | grep -oP '"skipped":\s*\K\d+' || echo "0")
GROUP_STATS[$group]="$result,$total,$passed,$failed,$skipped"
OVERALL_TOTAL=$((OVERALL_TOTAL + total))
OVERALL_PASSED=$((OVERALL_PASSED + passed))
OVERALL_FAILED=$((OVERALL_FAILED + failed))
OVERALL_SKIPPED=$((OVERALL_SKIPPED + skipped))
if [ "$result" == "success" ] && [ "$failed" -eq 0 ] && [ "$skipped" -eq 0 ]; then
GROUPS_PASSED=$((GROUPS_PASSED + 1))
else
GROUPS_FAILED=$((GROUPS_FAILED + 1))
FAILED_GROUP_NAMES="${FAILED_GROUP_NAMES}${group} "
fi
fi
done
# Overall summary
echo "### Overall Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ $GROUPS_FAILED -eq 0 ]; then
echo "✅ **All ${GROUPS_PASSED} test groups passed**" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **${GROUPS_FAILED} of $((GROUPS_PASSED + GROUPS_FAILED)) test groups failed**" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Total Tests: $OVERALL_TOTAL" >> $GITHUB_STEP_SUMMARY
echo "- Passed: $OVERALL_PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Failed: $OVERALL_FAILED" >> $GITHUB_STEP_SUMMARY
echo "- Skipped: $OVERALL_SKIPPED" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Detailed table
echo "### Test Results by Group" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Test Group | Status | Passed | Failed | Skipped | Total |" >> $GITHUB_STEP_SUMMARY
echo "|------------|--------|-------:|-------:|--------:|------:|" >> $GITHUB_STEP_SUMMARY
for group in $(echo "${!GROUP_STATS[@]}" | tr ' ' '\n' | sort); do
IFS=',' read -r result total passed failed skipped <<< "${GROUP_STATS[$group]}"
if [ "$result" == "success" ] && [ "$failed" -eq 0 ] && [ "$skipped" -eq 0 ]; then
status="✅ PASS"
else
status="❌ FAIL"
fi
echo "| $group | $status | $passed | $failed | $skipped | $total |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
# Check if any group failed
if [ $GROUPS_FAILED -gt 0 ]; then
echo "::error::${GROUPS_FAILED} test group(s) failed: ${FAILED_GROUP_NAMES}"
exit 1
fi