From b0dfe93cf132ccc53975e2b1b0ed6eee62acdb46 Mon Sep 17 00:00:00 2001 From: Dillon Stadther Date: Fri, 11 Sep 2026 20:46:56 -0400 Subject: [PATCH 1/3] 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 Claude-Session: https://claude.ai/code/session_01HL1T9zdfnCg1dcTcDfDRSt --- .github/workflows/tests.yml | 30 ++++++++++++++++++++++++++++++ Makefile | 3 +++ 2 files changed, 33 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8304a8f..2e0cfcd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,9 @@ jobs: lint: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write steps: - uses: actions/checkout@v4 @@ -50,6 +53,33 @@ jobs: - name: Quality check with pyscn run: make lint-quality + - name: Generate pyscn report + if: always() + run: make lint-quality-report + + - name: Upload pyscn report + if: always() + uses: actions/upload-artifact@v4 + with: + name: pyscn-report + path: .pyscn/reports/*.html + + - name: Comment pyscn summary on PR + if: >- + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + env: + GH_TOKEN: ${{ github.token }} + run: | + uv run pyscn analyze --json --output - . | jq -r ' + "## pyscn report\n" + + "- **Health Score:** " + (.summary.health_score | tostring) + " / 100 (" + .summary.grade + ")\n" + + "- Complexity: " + (.summary.complexity_score | tostring) + "\n" + + "- Dead code: " + (.summary.dead_code_score | tostring) + "\n" + ' > comment.md + gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md + type-check: runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index f81de20..a3fcf34 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,9 @@ lint-docstrings: lint-quality: uv run pyscn check . +lint-quality-report: + uv run pyscn analyze --no-open --html . + type: uv run pyrefly check From 989eeb4b94a6e33aa72c81d86b285d9e52a682bc Mon Sep 17 00:00:00 2001 From: Dillon Stadther Date: Fri, 11 Sep 2026 20:49:02 -0400 Subject: [PATCH 2/3] feat(ci): split pyscn quality analysis into its own path-filtered workflow Move the pyscn check/report/upload/comment steps out of tests.yml's lint job into a new quality.yml workflow, gated on pull_request/push paths (py files, .pyscn.toml, pyproject.toml) per pyscn's own CI docs example. Keeps the analysis from running on PRs/pushes that touch no Python, without skipping unrelated lint/test/build jobs too. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HL1T9zdfnCg1dcTcDfDRSt --- .github/workflows/quality.yml | 65 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 33 ------------------ 2 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/quality.yml diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..df498bc --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,65 @@ +name: quality + +on: + pull_request: + paths: + - '**/*.py' + - '.pyscn.toml' + - 'pyproject.toml' + push: + branches: + - master + - develop + paths: + - '**/*.py' + - '.pyscn.toml' + - 'pyproject.toml' + +jobs: + pyscn: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + make init-uv + make install + + - name: Quality check with pyscn + run: make lint-quality + + - name: Generate pyscn report + if: always() + run: make lint-quality-report + + - name: Upload pyscn report + if: always() + uses: actions/upload-artifact@v4 + with: + name: pyscn-report + path: .pyscn/reports/*.html + + - name: Comment pyscn summary on PR + if: >- + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + env: + GH_TOKEN: ${{ github.token }} + run: | + uv run pyscn analyze --json --output - . | jq -r ' + "## pyscn report\n" + + "- **Health Score:** " + (.summary.health_score | tostring) + " / 100 (" + .summary.grade + ")\n" + + "- Complexity: " + (.summary.complexity_score | tostring) + "\n" + + "- Dead code: " + (.summary.dead_code_score | tostring) + "\n" + ' > comment.md + gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2e0cfcd..4da3050 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,9 +28,6 @@ jobs: lint: runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write steps: - uses: actions/checkout@v4 @@ -50,36 +47,6 @@ jobs: - name: Lint with Sqlfluff run: make lint-sql - - name: Quality check with pyscn - run: make lint-quality - - - name: Generate pyscn report - if: always() - run: make lint-quality-report - - - name: Upload pyscn report - if: always() - uses: actions/upload-artifact@v4 - with: - name: pyscn-report - path: .pyscn/reports/*.html - - - name: Comment pyscn summary on PR - if: >- - always() && - github.event_name == 'pull_request' && - github.event.pull_request.head.repo.full_name == github.repository - env: - GH_TOKEN: ${{ github.token }} - run: | - uv run pyscn analyze --json --output - . | jq -r ' - "## pyscn report\n" + - "- **Health Score:** " + (.summary.health_score | tostring) + " / 100 (" + .summary.grade + ")\n" + - "- Complexity: " + (.summary.complexity_score | tostring) + "\n" + - "- Dead code: " + (.summary.dead_code_score | tostring) + "\n" - ' > comment.md - gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md - type-check: runs-on: ubuntu-latest steps: From c6f8a74d45bbb188fec98d1cd9f004098a7d89e2 Mon Sep 17 00:00:00 2001 From: Dillon Stadther Date: Fri, 11 Sep 2026 20:54:48 -0400 Subject: [PATCH 3/3] fix(ci): use main as trunk branch in quality workflow push trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit master/develop don't exist in this repo — trunk is main. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HL1T9zdfnCg1dcTcDfDRSt --- .github/workflows/quality.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index df498bc..c76e8ff 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -8,8 +8,7 @@ on: - 'pyproject.toml' push: branches: - - master - - develop + - main paths: - '**/*.py' - '.pyscn.toml'