fix(ci): 修复ci-cd.yml的YAML语法错误,将Python覆盖率汇总和失败通知抽到独立脚本
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 10s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1604h45m40s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1604h45m42s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1604h45m47s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1604h45m42s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1604h45m47s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1605h17m16s

This commit is contained in:
用户CI Test
2026-07-11 18:42:53 +08:00
parent db229bcc23
commit 8ed0ea21fe
3 changed files with 117 additions and 88 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""解析 coverage.xml 并输出覆盖率汇总。"""
import sys
import xml.etree.ElementTree as ET
THRESHOLD = 65 # 行覆盖率门槛,百分比
def main() -> int:
try:
tree = ET.parse("coverage.xml")
except FileNotFoundError:
print("coverage.xml 不存在,跳过汇总")
return 0
root = tree.getroot()
line_rate = float(root.get("line-rate", 0)) * 100
branch_rate = float(root.get("branch-rate", 0)) * 100
lines_covered = int(root.get("lines-covered", 0))
lines_valid = int(root.get("lines-valid", 0))
print(f"行覆盖率: {line_rate:.2f}% ({lines_covered}/{lines_valid})")
print(f"分支覆盖率: {branch_rate:.2f}%")
print(f"门槛: {THRESHOLD}%")
status = "PASS ✅" if line_rate >= THRESHOLD else "FAIL ❌"
print(f"状态: {status}")
return 0 if line_rate >= THRESHOLD else 1
if __name__ == "__main__":
sys.exit(main())