Skip to content

Commit 420c727

Browse files
kenibrewerclaude
andcommitted
šŸ› fix: update coverage report script for modern PyGithub and coverage.json
- Fix deprecated PyGithub authentication to use Auth.Token() - Correct GitHub context access patterns (repository.full_name, event.number) - Update coverage JSON parsing to match pytest-cov output format - Fix coverage file path to use coverage.json instead of non-existent subdirectory šŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 03b4585 commit 420c727

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

ā€Ž.github/workflows/lib/tests/coverage_report.pyā€Ž

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ def main():
3737
return
3838

3939
# Initialize GitHub client
40-
github = Github(github_token)
41-
repo = github.get_repo(f"{github_context['repo']['owner']}/{github_context['repo']['repo']}")
42-
pr_number = github_context['issue']['number']
40+
from github import Auth
41+
auth = Auth.Token(github_token)
42+
github = Github(auth=auth)
43+
repo = github.get_repo(github_context['repository']['full_name'])
44+
pr_number = github_context['event']['number']
4345

4446
# Read coverage summary
45-
coverage_path = '.github/workflows/lib/coverage/coverage-summary.json'
47+
coverage_path = 'coverage.json'
4648

4749
if not os.path.exists(coverage_path):
4850
print('Coverage summary file not found, skipping report')
@@ -51,21 +53,18 @@ def main():
5153
with open(coverage_path, 'r') as f:
5254
coverage = json.load(f)
5355

54-
total = coverage['total']
56+
total = coverage['totals']
5557

5658
# Generate comment
5759
comment = f"""## šŸ“Š Test Coverage Report
5860
5961
| Metric | Coverage | Status |
6062
|--------|----------|---------|
61-
| Statements | {total['statements']['pct']}% | {get_status_emoji(total['statements']['pct'])} |
62-
| Branches | {total['branches']['pct']}% | {get_status_emoji(total['branches']['pct'])} |
63-
| Functions | {total['functions']['pct']}% | {get_status_emoji(total['functions']['pct'])} |
64-
| Lines | {total['lines']['pct']}% | {get_status_emoji(total['lines']['pct'])} |
63+
| Lines | {total['percent_covered_display']}% | {get_status_emoji(float(total['percent_covered_display']))} |
6564
66-
**Tests:** {total['statements']['covered']} statements covered out of {total['statements']['total']}
65+
**Tests:** {total['covered_lines']} lines covered out of {total['num_statements']} statements
6766
68-
{get_coverage_message(total['statements']['pct'])}"""
67+
{get_coverage_message(float(total['percent_covered_display']))}"""
6968

7069
# Find existing coverage comment
7170
comments = list(repo.get_issue(pr_number).get_comments())

0 commit comments

Comments
Ā (0)