diff --git a/.gitea/workflows/ci-health-daily.yml b/.gitea/workflows/ci-health-daily.yml index 26a02ab8a..341d4e64b 100644 --- a/.gitea/workflows/ci-health-daily.yml +++ b/.gitea/workflows/ci-health-daily.yml @@ -8,7 +8,7 @@ permissions: jobs: ci-health-report: name: CI健康度每日巡检 - runs-on: saas + runs-on: ci-l2 timeout-minutes: 15 steps: - name: Checkout code diff --git a/.gitea/workflows/ci-trigger-monitor.yml b/.gitea/workflows/ci-trigger-monitor.yml index 4a0292353..a3abbbf62 100644 --- a/.gitea/workflows/ci-trigger-monitor.yml +++ b/.gitea/workflows/ci-trigger-monitor.yml @@ -16,15 +16,15 @@ permissions: jobs: monitor: name: Monitor CI Trigger Reliability - runs-on: ubuntu-latest + runs-on: ci-l2 timeout-minutes: 5 steps: - name: Checkout code - uses: actions/checkout@v3 - # 网络波动自动重试2次 - retry: - max_attempts: 2 - retry_on: error + shell: sh + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + curl -sH "Authorization: token $GITHUB_TOKEN" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/raw/scripts/ci/step_checkout.sh?ref=${GITHUB_SHA}" | bash - name: Check CI trigger status for all open PRs env: diff --git a/.gitea/workflows/code-review.yml b/.gitea/workflows/code-review.yml index 4a0000285..8374aaba8 100644 --- a/.gitea/workflows/code-review.yml +++ b/.gitea/workflows/code-review.yml @@ -15,20 +15,18 @@ concurrency: jobs: code-review: name: AI Code Review - runs-on: ubuntu-latest + runs-on: ci-l2 # 跳过草稿 PR if: ${{ !gitea.event.pull_request.draft }} steps: # actions/checkout 由 runner 在宿主机层面处理,不受容器网络影响 - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # 网络波动自动重试2次 - retry: - max_attempts: 2 - retry_on: error + shell: sh + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + curl -sH "Authorization: token $GITHUB_TOKEN" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/raw/scripts/ci/step_checkout.sh?ref=${GITHUB_SHA}" | bash - name: Install dependencies run: | diff --git a/.gitea/workflows/daily-check.yml b/.gitea/workflows/daily-check.yml index b352213db..e0d26842a 100644 --- a/.gitea/workflows/daily-check.yml +++ b/.gitea/workflows/daily-check.yml @@ -12,7 +12,7 @@ jobs: # ── 1. 生产环境冒烟测试 ───────────────────────────────────────────── production-smoke: name: Production Smoke Test - runs-on: saas + runs-on: ci-l2 timeout-minutes: 8 outputs: report: ${{ steps.smoke.outputs.report }} @@ -121,7 +121,7 @@ jobs: # ── 2. Staging API 集成测试 ───────────────────────────────────────── staging-api-tests: name: Staging API Integration Tests - runs-on: saas + runs-on: ci-l2 timeout-minutes: 10 outputs: report: ${{ steps.smoke.outputs.report }} @@ -176,6 +176,9 @@ jobs: - name: Run API smoke test on staging id: smoke shell: sh + env: + STAGING_TEST_USER: ${{ secrets.STAGING_TEST_USER }} + STAGING_TEST_PASSWORD: ${{ secrets.STAGING_TEST_PASSWORD }} run: | set +e START_TIME=$(date +%s) @@ -183,8 +186,8 @@ jobs: docker run --rm \ -e BASE_URL=https://staging-api.xiaoxiajianji.com \ -e WEB_URL=https://staging.xiaoxiajianji.com \ - -e TEST_USER=18314979086@163.com \ - -e TEST_PASSWORD=Ying1234 \ + -e TEST_USER="$STAGING_TEST_USER" \ + -e TEST_PASSWORD="$STAGING_TEST_PASSWORD" \ -e CLEANUP_ENABLED=1 \ -e PERF_CHECK_ENABLED=1 \ -e PERF_WARN_THRESHOLD_MS=500 \ @@ -270,7 +273,7 @@ jobs: # ── 3. Staging 浏览器 E2E ────────────────────────────────────────── staging-e2e: name: Staging Browser E2E - runs-on: saas + runs-on: ci-l2 timeout-minutes: 15 outputs: report: ${{ steps.smoke.outputs.report }} @@ -371,7 +374,7 @@ jobs: # ── 4. 性能基线巡检 ──────────────────────────────────────────────── performance-check: name: Performance Baseline Check - runs-on: saas + runs-on: ci-l2 timeout-minutes: 8 outputs: report: ${{ steps.report.outputs.report }} @@ -380,6 +383,9 @@ jobs: - name: Run performance baseline checks id: perf shell: sh + env: + STAGING_TEST_USER: ${{ secrets.STAGING_TEST_USER }} + STAGING_TEST_PASSWORD: ${{ secrets.STAGING_TEST_PASSWORD }} run: | set +e START_TIME=$(date +%s) @@ -415,9 +421,10 @@ jobs: # 先登录获取 token echo "--- 准备: 获取测试 Token ---" + LOGIN_BODY="{\"email\":\"$STAGING_TEST_USER\",\"password\":\"$STAGING_TEST_PASSWORD\"}" AUTH_RESP=$(curl -s -w "\n%{http_code}" -X POST \ -H "Content-Type: application/json" \ - -d '{"email":"18314979086@163.com","password":"Ying1234"}' \ + -d "$LOGIN_BODY" \ "https://staging-api.xiaoxiajianji.com/api/v1/auth/login" \ --max-time 10 2>&1) AUTH_CODE=$(echo "$AUTH_RESP" | tail -1) @@ -447,7 +454,7 @@ jobs: # 构建 curl 命令 CURL_ARGS="-s -o /dev/null -w '%{http_code} %{time_total}' --max-time 30" if [ "$method" = "POST" ]; then - CURL_ARGS="$CURL_ARGS -X POST -H 'Content-Type: application/json' -d '{\"email\":\"18314979086@163.com\",\"password\":\"Ying1234\"}'" + CURL_ARGS="$CURL_ARGS -X POST -H 'Content-Type: application/json' -d \"$LOGIN_BODY\"" fi if [ -n "$TOKEN" ] && [ "$name" != "健康检查" ]; then CURL_ARGS="$CURL_ARGS -H 'Authorization: Bearer $TOKEN'" @@ -495,6 +502,9 @@ jobs: - name: Generate performance report id: report shell: sh + env: + STAGING_TEST_USER: ${{ secrets.STAGING_TEST_USER }} + STAGING_TEST_PASSWORD: ${{ secrets.STAGING_TEST_PASSWORD }} run: | set +e echo "" @@ -509,10 +519,11 @@ jobs: RESULTS="" START_TIME=$(date +%s) + LOGIN_BODY="{\"email\":\"$STAGING_TEST_USER\",\"password\":\"$STAGING_TEST_PASSWORD\"}" # 先登录获取 token AUTH_RESP=$(curl -s -w "\n%{http_code}" -X POST \ -H "Content-Type: application/json" \ - -d '{"email":"18314979086@163.com","password":"Ying1234"}' \ + -d "$LOGIN_BODY" \ "https://staging-api.xiaoxiajianji.com/api/v1/auth/login" \ --max-time 10 2>&1) AUTH_CODE=$(echo "$AUTH_RESP" | tail -1) @@ -528,7 +539,7 @@ jobs: local CURL_ARGS="-s -o /dev/null -w '%{http_code} %{time_total}' --max-time 30" if [ "$method" = "POST" ]; then - CURL_ARGS="$CURL_ARGS -X POST -H 'Content-Type: application/json' -d '{\"email\":\"18314979086@163.com\",\"password\":\"Ying1234\"}'" + CURL_ARGS="$CURL_ARGS -X POST -H 'Content-Type: application/json' -d \"$LOGIN_BODY\"" fi if [ -n "$TOKEN" ] && [ "$name" != "健康检查" ]; then CURL_ARGS="$CURL_ARGS -H 'Authorization: Bearer $TOKEN'" @@ -631,7 +642,7 @@ jobs: # ── 5. 每日巡检汇总报告 ──────────────────────────────────────────── daily-report: name: Daily Check Report - runs-on: saas + runs-on: ci-l2 timeout-minutes: 2 if: always() needs: