Skip to content

feat(admin): fire GitHub dispatch on model PATCH (infra#153) #1298

feat(admin): fire GitHub dispatch on model PATCH (infra#153)

feat(admin): fire GitHub dispatch on model PATCH (infra#153) #1298

name: Claude Code Review
on:
pull_request:
types: [opened, ready_for_review] # When PR is ready for review (not draft)
issue_comment:
types: [created] # Listen for @claude mentions in PR comments
jobs:
claude-review:
# Run if: (PR opened/ready AND not draft) OR @claude review in PR comment
if: |
(github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
(contains(github.event.comment.body, '@claude review') ||
contains(github.event.comment.body, '@claude code review')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Fetch PR Comments Context
id: fetch-comments
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
# GraphQL query to fetch all PR comments and review threads
QUERY='query($owner: String!, $repo: String!, $prNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $prNumber) {
comments(first: 100) {
totalCount
nodes {
author { login }
body
createdAt
}
}
reviewThreads(first: 100) {
totalCount
nodes {
isResolved
isOutdated
path
line
comments(first: 50) {
nodes {
author { login }
body
createdAt
diffHunk
}
}
}
}
reviews(first: 50) {
totalCount
nodes {
author { login }
body
state
createdAt
}
}
}
}
}'
# Execute GraphQL query and check for errors
if ! COMMENTS_JSON=$(gh api graphql \
-f query="$QUERY" \
-f owner="$REPO_OWNER" \
-f repo="$REPO_NAME" \
-F prNumber="$PR_NUMBER"); then
echo "Warning: Failed to fetch PR comments. Proceeding without comment context."
echo "⚠️ Unable to fetch existing comments due to API error." > /tmp/pr_comments_context.txt
exit 0
fi
# Format comments for Claude using external Python script
export COMMENTS_JSON
python3 .github/scripts/format_pr_comments.py > /tmp/pr_comments_context.txt
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
<pr_context>
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
LANGUAGE: Rust
</pr_context>
<existing_discussions>
$(cat /tmp/pr_comments_context.txt)
</existing_discussions>
<review_instructions>
Analyze this pull request focusing on CRITICAL issues only. Keep feedback concise and actionable.
**IMPORTANT - CONTEXT AWARENESS:**
- Review the <existing_discussions> section above before providing feedback
- Acknowledge and reference previous discussions when relevant
- If a resolved thread addressed an issue, note that it was already fixed
- Build upon previous feedback rather than duplicating it
PRIORITY CHECKS (report only if found):
1. Logic & Functionality
- Logic flaws or incorrect implementations
- Missing edge cases (empty inputs, boundary conditions, None/Some variants)
- Unhandled error paths or panics in production code
- Backward compatibility issues with existing APIs/data formats
2. Production Safety (multi-cluster deployment context)
- Breaking changes that could fail during rolling updates
- State migration issues between old/new versions
- Race conditions or data consistency problems
- Resource leaks (memory, file handles, connections)
3. Database & Data Handling
- SQL injection risks or unsafe query construction
- N+1 query problems (queries in loops)
- Missing indexes causing slow queries (check query patterns)
- Missing or improper transaction boundaries
- Database migrations: ensure backward compatibility, no data loss
4. Performance & Efficiency
- Blocking operations in async functions (sync I/O, CPU-intensive work)
- Excessive memory allocations or large data structures
- Sequential operations that should be parallel (use tokio::join!/select!)
- Missing timeouts on external calls (HTTP, database, vLLM)
- Connection pool exhaustion risks
5. Rust-Specific Concerns
- Unnecessary .clone() calls (suggest borrows/references instead)
- Unsafe code without safety comments explaining invariants
- Incorrect ownership patterns or lifetime issues
- Improper error handling (unwrap/expect in library code)
- Concurrency issues (Arc/Mutex misuse, data races)
6. Code Quality
- Poor modularity (functions >100 lines, god objects)
- Unclear naming or missing documentation for public APIs
- Violated Single Responsibility Principle
- Security vulnerabilities (injection, hardcoded secrets)
REVIEW STYLE:
- List only CRITICAL issues that need fixing before merge
- Use bullet points, be direct and specific
- Provide code examples for suggested fixes when helpful
- If no critical issues: approve with brief summary
- Sign off with: ✅ (approved) or ⚠️ (issues found)
Consult the repository's CLAUDE.md file (if present) for project-specific conventions.
Use `gh pr comment` to post your review.
</review_instructions>
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'