sync: 同步develop上新增的ci脚本文件(缺失导致CI失败)
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 34s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1584h15m28s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1584h15m29s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1584h15m29s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1584h15m30s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1584h15m31s
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1584h47m4s

This commit is contained in:
2026-07-12 15:08:23 +08:00
committed by xiaoxia
parent cd43c3239c
commit 3c47a5cc35
4 changed files with 558 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
"""解析 coverage.xml 并输出覆盖率汇总。"""
import os
import sys
import xml.etree.ElementTree as ET
THRESHOLD = int(os.environ.get("COVERAGE_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())