fix: check_ci_status按时间取最新status,修复auto-merge一直等pending的bug
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Failing after 1350h26m51s
CI/CD Pipeline / Deploy Production (push) Failing after 1350h26m53s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1350h26m57s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1350h26m59s
CI/CD Pipeline / Build Production API Image (push) Failing after 1350h26m59s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1350h28m8s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1350h29m19s
CI/CD Pipeline / PR Build API Image (push) Failing after 1350h29m23s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Failing after 1351h1m33s
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped

This commit was merged in pull request #698.
This commit is contained in:
2026-07-22 08:58:00 +08:00
parent 524dbc002a
commit 809339fee3
+15 -13
View File
@@ -31,20 +31,22 @@ def main():
print("pending")
return
# API返回按时间倒序,第一个就是最新的
for s in statuses:
if s.get("context") == target_context:
status = s.get("status", "pending")
# skipped 视为通过(条件跳过的任务不需要等)
if status == "skipped":
print("success")
else:
print(status)
return
# 筛选目标context,按时间倒序取最新的
matching = [s for s in statuses if s.get("context") == target_context]
if not matching:
# 找不到说明CI还没开始写状态,返回pending继续等待
print("pending")
return
# 找不到这个context说明CI还没开始写状态,返回pending继续等待
# (如果workflow真的被跳过,它会有一条status为skipped的记录)
print("pending")
# Gitea statuses API按时间正序返回,必须取最新的一条
latest = max(matching, key=lambda s: s.get("created_at", ""))
status = latest.get("status", "pending")
# skipped 视为通过(条件跳过的任务不需要等)
if status == "skipped":
print("success")
else:
print(status)
if __name__ == "__main__":