Files
sokhan/scripts/coverage_summary.py
Abolfazl Ranjbaran 2075db529d feat(site): GitHub Pages landing page, CI coverage summary, dependabot + PR template
- Persian-first RTL landing page in site/ (measured numbers, benchmark
  table, screenshots, quickstart, architecture chain, og-image), pushed
  to production by the new pages.yml workflow on every main push
- CI test job now measures branch coverage over sokhan + sokhan_bot and
  appends a per-file markdown table to the job summary
  (scripts/coverage_summary.py); pytest-cov joins the backend dev extra
- weekly dependabot updates (pip, npm, github-actions, docker) and a PR
  template that repeats the measurement-first checklist
- README: fix stale honest-limits/roadmap claims — streaming decode and
  signed webhooks shipped in v1.3.0, not open items; add Docker badge and
  landing-page link
2026-11-23 06:46:45 +00:00

52 lines
1.4 KiB
Python

"""Render coverage.json as a markdown table for the CI job summary.
CI usage (after ``pytest --cov-report=json:coverage.json``):
python scripts/coverage_summary.py coverage.json >> "$GITHUB_STEP_SUMMARY"
No third-party imports: runs inside the CI job without extra installs.
"""
import json
import sys
def main(path: str) -> None:
with open(path, encoding="utf-8") as fh:
data = json.load(fh)
totals = data["totals"]
print("## Coverage")
print()
print(
f"**{totals['percent_covered']:.1f}%** — "
f"{totals['covered_lines']}/{totals['num_statements']} lines"
+ (
f", {totals['covered_branches']}/{totals['num_branches']} branches"
if totals.get("num_branches")
else ""
)
)
print()
print("| File | Stmts | Miss | Cover |")
print("| --- | ---: | ---: | ---: |")
files = data["files"]
for path_, info in sorted(files.items()):
s = info["summary"]
print(
f"| `{path_}` | {s['num_statements']} | {s['missing_lines']} "
f"| {s['percent_covered']:.1f}% |"
)
print()
print("*Measured with branch coverage (`--cov-branch`) over "
"`sokhan` and `sokhan_bot` on the non-GPU test suite.*")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("usage: coverage_summary.py <coverage.json>", file=sys.stderr)
raise SystemExit(2)
main(sys.argv[1])