Skip to content

Commit c9bf11e

Browse files
committed
Update current feature
1 parent 80dbfc4 commit c9bf11e

File tree

1 file changed

+135
-21
lines changed

1 file changed

+135
-21
lines changed

.github/workflows/dispatch.yaml

Lines changed: 135 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,151 @@
1-
name: "e2e: platform=k8s, survey=ztf, science=true, infra=self-hosted"
1+
name: "Home-CI External Test Results Processing"
22

33
on:
44
repository_dispatch:
5-
types: [dispatch-with-artifacts]
5+
types: [dispatch-with-artifacts, test-dispatch-with-artifacts]
66

77
jobs:
8-
e2e-science:
8+
process-test-results:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: build
11+
- name: Display test metadata
1212
run: |
13-
image="${{ github.event.client_payload.image }}"
14-
if [ "${{ github.event.client_payload.build }}" == "true" ]; then
15-
echo "build success for image $image"
13+
echo "🔍 Processing test results from home-ci"
14+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
15+
echo "📍 Branch: ${{ github.event.client_payload.branch }}"
16+
echo "📍 Commit: ${{ github.event.client_payload.commit }}"
17+
echo "📍 Success: ${{ github.event.client_payload.success }}"
18+
echo "📍 Source: ${{ github.event.client_payload.source }}"
19+
echo "📍 Timestamp: ${{ github.event.client_payload.timestamp }}"
20+
echo "📍 Artifact: ${{ github.event.client_payload.artifact_name }}"
21+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
22+
23+
- name: Process test logs
24+
run: |
25+
echo "📋 Processing test execution logs..."
26+
27+
# Check if artifacts exist and process them
28+
if [ "${{ toJson(github.event.client_payload.artifacts) }}" != "null" ]; then
29+
echo "✅ Test artifacts found"
30+
31+
# Create artifacts directory
32+
mkdir -p test-artifacts
33+
34+
# List available artifacts
35+
echo "📦 Available artifacts:"
36+
echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r 'keys[]' | while read artifact; do
37+
echo " - $artifact"
38+
done
39+
1640
else
17-
echo "build failed for image $image"
18-
exit 1
41+
echo "⚠️ No artifacts found in payload"
1942
fi
20-
- name: e2e
43+
44+
- name: Decode and save test logs
45+
if: github.event.client_payload.artifacts
2146
run: |
22-
cluster="${{ github.event.client_payload.cluster }}"
23-
if [ "${{ github.event.client_payload.e2e }}" == "true" ]; then
24-
echo "Succeed to run e2e tests on cluster $cluster"
47+
echo "💾 Extracting test logs..."
48+
49+
# Extract log files (find files with .log extension in artifacts)
50+
echo '${{ toJson(github.event.client_payload.artifacts) }}' | jq -r '
51+
to_entries[] |
52+
select(.key | endswith(".log")) |
53+
"LOG_FILE=\(.key)\nLOG_CONTENT=\(.value.content)"
54+
' > log_vars.env
55+
56+
if [ -f log_vars.env ] && [ -s log_vars.env ]; then
57+
source log_vars.env
58+
59+
# Decode and save log content
60+
if [ ! -z "$LOG_CONTENT" ] && [ "$LOG_CONTENT" != "null" ]; then
61+
echo "$LOG_CONTENT" | base64 -d > "test-artifacts/$LOG_FILE"
62+
echo "✅ Saved log file: test-artifacts/$LOG_FILE"
63+
64+
# Show log summary
65+
echo ""
66+
echo "📊 Log file summary:"
67+
echo " Size: $(wc -c < test-artifacts/$LOG_FILE) bytes"
68+
echo " Lines: $(wc -l < test-artifacts/$LOG_FILE) lines"
69+
70+
# Show key information from logs
71+
echo ""
72+
echo "🔍 Test execution highlights:"
73+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
74+
75+
# Extract key information
76+
if grep -q "Install kind" "test-artifacts/$LOG_FILE"; then
77+
echo " ✅ Kind installation step found"
78+
fi
79+
80+
if grep -q "Create k8s cluster" "test-artifacts/$LOG_FILE"; then
81+
echo " ✅ Kubernetes cluster creation step found"
82+
fi
83+
84+
if grep -q "kubectl get" "test-artifacts/$LOG_FILE"; then
85+
echo " ✅ Kubernetes verification commands found"
86+
fi
87+
88+
# Show any errors
89+
if grep -qi "error\|fail" "test-artifacts/$LOG_FILE"; then
90+
echo " ⚠️ Errors or failures detected:"
91+
grep -i "error\|fail" "test-artifacts/$LOG_FILE" | head -3 | sed 's/^/ /'
92+
fi
93+
94+
# Show success indicators
95+
if grep -q "Ready.*control-plane" "test-artifacts/$LOG_FILE"; then
96+
echo " ✅ Kubernetes control plane ready"
97+
fi
98+
99+
else
100+
echo "⚠️ Log content is empty or null"
101+
fi
25102
else
26-
echo "Failed to run e2e tests on cluster $cluster"
27-
exit 1
103+
echo "ℹ️ No log files found in artifacts"
28104
fi
29-
- name: push
105+
106+
- name: Create test result summary
30107
run: |
31-
image="${{ github.event.client_payload.image }}"
32-
if [ "${{ github.event.client_payload.push }}" == "true" ]; then
33-
echo "Succeed in pushing image $image"
108+
echo "📈 Creating test result summary..."
109+
110+
# Determine status emoji and message
111+
if [ "${{ github.event.client_payload.success }}" == "true" ]; then
112+
STATUS_EMOJI="✅"
113+
STATUS_MSG="SUCCESS"
114+
STATUS_COLOR="🟢"
34115
else
35-
echo "Failed to push image $image"
36-
exit 1
116+
STATUS_EMOJI="❌"
117+
STATUS_MSG="FAILURE"
118+
STATUS_COLOR="🔴"
37119
fi
120+
121+
echo ""
122+
echo "╭─────────────────────────────────────────╮"
123+
echo "│ TEST RESULT SUMMARY │"
124+
echo "├─────────────────────────────────────────┤"
125+
echo "│ Status: $STATUS_COLOR $STATUS_EMOJI $STATUS_MSG"
126+
echo "│ Branch: ${{ github.event.client_payload.branch }}"
127+
echo "│ Commit: ${{ github.event.client_payload.commit }}"
128+
echo "│ Source: ${{ github.event.client_payload.source }}"
129+
echo "╰─────────────────────────────────────────╯"
130+
131+
# Create summary for GitHub Actions summary
132+
cat >> $GITHUB_STEP_SUMMARY << EOF
133+
## $STATUS_EMOJI External Test Results - $STATUS_MSG
134+
135+
**Test Details:**
136+
- **Status**: $STATUS_EMOJI $STATUS_MSG
137+
- **Branch**: \`${{ github.event.client_payload.branch }}\`
138+
- **Commit**: \`${{ github.event.client_payload.commit }}\`
139+
- **Source**: ${{ github.event.client_payload.source }}
140+
- **Timestamp**: $(date -d @${{ github.event.client_payload.timestamp }} 2>/dev/null || echo "${{ github.event.client_payload.timestamp }}")
141+
142+
**Artifact**: ${{ github.event.client_payload.artifact_name }}
143+
EOF
144+
145+
- name: Upload artifacts
146+
if: github.event.client_payload.artifacts
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: external-test-results-${{ github.event.client_payload.artifact_name }}
150+
path: test-artifacts/
151+
retention-days: 30

0 commit comments

Comments
 (0)