diff --git a/.gitea/workflows/auto-approve.yml b/.gitea/workflows/auto-approve.yml index 96d14a076..401d18b45 100644 --- a/.gitea/workflows/auto-approve.yml +++ b/.gitea/workflows/auto-approve.yml @@ -7,7 +7,7 @@ on: jobs: auto-approve: name: Auto Approve on CI Green - runs-on: ci-l1 + runs-on: ci-check if: github.event_name == 'pull_request' && !github.event.pull_request.draft timeout-minutes: 20 steps: @@ -20,6 +20,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} REVIEW_TOKEN: ${{ secrets.REVIEW_GITEA_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | set -eu @@ -67,7 +68,7 @@ jobs: # 调用辅助脚本检查每个context状态 for ctx in "${CONTEXTS[@]}"; do - STATE=$(python3 scripts/check_ci_status.py "$GITHUB_TOKEN" "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$ctx") + STATE=$(python3 scripts/check_ci_status.py "$GITHUB_TOKEN" "$GITHUB_REPOSITORY" "$PR_HEAD_SHA" "$ctx") echo " $ctx: $STATE" if [ "$STATE" != "success" ]; then diff --git a/.gitea/workflows/auto-merge.yml b/.gitea/workflows/auto-merge.yml index bc0db30ee..d1998dec6 100644 --- a/.gitea/workflows/auto-merge.yml +++ b/.gitea/workflows/auto-merge.yml @@ -7,7 +7,7 @@ on: jobs: auto-merge: name: Auto Merge on CI Green + Approved - runs-on: ci-l1 + runs-on: ci-check if: github.event_name == 'pull_request' && !github.event.pull_request.draft && github.event.pull_request.base.ref == 'develop' timeout-minutes: 30 steps: @@ -20,6 +20,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} MERGE_TOKEN: ${{ secrets.REVIEW_GITEA_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} BASE_REF: ${{ github.event.pull_request.base.ref }} run: | set -eu @@ -65,7 +66,7 @@ jobs: # 检查CI状态 for ctx in "${CONTEXTS[@]}"; do - STATE=$(python3 scripts/check_ci_status.py "$GITHUB_TOKEN" "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$ctx") + STATE=$(python3 scripts/check_ci_status.py "$GITHUB_TOKEN" "$GITHUB_REPOSITORY" "$PR_HEAD_SHA" "$ctx") echo " CI: ${ctx##*/}: $STATE" if [ "$STATE" != "success" ]; then ALL_SUCCESS=false diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index b7ea51473..1301229f8 100755 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -24,7 +24,7 @@ concurrency: jobs: check-frontend-only: name: Check if frontend-only change - runs-on: ci-l1 + runs-on: ci-check if: github.event_name == 'pull_request' outputs: skip_backend: ${{ steps.check.outputs.skip_backend }} @@ -60,7 +60,7 @@ jobs: needs: check-frontend-only if: always() && needs.check-frontend-only.outputs.skip_backend != 'true' name: Validate Code Quality And Tests - runs-on: ci-l1 + runs-on: ci-check timeout-minutes: 10 env: DATABASE_URL: postgresql+psycopg://postgres:postgres@127.0.0.1:5432/xiaoxia_saas @@ -412,7 +412,7 @@ jobs: ' frontend-lint: name: Frontend Lint - runs-on: ci-l1 + runs-on: ci-check timeout-minutes: 10 steps: - name: Checkout code @@ -459,4 +459,4 @@ jobs: NOTIFY_MODE=failure JOB_NAME="Frontend Lint" python3 scripts/ci_notify.py - ' \ No newline at end of file + ' diff --git a/scripts/check_ci_status.py b/scripts/check_ci_status.py index cc159f9eb..13b82ede0 100644 --- a/scripts/check_ci_status.py +++ b/scripts/check_ci_status.py @@ -34,10 +34,16 @@ def main(): # API返回按时间倒序,第一个就是最新的 for s in statuses: if s.get("context") == target_context: - print(s.get("status", "pending")) + status = s.get("status", "pending") + # skipped 视为通过(条件跳过的任务不需要等) + if status == "skipped": + print("success") + else: + print(status) return - print("pending") + # 找不到这个context也视为通过(该workflow没触发=不需要检查) + print("success") if __name__ == "__main__":