ci: publish LOC source file totals
This commit is contained in:
parent
7a49ac2753
commit
e62480ddb4
5
Jenkinsfile
vendored
5
Jenkinsfile
vendored
@ -244,6 +244,7 @@ PY
|
||||
tests_passed=0
|
||||
fi
|
||||
coverage_percent="$(jq -r '.coverage_percent // 0' build/quality-summary.json 2>/dev/null || echo 0)"
|
||||
source_files_total="$(jq -r '.source_files_total // 0' build/quality-summary.json 2>/dev/null || echo 0)"
|
||||
over_500="$(jq -r '.source_lines_over_500 // 0' build/quality-summary.json 2>/dev/null || echo 0)"
|
||||
cat > build/test-summary.json <<EOF
|
||||
{
|
||||
@ -253,6 +254,7 @@ PY
|
||||
"errors": ${tests_errors},
|
||||
"skipped": ${tests_skipped},
|
||||
"coverage_percent": ${coverage_percent},
|
||||
"source_files_total": ${source_files_total},
|
||||
"source_lines_over_500": ${over_500}
|
||||
}
|
||||
EOF
|
||||
@ -299,6 +301,7 @@ EOF
|
||||
tests_errors="$(jq -r '.errors // 0' build/test-summary.json 2>/dev/null || echo 0)"
|
||||
tests_skipped="$(jq -r '.skipped // 0' build/test-summary.json 2>/dev/null || echo 0)"
|
||||
coverage_percent="$(jq -r '.coverage_percent // 0' build/test-summary.json 2>/dev/null || echo 0)"
|
||||
source_files_total="$(jq -r '.source_files_total // 0' build/test-summary.json 2>/dev/null || echo 0)"
|
||||
over_500="$(jq -r '.source_lines_over_500 // 0' build/test-summary.json 2>/dev/null || echo 0)"
|
||||
metric_branch_raw="${BRANCH_NAME:-${GIT_BRANCH:-unknown}}"
|
||||
metric_branch_raw="${metric_branch_raw#origin/}"
|
||||
@ -376,6 +379,8 @@ soteria_quality_gate_tests_total{suite="${suite}",result="skipped"} ${tests_skip
|
||||
soteria_quality_gate_coverage_percent{suite="${suite}"} ${coverage_percent}
|
||||
# TYPE platform_quality_gate_workspace_line_coverage_percent gauge
|
||||
platform_quality_gate_workspace_line_coverage_percent{suite="${suite}"} ${coverage_percent}
|
||||
# TYPE platform_quality_gate_source_files_total gauge
|
||||
platform_quality_gate_source_files_total{suite="${suite}"} ${source_files_total}
|
||||
# TYPE platform_quality_gate_source_lines_over_500_total gauge
|
||||
platform_quality_gate_source_lines_over_500_total{suite="${suite}"} ${over_500}
|
||||
# TYPE platform_quality_gate_build_info gauge
|
||||
|
||||
@ -84,10 +84,12 @@ from pathlib import Path
|
||||
build = Path("build")
|
||||
loc_path = build / "loc-summary.json"
|
||||
cov_path = build / "coverage-summary.json"
|
||||
summary = {"coverage_percent": 0.0, "source_lines_over_500": 0}
|
||||
summary = {"coverage_percent": 0.0, "source_files_total": 0, "source_lines_over_500": 0}
|
||||
if loc_path.exists():
|
||||
try:
|
||||
summary["source_lines_over_500"] = int(json.loads(loc_path.read_text()).get("over_500", 0))
|
||||
loc = json.loads(loc_path.read_text())
|
||||
summary["source_files_total"] = int(loc.get("source_files_total", 0))
|
||||
summary["source_lines_over_500"] = int(loc.get("over_500", 0))
|
||||
except Exception:
|
||||
pass
|
||||
if cov_path.exists():
|
||||
|
||||
@ -70,7 +70,9 @@ def main() -> int:
|
||||
violations: list[str] = []
|
||||
over_500 = 0
|
||||
|
||||
for path in iter_source_files(root):
|
||||
source_files = iter_source_files(root)
|
||||
|
||||
for path in source_files:
|
||||
rel = path.relative_to(root).as_posix()
|
||||
line_count = len(path.read_text(encoding="utf-8", errors="ignore").splitlines())
|
||||
if line_count > 500:
|
||||
@ -79,7 +81,7 @@ def main() -> int:
|
||||
if line_count > limit:
|
||||
violations.append(f"{rel}: {line_count} lines (limit {limit})")
|
||||
|
||||
summary = {"over_500": over_500, "violations": len(violations)}
|
||||
summary = {"source_files_total": len(source_files), "over_500": over_500, "violations": len(violations)}
|
||||
if args.summary_json:
|
||||
Path(args.summary_json).write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user