ci: publish LOC source file totals

This commit is contained in:
codex 2026-05-11 17:39:53 -03:00
parent 13bf0a64dd
commit c7a6410837

View File

@ -187,8 +187,7 @@ def _post_text(url: str, payload: str) -> None:
raise RuntimeError(f"push failed status={resp.status}")
def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int:
count = 0
def _iter_source_files(repo_root: Path):
for rel_root in SOURCE_SCAN_ROOTS:
base = repo_root / rel_root
if not base.exists():
@ -200,9 +199,19 @@ def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int
continue
if path.name.endswith("_test.go") or path.name.endswith(".test.ts") or path.name.endswith(".test.tsx"):
continue
lines = len(path.read_text(encoding="utf-8", errors="ignore").splitlines())
if lines > max_lines:
count += 1
yield path
def _count_source_files(repo_root: Path) -> int:
return sum(1 for _ in _iter_source_files(repo_root))
def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int:
count = 0
for path in _iter_source_files(repo_root):
lines = len(path.read_text(encoding="utf-8", errors="ignore").splitlines())
if lines > max_lines:
count += 1
return count
@ -306,6 +315,7 @@ def main() -> int:
}
gate_ok = bool(gate_summary.get("ok"))
gate_issues = gate_summary.get("issues") or []
source_files_total = _count_source_files(repo_root)
source_lines_over_500 = _count_source_files_over_limit(repo_root, max_lines=500)
issue_checks = {
str(issue.get("check") or "").strip().lower()
@ -363,6 +373,8 @@ def main() -> int:
f'pegasus_quality_gate_coverage_percent{{suite="{suite}"}} {coverage_pct:.3f}',
"# TYPE platform_quality_gate_workspace_line_coverage_percent gauge",
f'platform_quality_gate_workspace_line_coverage_percent{{suite="{suite}"}} {coverage_pct:.3f}',
"# TYPE platform_quality_gate_source_files_total gauge",
f'platform_quality_gate_source_files_total{{suite="{suite}"}} {source_files_total}',
"# TYPE platform_quality_gate_source_lines_over_500_total gauge",
f'platform_quality_gate_source_lines_over_500_total{{suite="{suite}"}} {source_lines_over_500}',
"# TYPE pegasus_quality_gate_status gauge",