From 4bd3da73e386d8d7ef675139f8d68d6f8da79c5b Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 30 Jul 2026 00:41:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20pr=5Fauto=5Fscan=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B4=A9=E6=BA=83bug=20+=20=E7=BB=9F=E4=B8=80merge=E9=97=A8?= =?UTF-8?q?=E7=A6=81=E4=B8=BACI=20Gate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api_request: 修复HTTPError空响应体导致JSON解析崩溃 - REQUIRED_CONTEXTS_FULL: 改为只检查CI Gate,与pr-automation/分支保护保持一致 - FRONTEND_ONLY_CONTEXT: 改为CI Gate,内部自动处理跳过逻辑 --- scripts/ci/pr_auto_scan.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/ci/pr_auto_scan.py b/scripts/ci/pr_auto_scan.py index cfe6db8ef..6bef46da2 100644 --- a/scripts/ci/pr_auto_scan.py +++ b/scripts/ci/pr_auto_scan.py @@ -32,7 +32,13 @@ def api_request(token, repo, endpoint, method="GET", data=None): resp = urllib.request.urlopen(req, context=ctx) return json.loads(resp.read().decode()), resp.status except urllib.error.HTTPError as e: - return json.loads(e.read().decode()) if e.read() else {"error": str(e)}, e.code + body = e.read().decode() + if body: + try: + return json.loads(body), e.code + except json.JSONDecodeError: + return {"error": body}, e.code + return {"error": str(e)}, e.code def get_open_prs(token, repo, base="develop"): @@ -269,13 +275,9 @@ def main(): # required contexts(与分支保护一致) REQUIRED_CONTEXTS_FULL = [ - "CI/CD Pipeline / Validate - Code Quality (pull_request)", - "CI/CD Pipeline / Validate - Type Check (mypy) (pull_request)", - "CI/CD Pipeline / Validate - Migration (alembic) (pull_request)", - "CI/CD Pipeline / Frontend Lint (pull_request)", - "CI/CD Pipeline / PR Build API Image (pull_request)", - "CI/CD Pipeline / PR Build Worker Image (pull_request)", - "CI/CD Pipeline / PR Build Web Image (pull_request)", + # 统一使用CI Gate作为合并门禁(与pr-automation和分支保护保持一致) + # CI Gate内部已包含: 代码质量/类型检查/迁移检查/单测/集成测试/前端Lint/前端单测/构建/AI审查 + "CI/CD Pipeline / CI Gate (pull_request)", ] REQUIRED_CONTEXTS_APPROVE = [ "CI/CD Pipeline / Validate - Code Quality (pull_request)", @@ -284,7 +286,8 @@ def main(): "CI/CD Pipeline / Frontend Lint (pull_request)", ] FRONTEND_ONLY_CONTEXT = [ - "CI/CD Pipeline / Frontend Lint (pull_request)", + # 纯前端PR也用CI Gate统一判断,内部自动跳过后端相关检查 + "CI/CD Pipeline / CI Gate (pull_request)", ] # 获取所有open PR