From a61ea2f14d13c5537e24c4b2c18f05ee6434cc9f Mon Sep 17 00:00:00 2001 From: OG T Date: Thu, 26 Mar 2026 12:20:14 +0800 Subject: [PATCH] feat(ci): Phase 18.3 Daily E2E Health Check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 每日 08:30 (台北) 自動執行 E2E 驗證: - Alert → AI → Approval → Execution 完整流程 - Safe Mode 防護 (dry_run=true) - 失敗時 Telegram 通知 需配置 Secrets: - TELEGRAM_BOT_TOKEN - TELEGRAM_CHAT_ID Co-Authored-By: Claude Opus 4.5 --- .github/workflows/daily-e2e-health.yaml | 112 ++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/daily-e2e-health.yaml diff --git a/.github/workflows/daily-e2e-health.yaml b/.github/workflows/daily-e2e-health.yaml new file mode 100644 index 00000000..a2dc948b --- /dev/null +++ b/.github/workflows/daily-e2e-health.yaml @@ -0,0 +1,112 @@ +# ============================================================================= +# AWOOOI Daily E2E Health Check (Phase 18.3) +# ============================================================================= +# 🎯 每日端到端驗證:Alert → AI → Approval → Execution +# +# 觸發時機: +# - 每日 00:30 UTC (08:30 台北) +# - 手動觸發 +# +# 驗證內容: +# - E2E Tool Call 完整流程 +# - Safe Mode 防護機制 +# - 目標資源驗證 +# +# 失敗通知: Telegram + +name: Daily E2E Health Check + +on: + schedule: + - cron: '30 0 * * *' # 每日 00:30 UTC (08:30 台北) + workflow_dispatch: + inputs: + api_url: + description: 'API URL to test' + required: false + default: 'http://192.168.0.120:32334' + dry_run: + description: 'Dry run mode (skip actual approval)' + required: false + default: 'true' + type: choice + options: + - 'true' + - 'false' + +concurrency: + group: daily-e2e + cancel-in-progress: true + +env: + PYTHON_VERSION: '3.11' + DEFAULT_API_URL: http://192.168.0.120:32334 + +jobs: + e2e-health-check: + name: E2E Health Check + runs-on: [self-hosted, harbor, k8s] + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Install dependencies + working-directory: apps/api + run: uv sync + + - name: Check API Health + run: | + API_URL="${{ github.event.inputs.api_url || env.DEFAULT_API_URL }}" + echo "🔗 檢查 API 健康狀態..." + if curl -s --connect-timeout 10 "$API_URL/health" > /dev/null; then + echo "✅ API 可用: $API_URL" + else + echo "❌ API 無法連線: $API_URL" + exit 1 + fi + + - name: Run E2E Verification + id: e2e + working-directory: apps/api + env: + PYTHONPATH: ${{ github.workspace }}/apps/api + run: | + API_URL="${{ github.event.inputs.api_url || env.DEFAULT_API_URL }}" + DRY_RUN="${{ github.event.inputs.dry_run || 'true' }}" + + echo "🎯 執行 E2E Tool Call Verification v2.0" + echo " API: $API_URL" + echo " Dry Run: $DRY_RUN" + + if [ "$DRY_RUN" = "true" ]; then + uv run python -m scripts.e2e_tool_call_verification --api-url "$API_URL" --dry-run + else + uv run python -m scripts.e2e_tool_call_verification --api-url "$API_URL" --no-dry-run + fi + + - name: Summary + if: always() + run: | + echo "## Daily E2E Health Check 完成" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| 項目 | 值 |" >> $GITHUB_STEP_SUMMARY + echo "|------|-----|" >> $GITHUB_STEP_SUMMARY + echo "| API URL | ${{ github.event.inputs.api_url || env.DEFAULT_API_URL }} |" >> $GITHUB_STEP_SUMMARY + echo "| 時間 | $(TZ='Asia/Taipei' date '+%Y-%m-%d %H:%M:%S') |" >> $GITHUB_STEP_SUMMARY + echo "| 結果 | ${{ steps.e2e.outcome }} |" >> $GITHUB_STEP_SUMMARY + + # Phase 18.3.2: 失敗時 Telegram 通知 + - name: Notify on Failure + if: failure() + run: | + curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ + -d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \ + -d "text=❌ Daily E2E Health Check 失敗%0A時間: $(TZ='Asia/Taipei' date '+%Y-%m-%d %H:%M')%0A詳情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"