fix(ci): E2E 健康檢查添加重試機制

2026-03-29 Claude Code:
- 添加 3 次重試,間隔 2 秒
- 顯示詳細連接錯誤信息
- 應對網路抖動問題

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-29 21:41:02 +08:00
parent bc5716b8fe
commit 8cae26eaf3

View File

@@ -101,22 +101,32 @@ jobs:
echo "🔗 檢查 API 健康狀態..."
echo "📍 Runner: $(hostname)"
echo "🌐 Target: $API_URL"
echo "🕐 Time: $(date '+%H:%M:%S')"
# 2026-03-29 Claude Code: 簡化版健康檢查,避免 SIGPIPE 問題
HTTP_CODE=$(curl -s -w "%{http_code}" -o /tmp/health_response.txt --connect-timeout 15 "$API_URL/api/v1/health" 2>/dev/null)
echo "📊 HTTP Code: [$HTTP_CODE]"
# 2026-03-29 Claude Code: 重試機制 (最多 3 次,間隔 2 秒)
for i in 1 2 3; do
echo "📡 嘗試連接 #$i..."
HTTP_CODE=$(curl -s -w "%{http_code}" -o /tmp/health_response.txt --connect-timeout 10 "$API_URL/api/v1/health" 2>&1) || true
echo "📊 HTTP Code: [$HTTP_CODE]"
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ API 可用: $API_URL"
cat /tmp/health_response.txt
echo ""
echo "working_api_url=$API_URL" >> $GITHUB_OUTPUT
else
echo "❌ API 無法連線: $API_URL (HTTP $HTTP_CODE)"
echo "📋 Response:"
cat /tmp/health_response.txt 2>/dev/null || echo "(empty)"
exit 1
fi
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ API 可用: $API_URL"
cat /tmp/health_response.txt
echo ""
echo "working_api_url=$API_URL" >> $GITHUB_OUTPUT
exit 0
fi
if [ $i -lt 3 ]; then
echo "⏳ 等待 2 秒後重試..."
sleep 2
fi
done
echo "❌ API 無法連線: $API_URL (HTTP $HTTP_CODE)"
echo "📋 Response:"
cat /tmp/health_response.txt 2>/dev/null || echo "(empty)"
exit 1
- name: Run E2E Verification
id: e2e