fix(ci): 修复自动审批/合并失效——context 列表同步 CI 优化后 job 名 #1594

Closed
xiaoxia wants to merge 4 commits from fix/auto-merge-contexts-v2 into develop
Owner

根因(已实查验证)

CI 优化(2026-08)后 job 名称变更,但自动审批/合并脚本的 context 列表未同步:

脚本里写的旧名(已不存在) 实际新 job 名
Validate - Code Quality Validate - Style + Validate - Security
Validate - Type Check (mypy) Validate - Python (mypy + alembic)
Validate - Migration (alembic) (合并进上一行)

context 匹配是精确字符串匹配,旧名永远查不到 → check_required_contexts 永远返回 pending → 后端 PR 永远不被自动 approve → 自动合并需要 approve → 自动合并链路全链路卡死(脚本 job 显示绿,是因为超时后正常退出,极具迷惑性)。

纯前端 PR 走 CI Gate 门禁不受影响,所以历史上偶有自动合并成功。

修改

  1. scripts/ci/pr_auto_scan.py:REQUIRED_CONTEXTS_APPROVE 同步为新 job 名(merge 门禁用的 CI Gate 名字本来就对,未动)
  2. scripts/ci/auto_approve.sh:CONTEXTS 后端列表同步为新 job 名(与 scan 脚本的 approve 门禁对齐)
  3. .gitea/workflows/pr-auto-scan.yml:cron */10 → */15(develop 版本,随脚本一起入库)

验证

  • 最近 30 个已合并 PR 全部人工合并、无自动 review 记录,与根因吻合
  • #1590 实际 CI 状态实查:新 job 名(Validate - Style/Security/Python)全部真实存在且在跑
  • 脚本 bash/python 语法自检均通过

注意

schedule 触发器实际读取默认分支(main)的 workflow 文件,故 cron 降频对 main 另有一个一行改动的 PR(chore/pr-auto-scan-cron-15min → main)。

## 根因(已实查验证) CI 优化(2026-08)后 job 名称变更,但自动审批/合并脚本的 context 列表未同步: | 脚本里写的旧名(已不存在) | 实际新 job 名 | |---|---| | Validate - Code Quality | Validate - Style + Validate - Security | | Validate - Type Check (mypy) | Validate - Python (mypy + alembic) | | Validate - Migration (alembic) | (合并进上一行) | context 匹配是**精确字符串匹配**,旧名永远查不到 → check_required_contexts 永远返回 pending → 后端 PR 永远不被自动 approve → 自动合并需要 approve → **自动合并链路全链路卡死**(脚本 job 显示绿,是因为超时后正常退出,极具迷惑性)。 纯前端 PR 走 CI Gate 门禁不受影响,所以历史上偶有自动合并成功。 ## 修改 1. `scripts/ci/pr_auto_scan.py`:REQUIRED_CONTEXTS_APPROVE 同步为新 job 名(merge 门禁用的 CI Gate 名字本来就对,未动) 2. `scripts/ci/auto_approve.sh`:CONTEXTS 后端列表同步为新 job 名(与 scan 脚本的 approve 门禁对齐) 3. `.gitea/workflows/pr-auto-scan.yml`:cron */10 → */15(develop 版本,随脚本一起入库) ## 验证 - 最近 30 个已合并 PR 全部人工合并、无自动 review 记录,与根因吻合 - #1590 实际 CI 状态实查:新 job 名(Validate - Style/Security/Python)全部真实存在且在跑 - 脚本 bash/python 语法自检均通过 ## 注意 schedule 触发器实际读取默认分支(main)的 workflow 文件,故 cron 降频对 main 另有一个一行改动的 PR(chore/pr-auto-scan-cron-15min → main)。
xiaoxia added 3 commits 2026-09-01 07:22:59 +08:00
perf(ci): pr-auto-scan 频率 10 分钟降为 15 分钟
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 4m42s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 5m4s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m49s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 4m24s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 5m4s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m19s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
PR Automation / Auto Approve on CI Green (pull_request) Successful in 8m47s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m31s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 5m32s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 7m32s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 16m17s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 3s
74d0bfabd4

🚀 预览环境已部署

项目 详情
PR号 #1594
预览链接 https://pr-1594.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1594 | | 预览链接 | [https://pr-1594.preview.xiaoxiajianji.com](https://pr-1594.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-01 10:22:15 +08:00
ci: trigger CI for context fix verification
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4s
AI Code Review / AI Code Review (pull_request) Successful in 4m41s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m2s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m2s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m8s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m7s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m33s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 3m48s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m42s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m52s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m15s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 1m19s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m47s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 11m11s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 24m15s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
dcf88c8910
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:1 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

  1. [scripts/ci/auto_approve.sh, scripts/ci/pr_auto_scan.py] 自动批准策略变更确认
    • 具体内容:本次修改移除了 Unit TestsFrontend Unit Tests 以及 Build Image 等检查项,仅保留了 StyleSecurityPythonFrontend Lint。这意味着 PR 可能在单元测试未通过或构建失败的情况下被自动批准。请确认这是符合预期的 CI 策略调整(即仅通过代码静态检查即可批准),而非遗漏必要的前置条件。

良好实践

  1. 跨文件一致性auto_approve.shpr_auto_scan.py 中的上下文名称更新保持了高度一致,且通过注释明确指出了两者的对应关系,降低了维护风险。
  2. 注释清晰:代码变更中包含了对变更原因("CI 优化后 job 名称")的详细注释,有助于后续代码审查和维护。
  3. 性能优化:适当降低了定时扫描频率(10分钟 -> 15分钟),在保证扫描及时性的同时有效降低了系统负载。

🤖 由 AI 代码审查机器人自动生成 | 2026-09-01 02:26:59 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:1 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 1. **[scripts/ci/auto_approve.sh, scripts/ci/pr_auto_scan.py] 自动批准策略变更确认** - 具体内容:本次修改移除了 `Unit Tests`、`Frontend Unit Tests` 以及 `Build Image` 等检查项,仅保留了 `Style`、`Security`、`Python` 和 `Frontend Lint`。这意味着 PR 可能在单元测试未通过或构建失败的情况下被自动批准。请确认这是符合预期的 CI 策略调整(即仅通过代码静态检查即可批准),而非遗漏必要的前置条件。 ### ✅ 良好实践 1. **跨文件一致性**:`auto_approve.sh` 与 `pr_auto_scan.py` 中的上下文名称更新保持了高度一致,且通过注释明确指出了两者的对应关系,降低了维护风险。 2. **注释清晰**:代码变更中包含了对变更原因("CI 优化后 job 名称")的详细注释,有助于后续代码审查和维护。 3. **性能优化**:适当降低了定时扫描频率(10分钟 -> 15分钟),在保证扫描及时性的同时有效降低了系统负载。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-09-01 02:26:59 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia closed this pull request 2026-09-01 10:30:45 +08:00

🗑️ 预览环境已清理

PR #1594 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1594 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4s
AI Code Review / AI Code Review (pull_request) Successful in 4m41s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m2s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 7m2s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m8s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m7s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m33s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 3m48s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m42s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m52s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m15s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 1m19s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m47s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 11m11s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 24m15s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.