d8d1674ff0
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 2m21s
CI/CD Pipeline / Frontend Lint (push) Successful in 3m5s
CI/CD Pipeline / Build Production Runtime Images (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Successful in 2m29s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (push) Failing after 30m0s
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
ci: 集成测试拆分为独立job + runner标签适配 + 清理废workflow - 集成测试从Validate中拆出为独立job,PR页面可见独立status - runner标签从ubuntu-22.04适配为host - 清理3个废workflow(tests.yml、test-ssh-secret.yml、auto-merge.yml) - 修复Verify步骤python命令为python3 - Validate单元测试只统计API层覆盖率,排除worker代码 - 集成测试覆盖率门槛降至40%,覆盖率汇总脚本支持环境变量 - Integration Tests加Redis容器(host模式无预装Redis)
35 lines
1.0 KiB
Python
Executable File
35 lines
1.0 KiB
Python
Executable File
#!/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())
|