From e92e616fd9aacaba37e0063c85b4c3e17f8f45d1 Mon Sep 17 00:00:00 2001 From: codex Date: Mon, 11 May 2026 17:43:05 -0300 Subject: [PATCH] ci: publish LOC source file totals --- scripts/publish_test_metrics.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/publish_test_metrics.py b/scripts/publish_test_metrics.py index 5b565cc..e0d550e 100644 --- a/scripts/publish_test_metrics.py +++ b/scripts/publish_test_metrics.py @@ -136,8 +136,7 @@ def _fetch_existing_counter(pushgateway_url: str, metric: str, labels: dict[str, return 0.0 -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(): @@ -147,9 +146,19 @@ def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int continue if path.suffix not in SOURCE_EXTENSIONS: 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 @@ -247,6 +256,7 @@ def main() -> int: if coverage_path.exists(): coverage = _load_coverage(str(coverage_path)) docs_gate_rc = _load_gate_rc(Path(os.getenv("QUALITY_GATE_DOCS_RC_PATH", str(build_dir / "docs-naming.rc")))) + source_files_total = _count_source_files(repo_root) source_lines_over_500 = _count_source_files_over_limit(repo_root, max_lines=500) totals = {"tests": 0, "failures": 0, "errors": 0, "skipped": 0} test_cases: list[tuple[str, str]] = [] @@ -310,6 +320,8 @@ def main() -> int: f'ariadne_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",