Skip to content

Commit b0dfe93

Browse files
dlstadtherclaude
andcommitted
feat(ci): persist pyscn analyze report and post PR comment
Add pyscn analyze --html report generation + upload-artifact so full reports survive past the job. On pull_request runs (same-repo only, so forked-PR tokens don't hit a permissions error), pipe the JSON report through jq into a PR comment via gh. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HL1T9zdfnCg1dcTcDfDRSt
1 parent ef54ca2 commit b0dfe93

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828

2929
lint:
3030
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
pull-requests: write
3134
steps:
3235
- uses: actions/checkout@v4
3336

@@ -50,6 +53,33 @@ jobs:
5053
- name: Quality check with pyscn
5154
run: make lint-quality
5255

56+
- name: Generate pyscn report
57+
if: always()
58+
run: make lint-quality-report
59+
60+
- name: Upload pyscn report
61+
if: always()
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: pyscn-report
65+
path: .pyscn/reports/*.html
66+
67+
- name: Comment pyscn summary on PR
68+
if: >-
69+
always() &&
70+
github.event_name == 'pull_request' &&
71+
github.event.pull_request.head.repo.full_name == github.repository
72+
env:
73+
GH_TOKEN: ${{ github.token }}
74+
run: |
75+
uv run pyscn analyze --json --output - . | jq -r '
76+
"## pyscn report\n" +
77+
"- **Health Score:** " + (.summary.health_score | tostring) + " / 100 (" + .summary.grade + ")\n" +
78+
"- Complexity: " + (.summary.complexity_score | tostring) + "\n" +
79+
"- Dead code: " + (.summary.dead_code_score | tostring) + "\n"
80+
' > comment.md
81+
gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md
82+
5383
type-check:
5484
runs-on: ubuntu-latest
5585
steps:

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ lint-docstrings:
5353
lint-quality:
5454
uv run pyscn check .
5555

56+
lint-quality-report:
57+
uv run pyscn analyze --no-open --html .
58+
5659
type:
5760
uv run pyrefly check
5861

0 commit comments

Comments
 (0)