-
Notifications
You must be signed in to change notification settings - Fork 359
[feat] Add comprehensive Claude PR review with inline comments #4453
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 16 commits
0694a96
0f871b5
2271607
f8cbd15
39dc780
4e70864
13b826f
931d772
b800104
8a806dd
f3e4bb7
187fe67
79fe98e
19f45c0
51622eb
4d70abb
a60e7c0
59b412f
25cd97c
d4280f9
976130a
2acc16e
a6b7ccb
d9f4df3
d0deb4c
5e2ed16
1df08d0
1677513
ee42add
34dee8f
b82e0d7
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ permissions: | |
contents: read | ||
pull-requests: write | ||
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. [Security] Medium Priority Issue: Broad permissions granted to workflow that may not all be necessary |
||
issues: write | ||
id-token: write | ||
|
||
on: | ||
pull_request: | ||
|
@@ -20,15 +21,15 @@ jobs: | |
uses: lewagon/wait-on-check-action@v1.3.1 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
check-regexp: '^(ESLint|Prettier Check|Tests CI|Vitest Tests)' | ||
check-regexp: '^(eslint|prettier|test)' | ||
wait-interval: 30 | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check if we should proceed | ||
id: check-status | ||
run: | | ||
# Get all check runs for this commit | ||
CHECK_RUNS=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs --jq '.check_runs[] | select(.name | test("ESLint|Prettier Check|Tests CI|Vitest Tests")) | {name, conclusion}') | ||
CHECK_RUNS=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs --jq '.check_runs[] | select(.name | test("eslint|prettier|test")) | {name, conclusion}') | ||
|
||
# Check if any required checks failed | ||
if echo "$CHECK_RUNS" | grep -q '"conclusion": "failure"'; then | ||
|
@@ -61,12 +62,81 @@ jobs: | |
npm install -g typescript @vue/compiler-sfc | ||
|
||
- name: Run Claude PR Review | ||
uses: anthropics/claude-code-action@main | ||
uses: anthropics/claude-code-base-action@beta | ||
with: | ||
prompt_file: .claude/commands/comprehensive-pr-review.md | ||
prompt: | | ||
You are performing a code review for PR #${{ github.event.pull_request.number }} in the ComfyUI_frontend repository. | ||
|
||
STEP 1: Get PR information and changed files | ||
Execute this bash command: | ||
```bash | ||
gh pr view $PR_NUMBER --json files,title,body,additions,deletions --jq '.files[].filename' > changed_files.txt | ||
echo "Changed files:" | ||
cat changed_files.txt | ||
``` | ||
|
||
STEP 2: Analyze each changed file | ||
For each file in changed_files.txt: | ||
- Read the file using the Read tool | ||
- Look for these issues: | ||
* Security vulnerabilities (hardcoded secrets, SQL injection, XSS) | ||
* Performance problems (console.log statements, inefficient code) | ||
* Code quality issues (missing error handling, deprecated patterns) | ||
* Architecture violations (improper component structure) | ||
|
||
STEP 3: Post individual inline review comments | ||
For each issue found, post an inline comment using this bash function: | ||
```bash | ||
add_inline_comment() { | ||
local file_path=$1 | ||
local line_number=$2 | ||
local severity=$3 | ||
local category=$4 | ||
local issue=$5 | ||
local suggestion=$6 | ||
|
||
gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/$REPOSITORY/pulls/$PR_NUMBER/comments \ | ||
-f body="**[$category] $severity Priority** | ||
|
||
**Issue**: $issue | ||
**Suggestion**: $suggestion | ||
|
||
This review is generated by Claude." \ | ||
-f commit_id="$COMMIT_SHA" \ | ||
-f path="$file_path" \ | ||
-F line=$line_number \ | ||
-f side="RIGHT" | ||
} | ||
|
||
# Example usage: | ||
# add_inline_comment "src/services/testReviewService.ts" 15 "Critical" "Security" "Hardcoded API key" "Use environment variables instead" | ||
``` | ||
|
||
STEP 4: Post final summary review | ||
After posting all inline comments, create a summary: | ||
```bash | ||
gh pr review $PR_NUMBER --comment --body "# 🤖 Claude PR Review Summary | ||
|
||
**Issues Found**: [X total] | ||
- Critical: [X] | ||
- High: [X] | ||
- Medium: [X] | ||
- Low: [X] | ||
|
||
See individual inline comments above for specific issues and suggestions. | ||
|
||
This review is generated by Claude. It may not always be accurate. Please verify suggestions before implementing." | ||
``` | ||
|
||
The environment variables PR_NUMBER, GITHUB_TOKEN, COMMIT_SHA, and REPOSITORY are already set. | ||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
max_turns: 1 | ||
max_turns: 30 | ||
timeout_minutes: 30 | ||
allowed_tools: "Bash(git:*),Bash(gh:*),Bash(jq:*),Bash(curl:*),Bash(echo:*),Bash(mkdir:*),Bash(mv:*),Bash(cp:*),Bash(find:*),Bash(cat:*),Bash(wc:*),Bash(awk:*),Bash(date:*),Bash(export:*),Read,Write,Edit,Glob,Grep,WebFetch" | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { expect } from '@playwright/test' | ||
import { Position } from '@vueuse/core' | ||
|
||
// Test update for PR review validation | ||
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. [Quality] Low Priority Issue: Test comment lacks specific purpose or context 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. [Quality] Low Priority Issue: Test comment lacks specific purpose or context |
||
|
||
import { | ||
type ComfyPage, | ||
comfyPageFixture as test, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,10 +329,6 @@ | |
}, | ||
"tooltip": "選單列位置。在行動裝置上,選單永遠顯示在頂部。" | ||
}, | ||
"Comfy_Validation_NodeDefs": { | ||
"name": "驗證節點定義(較慢)", | ||
"tooltip": "建議節點開發者使用。這會在啟動時驗證所有節點定義。" | ||
}, | ||
"Comfy_Validation_Workflows": { | ||
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. [Quality] Medium Priority Issue: Translation key removed without verification of usage in codebase 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. [Quality] Medium Priority Issue: Translation key removed without verification of usage in codebase |
||
"name": "驗證工作流程" | ||
}, | ||
|
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.
[Security] Medium Priority
Issue: Broad permissions granted to workflow that may not all be necessary
Context: The workflow has write permissions for contents, issues, statuses which increases attack surface if compromised
Suggestion: Follow principle of least privilege - only grant the minimum permissions needed (pull-requests: write and contents: read appear sufficient)