Compare commits

...

2 Commits

Author SHA1 Message Date
CI Bot 5a6491687f style: auto-format with black + isort + prettier [skip ci-format-check]
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 26s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 24s
2026-09-03 07:55:14 +00:00
xiaoxia ffd02a3ec8 fix(ci): 修复自动合并竞态问题
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 16s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Failing after 27s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 54s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 38s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m16s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m5s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m17s
AI Code Review / AI Code Review (pull_request) Successful in 5m51s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 5m37s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 7m21s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m58s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 57s
CI/CD Pipeline / CI Gate (pull_request) Failing after 18s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 311h27m51s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 311h27m57s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 311h27m58s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 311h28m55s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 311h28m55s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 311h28m57s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 311h36m28s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 311h36m47s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 311h36m48s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 311h36m55s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 311h36m35s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 311h36m55s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 311h36m35s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 311h36m56s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 312h11m8s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 312h11m14s
问题:auto-merge job 和 auto-approve job 并行执行,auto-merge
在审批完成前就检查审批状态,发现无审批后直接退出。等审批完成时
merge job 已结束,无人再触发合并,PR 卡住无法自动合并。

实核:PR #1602 CI 全绿 + 已审批,但 PR 至今未合并。
auto-merge 在 6m43s 退出,auto-approve 在 8m8s 才完成。

修复:
1. pr-automation.yml: auto-merge 添加 needs: [auto-approve],
   确保审批完成后再尝试合并
2. pr-automation.yml: auto-approve timeout 从 3min 增至 10min,
   auto-merge timeout 从 3min 增至 15min
3. auto_merge.sh: 将单次检查改为轮询模式(30s初始等待 + 60次×10s
   轮询 = 最多10分钟),CI pending 时 return 1 继续重试而非 exit 0
   直接退出
2026-09-03 15:47:44 +08:00
3 changed files with 30 additions and 14 deletions
+3 -2
View File
@@ -18,7 +18,7 @@ jobs:
name: Auto Approve on CI Green
runs-on: ci-check
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
timeout-minutes: 3 # 长等待模式:等CI全绿后自动合并,不遗漏任何PR
timeout-minutes: 10 # 等待CI全绿+审批,需要充足时间
steps:
- name: Checkout code
shell: sh
@@ -61,7 +61,8 @@ jobs:
name: Auto Merge on CI Green + Approved
runs-on: ci-check
if: github.event_name == 'pull_request' && !github.event.pull_request.draft && github.event.pull_request.base.ref == 'develop'
timeout-minutes: 3 # 短作业模式:检查一次,不满足就退出,由pr-auto-scan每5分钟定时兜底
needs: [auto-approve] # 修复竞态:必须等审批完成后再尝试合并
timeout-minutes: 15 # 等待审批+CI就绪+合并,需要充足时间
steps:
- name: Checkout code
shell: sh
+24 -9
View File
@@ -32,9 +32,9 @@ CONTEXTS=(
echo "检查CI Gate统一门禁"
echo
# 等待60秒,给CI启动写status的时间
echo "等待60秒让CI启动..."
sleep 60
# 等待30秒后开始轮询,最多10分钟
echo "等待30秒让CI启动..."
sleep 30
# 405计数器(单次运行内重试)
MERGE_405_COUNT=0
@@ -72,9 +72,9 @@ check_and_merge() {
# CI未全绿(pending中)→ 退出,等下次触发
if [ "$ALL_SUCCESS" != "true" ]; then
echo
echo "⏳ CI尚未全绿(仍有pending),退出等待下次触发"
echo " (pr-auto-scan每5分钟扫描一次,CI通过后会自动合并)"
exit 0
echo "⏳ CI尚未全绿(仍有pending),等待重试..."
echo " (当前第${attempt}次轮询,最多${MAX_ATTEMPTS}次)"
return 1
fi
# CI全绿 → 合并
@@ -136,13 +136,28 @@ check_and_merge() {
fi
}
# 最多重试3次(用于405重试,非CI轮询)
for i in 1 2 3; do
# 轮询等待CI就绪+审批完成,最多10分钟(60次x10秒)
MAX_ATTEMPTS=60
for attempt in $(seq 1 $MAX_ATTEMPTS); do
if check_and_merge; then
exit 0
fi
# 检查PR是否还open(可能已被手动合并或关闭)
PR_STATE=$(curl -s -H "Authorization: token ${MERGE_TOKEN}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \
| python3 -c "import sys,json; print(json.load(sys.stdin).get('state',''))" 2>/dev/null || echo "?")
if [ "$PR_STATE" != "open" ]; then
echo "PR状态为 ${PR_STATE},无需继续等待"
exit 0
fi
if [ $attempt -lt $MAX_ATTEMPTS ]; then
sleep 10
fi
done
echo
echo "本次检查未满足合并条件,退出。pr-auto-scan每5分钟会继续扫描。"
echo "⏰ 等待10分钟后仍未满足合并条件,退出。pr-auto-scan定时扫描会继续重试。"
exit 0
+3 -3
View File
@@ -707,9 +707,9 @@ class TestStrayLoggerRemoved:
source = inspect.getsource(generation_cover)
# The stray call was logger.info(\n plan_id,\n generation_task_id,\n)
# with no format string — should not exist
assert "logger.info(\n plan_id," not in source, (
"Stray logger.info(plan_id, generation_task_id) should be removed"
)
assert (
"logger.info(\n plan_id," not in source
), "Stray logger.info(plan_id, generation_task_id) should be removed"
class TestUploadCoverType: