ci: publish LOC source file totals
This commit is contained in:
parent
d44af59fed
commit
e92e616fd9
@ -136,8 +136,7 @@ def _fetch_existing_counter(pushgateway_url: str, metric: str, labels: dict[str,
|
|||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int:
|
def _iter_source_files(repo_root: Path):
|
||||||
count = 0
|
|
||||||
for rel_root in SOURCE_SCAN_ROOTS:
|
for rel_root in SOURCE_SCAN_ROOTS:
|
||||||
base = repo_root / rel_root
|
base = repo_root / rel_root
|
||||||
if not base.exists():
|
if not base.exists():
|
||||||
@ -147,9 +146,19 @@ def _count_source_files_over_limit(repo_root: Path, max_lines: int = 500) -> int
|
|||||||
continue
|
continue
|
||||||
if path.suffix not in SOURCE_EXTENSIONS:
|
if path.suffix not in SOURCE_EXTENSIONS:
|
||||||
continue
|
continue
|
||||||
lines = len(path.read_text(encoding="utf-8", errors="ignore").splitlines())
|
yield path
|
||||||
if lines > max_lines:
|
|
||||||
count += 1
|
|
||||||
|
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
|
return count
|
||||||
|
|
||||||
|
|
||||||
@ -247,6 +256,7 @@ def main() -> int:
|
|||||||
if coverage_path.exists():
|
if coverage_path.exists():
|
||||||
coverage = _load_coverage(str(coverage_path))
|
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"))))
|
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)
|
source_lines_over_500 = _count_source_files_over_limit(repo_root, max_lines=500)
|
||||||
totals = {"tests": 0, "failures": 0, "errors": 0, "skipped": 0}
|
totals = {"tests": 0, "failures": 0, "errors": 0, "skipped": 0}
|
||||||
test_cases: list[tuple[str, str]] = []
|
test_cases: list[tuple[str, str]] = []
|
||||||
@ -310,6 +320,8 @@ def main() -> int:
|
|||||||
f'ariadne_quality_gate_coverage_percent{{suite="{suite}"}} {coverage:.3f}',
|
f'ariadne_quality_gate_coverage_percent{{suite="{suite}"}} {coverage:.3f}',
|
||||||
"# TYPE platform_quality_gate_workspace_line_coverage_percent gauge",
|
"# TYPE platform_quality_gate_workspace_line_coverage_percent gauge",
|
||||||
f'platform_quality_gate_workspace_line_coverage_percent{{suite="{suite}"}} {coverage:.3f}',
|
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",
|
"# 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}',
|
f'platform_quality_gate_source_lines_over_500_total{{suite="{suite}"}} {source_lines_over_500}',
|
||||||
"# TYPE platform_quality_gate_build_info gauge",
|
"# TYPE platform_quality_gate_build_info gauge",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user