-
Notifications
You must be signed in to change notification settings - Fork 12
feat(review-pr): add exclude-paths input to skip generated files from review #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eadbd00
300ac1c
80545fa
d8b3ea2
3701812
690ad4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,10 @@ inputs: | |
| description: "Skip the built-in authorization check (caller already verified auth)" | ||
| required: false | ||
| default: "false" | ||
| exclude-paths: | ||
| description: 'Newline-separated list of path prefixes to strip from the diff before chunking. Files matching these prefixes are excluded from review entirely.' | ||
| required: false | ||
| default: '' | ||
|
|
||
| outputs: | ||
| exit-code: | ||
|
|
@@ -233,6 +237,14 @@ runs: | |
| fi | ||
| fi | ||
|
|
||
| - name: Filter excluded paths from diff | ||
| if: hashFiles('pr.diff') != '' && inputs.exclude-paths != '' | ||
| shell: bash | ||
| env: | ||
| EXCLUDE_PATHS: ${{ inputs.exclude-paths }} | ||
| run: | | ||
| node "$ACTION_PATH/dist/filter-diff.js" pr.diff "$EXCLUDE_PATHS" | ||
|
|
||
| - name: Split diff into chunks | ||
| if: hashFiles('pr.diff') != '' | ||
| id: chunk-diff | ||
|
|
@@ -307,63 +319,11 @@ runs: | |
| - name: Score file risk | ||
| if: hashFiles('pr.diff') != '' | ||
| shell: bash | ||
| env: | ||
| EXCLUDE_PATHS: ${{ inputs.exclude-paths }} | ||
| run: | | ||
| # Extract per-file diff stats (added lines, hunk count) | ||
| awk ' | ||
| /^diff --git/ { | ||
| if (file != "") print file, added, hunks | ||
| file = $0; sub(/.*b\//, "", file) | ||
| added = 0; hunks = 0 | ||
| } | ||
| /^@@/ { hunks++ } | ||
| /^\+[^+]/ { added++ } | ||
| END { if (file != "") print file, added, hunks } | ||
| ' pr.diff > /tmp/file_diff_stats.txt | ||
|
|
||
| # Build final scores | ||
| jq -n '{}' > /tmp/file_risk_scores.json | ||
| while read -r file added hunks; do | ||
| SCORE=0 | ||
|
|
||
| # Security-sensitive paths: +2 | ||
| if echo "$file" | grep -qiE 'auth|security|crypto|session|secret|token|password|credential'; then | ||
| SCORE=$((SCORE + 2)) | ||
| fi | ||
|
|
||
| # Large change (>100 added lines): +2 | ||
| if [ "$added" -gt 100 ]; then | ||
| SCORE=$((SCORE + 2)) | ||
| fi | ||
|
|
||
| # Many hunks (>3): +1 | ||
| if [ "$hunks" -gt 3 ]; then | ||
| SCORE=$((SCORE + 1)) | ||
| fi | ||
|
|
||
| # Test/doc/config files: score = 0 | ||
| if echo "$file" | grep -qiE '_test\.go$|\.test\.[tj]sx?$|\.spec\.[tj]sx?$|test_.*\.py$|\.md$|\.ya?ml$|\.json$|\.toml$'; then | ||
| SCORE=0 | ||
| fi | ||
|
|
||
| # Error handling patterns in diff for this file: +1 | ||
| ERROR_LINES=$(awk -v f="$file" ' | ||
| /^diff --git/ { cur=$0; sub(/.*b\//, "", cur) } | ||
| cur == f && /^\+[^+]/ && /catch|rescue|except|recover|error|panic/ { count++ } | ||
| END { print count+0 } | ||
| ' pr.diff) | ||
| if [ "$ERROR_LINES" -gt 0 ]; then | ||
| SCORE=$((SCORE + 1)) | ||
| fi | ||
|
|
||
| if jq --arg f "$file" --argjson s "$SCORE" '.[$f] = $s' /tmp/file_risk_scores.json > /tmp/file_risk_scores.tmp; then | ||
| mv /tmp/file_risk_scores.tmp /tmp/file_risk_scores.json | ||
| else | ||
| echo "⚠️ Failed to score $file, skipping" | ||
| rm -f /tmp/file_risk_scores.tmp | ||
| fi | ||
| done < /tmp/file_diff_stats.txt | ||
|
|
||
| rm -f /tmp/file_diff_stats.txt | ||
| set -euo pipefail | ||
| node "$ACTION_PATH/dist/score-risk.js" pr.diff "$EXCLUDE_PATHS" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MEDIUM] The node "$ACTION_PATH/dist/score-risk.js" pr.diff "$EXCLUDE_PATHS"
echo "✅ File risk scores: $(jq -c . /tmp/file_risk_scores.json)"If Compare: Fix: add set -euo pipefail
node "$ACTION_PATH/dist/score-risk.js" pr.diff "$EXCLUDE_PATHS"
echo "✅ File risk scores: $(jq -c . /tmp/file_risk_scores.json)"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4bc6182. The run: |
set -euo pipefail
node "$ACTION_PATH/dist/score-risk.js" pr.diff "$EXCLUDE_PATHS"
echo "✅ File risk scores: $(jq -c . /tmp/file_risk_scores.json)"If |
||
| echo "✅ File risk scores: $(jq -c . /tmp/file_risk_scores.json)" | ||
|
|
||
| - name: Generate file history | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[LOW]
score-risk/module missing fromAGENTS.mdrepo layoutAGENTS.mdwas updated to add thefilter-diff/section (lines 42–45), butsrc/score-risk/— the other new module introduced by this PR — is absent from the layout. The layout section is the canonical map of what lives insrc/for future contributors and agents reading this file.The missing entry should appear after
filter-diff/(alphabetically betweenfilter-diff/andget-pr-meta/):There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 06b6243 — added
score-risk/betweenfilter-diff/andget-pr-meta/in the repo layout section ofAGENTS.md.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already fixed in 06b6243 (the commit immediately before this round's changes).
score-risk/is now present betweenfilter-diff/andget-pr-meta/in the repo layout section ofAGENTS.md.