mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
Add AI engine coverage reporting to CI (run tests with coverage, show in step summary, and upload artifact). Relax and align engine pre-commit package specifiers and update uv.lock. Increase ruff line-length and add per-file ignores; update Taskfile and pre-commit Taskfile to use engine ruff config. Add coverage entries to engine/.gitignore. Apply numerous non-functional Python style and formatting fixes across scripts and cucumber test steps (imports, f-strings, line breaks, noqa markers, single-line asserts) to satisfy linters—no behavioral changes intended.
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""Fail when any measured source file falls below the required coverage."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("report", type=Path)
|
|
parser.add_argument("--minimum", type=float, default=90.0)
|
|
args = parser.parse_args()
|
|
|
|
data = json.loads(args.report.read_text(encoding="utf-8"))
|
|
failures: list[tuple[str, float]] = []
|
|
for filename, details in data["files"].items():
|
|
coverage = float(details["summary"]["percent_covered"])
|
|
if coverage < args.minimum:
|
|
failures.append((filename, coverage))
|
|
|
|
if failures:
|
|
print(f"Per-file coverage below {args.minimum:.1f}%:", file=sys.stderr)
|
|
for filename, coverage in sorted(failures):
|
|
print(f" {coverage:.1f}% {filename}", file=sys.stderr)
|
|
return 1
|
|
|
|
print(f"Per-file coverage: every file is at least {args.minimum:.1f}%.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|