fix: make main CI green (lint, tests, vscode, react, pip-audit) #46
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Thin PR analysis path (Wave 2/3): | |
| # pip install -e . | |
| # u scan . -o maps/repo_{base,head}.json | |
| # u diff --old ... --new ... -o maps/delta.json --json | |
| # | |
| # Install notes: | |
| # - Default `pip install -e .` is enough for Python AST maps (McCabe) and for | |
| # JS/TS/Go/Rust/C# regex best-effort degrade paths (no extra toolchains). | |
| # - Optional: `pip install -e ".[analyzers]"` adds javalang for Java AST when | |
| # present; without it, Java scans degrade to keyword-heuristic regex. | |
| # - Optional toolchains (Node/Go/Rust/dotnet) unlock JS/Go/Rust/C# AST workers | |
| # when present on the runner; this workflow does not install them, so | |
| # non-Python languages typically stay on regex degrade — that is intentional. | |
| # | |
| # Complexity delta comes from real McCabe scores on Python maps. | |
| # PR comment is fail-soft (permissions); scan/diff are fail-closed. | |
| name: Understand-First PR Analysis | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| pr-map-diff: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR head | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Understand-First | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e . | |
| - name: Scan PR head | |
| run: | | |
| mkdir -p maps | |
| u scan . -o maps/repo_head.json | |
| - name: Scan PR base | |
| run: | | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| git checkout --force "$BASE_SHA" | |
| u scan . -o maps/repo_base.json | |
| git checkout --force "${{ github.sha }}" | |
| - name: Diff base vs head maps | |
| run: | | |
| u diff --old maps/repo_base.json --new maps/repo_head.json -o maps/delta.json --json | |
| - name: Summarize delta | |
| run: | | |
| echo "## Understand-First map delta" >> "$GITHUB_STEP_SUMMARY" | |
| jq -r ' | |
| "### Summary", | |
| "- Added: \(.summary.added // 0)", | |
| "- Removed: \(.summary.removed // 0)", | |
| "- Modified: \(.summary.modified // 0)", | |
| "- Policy breaches: \(.summary.policy_breaches // 0)", | |
| "- Complexity net change: \(.summary.complexity_net_change // .complexity_delta.net_change // 0)", | |
| "- Side-effect tags added (heuristic): \(.summary.side_effects_added // 0)", | |
| "", | |
| "Complexity = McCabe on Python AST maps; JS/TS maps use keyword-heuristic complexity (not McCabe). Side effects = Python AST heuristics when present." | |
| ' maps/delta.json >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload map artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: understand-first-pr-maps | |
| path: | | |
| maps/repo_base.json | |
| maps/repo_head.json | |
| maps/delta.json | |
| retention-days: 14 | |
| - name: Comment delta summary on PR | |
| if: github.event_name == 'pull_request' | |
| continue-on-error: true | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let delta; | |
| try { | |
| delta = JSON.parse(fs.readFileSync('maps/delta.json', 'utf8')); | |
| } catch (e) { | |
| core.warning('delta.json missing; skipping PR comment'); | |
| return; | |
| } | |
| const s = delta.summary || {}; | |
| const cd = delta.complexity_delta || {}; | |
| const net = s.complexity_net_change ?? cd.net_change ?? 0; | |
| const increased = (cd.increased || []).slice(0, 8); | |
| const breachLines = (delta.policy_breaches || []).slice(0, 8).map( | |
| b => `- \`${b.function}\`: ${b.old_complexity} → ${b.new_complexity} (threshold ${b.threshold})` | |
| ); | |
| const body = [ | |
| '## Understand-First PR map delta', | |
| '', | |
| '| Metric | Value |', | |
| '|--------|------:|', | |
| `| Functions added | ${s.added ?? 0} |`, | |
| `| Functions removed | ${s.removed ?? 0} |`, | |
| `| Functions modified | ${s.modified ?? 0} |`, | |
| `| Complexity net change | ${net >= 0 ? '+' : ''}${net} |`, | |
| `| Complexity total (base → head) | ${cd.total_old ?? s.complexity_total_old ?? '?'} → ${cd.total_new ?? s.complexity_total_new ?? '?'} |`, | |
| `| Side-effect tag adds (heuristic) | ${s.side_effects_added ?? 0} |`, | |
| `| Policy breaches | ${s.policy_breaches ?? 0} |`, | |
| '', | |
| increased.length | |
| ? '### Complexity increases\n' + increased.map( | |
| x => `- \`${x.function}\`: ${x.old_complexity} → ${x.new_complexity}` | |
| ).join('\n') | |
| : '### Complexity increases\n_None_', | |
| '', | |
| breachLines.length | |
| ? '### Policy breaches\n' + breachLines.join('\n') | |
| : '', | |
| '', | |
| '_Generated by `u scan` + `u diff --old/--new` (Python AST + JS/TS best-effort when present)._', | |
| '_Complexity: McCabe for Python; keyword-heuristic for JS/TS — mixed totals are not uniform McCabe._', | |
| '_Side effects are Python AST heuristics when present; JS maps typically omit them._', | |
| '_PR comment step is fail-soft; scan/diff above are fail-closed._', | |
| ].filter(Boolean).join('\n'); | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); |