| name | run2_report-builder |
| description | How to assemble and write a structured JSON report for GitHub community pulse statistics with validation. |
GitHub Community Pulse Report Builder
Report Schema
{
"pr": {
"total": <int>,
"merged": <int>,
"closed": <int>,
"avg_merge_days": <float>,
"top_contributor": <str>
},
"issue": {
"total": <int>,
"bug": <int>,
"resolved_bugs": <int>
}
}
Validation Checks
def validate_report(report, prs, issues):
pr = report["pr"]
iss = report["issue"]
assert pr["merged"] + pr["closed"] <= pr["total"], "merged+closed exceeds total"
assert iss["bug"] <= iss["total"], "bug > total issues"
assert iss["resolved_bugs"] <= iss["bug"], "resolved_bugs > bug"
assert pr["avg_merge_days"] >= 0, "negative avg_merge_days"
Writing the Report
import json
def write_report(path, report):
with open(path, "w") as f:
json.dump(report, f, indent=2)
print(f"Report written to {path}")
print(json.dumps(report, indent=2))
Full Assembly
report = {
"pr": {
"total": len(prs),
"merged": len(merged_prs),
"closed": len(closed_prs),
"avg_merge_days": compute_avg_merge_days(merged_prs),
"top_contributor": get_top_contributor(prs)
},
"issue": {
"total": len(issues),
"bug": len(bug_issues),
"resolved_bugs": len(resolved_bugs)
}
}
validate_report(report, prs, issues)
write_report("/app/report.json", report)