4a38216fb0
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 16s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 56s
AI Code Review / AI Code Review (pull_request) Successful in 2m30s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 3m9s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m18s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 3m40s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m29s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 5m0s
- check_ci_status.py: 找不到context时返回pending而非success (找不到=CI还没启动,应该等待;真跳过的会有skipped状态) - auto-merge.yml: 405时不立即退出,改为重试多轮后才放弃 (405可能是CI状态同步延迟,不是真的合并失败) - auto-merge.yml + auto-approve.yml: 增加30秒初始等待 (避免tar.gz checkout太快,CI还没写第一个status就检查)
52 lines
1.4 KiB
Python
Executable File
52 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""检查指定commit的CI status状态。
|
|
|
|
用法: python3 check_ci_status.py <token> <repo> <sha> <context>
|
|
返回: 打印状态 (success/failure/pending/error)
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) != 5:
|
|
print("pending")
|
|
return
|
|
|
|
token = sys.argv[1]
|
|
repo = sys.argv[2]
|
|
sha = sys.argv[3]
|
|
target_context = sys.argv[4]
|
|
|
|
api_url = f"https://git.xiaoxiajianji.com/api/v1/repos/{repo}/commits/{sha}/statuses?per_page=100"
|
|
req = urllib.request.Request(api_url, headers={"Authorization": f"token {token}"})
|
|
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
statuses = json.loads(resp.read().decode())
|
|
except Exception:
|
|
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说明CI还没开始写状态,返回pending继续等待
|
|
# (如果workflow真的被跳过,它会有一条status为skipped的记录)
|
|
print("pending")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|