ci: publish LOC source file totals
This commit is contained in:
parent
a343452233
commit
f4801537ec
@ -152,10 +152,7 @@ def _series_exists(pushgateway_url: str, metric: str, labels: dict[str, str]) ->
|
||||
return False
|
||||
|
||||
|
||||
def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int:
|
||||
"""Count source files above the configured line budget."""
|
||||
|
||||
count = 0
|
||||
def _iter_source_files(repo_root: Path):
|
||||
for rel_root in ("cmd", "pkg", "scripts", "testing"):
|
||||
base = repo_root / rel_root
|
||||
if not base.exists():
|
||||
@ -165,9 +162,23 @@ def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int
|
||||
continue
|
||||
if path.suffix not in {".go", ".py", ".sh"}:
|
||||
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:
|
||||
"""Count source files covered by the line budget."""
|
||||
|
||||
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 source files above the configured line budget."""
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -240,6 +251,7 @@ def main() -> int:
|
||||
test_cases = _load_junit_cases(junit_path)
|
||||
test_exit_code = _load_exit_code(test_exit_code_path)
|
||||
docs_exit_code = _load_exit_code(docs_exit_code_path)
|
||||
source_files_total = _count_source_files(repo_root)
|
||||
source_lines_over_500 = _count_source_files_over_limit(repo_root, max_lines=500)
|
||||
passed = max(totals["tests"] - totals["failures"] - totals["errors"] - totals["skipped"], 0)
|
||||
|
||||
@ -320,6 +332,8 @@ def main() -> int:
|
||||
f'metis_quality_gate_coverage_percent{{suite="{suite}"}} {coverage:.3f}',
|
||||
"# TYPE platform_quality_gate_workspace_line_coverage_percent gauge",
|
||||
f'platform_quality_gate_workspace_line_coverage_percent{{suite="{suite}"}} {coverage:.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 platform_quality_gate_build_info gauge",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user