Skip to content

Commit e64961d

Browse files
feat(ci): migrate from Claude to GitHub Copilot code review (#588)
* feat(ci): migrate from Claude to GitHub Copilot code review - Remove claude-code-review.yml and claude.yml workflows - Update auto-approve.yml to check Copilot inline comments instead of Claude - Copilot code review is now configured via repository ruleset This change reduces CI costs and avoids potential account suspension from running Claude ~100 times/day across different GitHub runners. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * fix(ci): address Copilot review feedback and skip tests for CI-only changes - Check Copilot review existence before checking comments (fixes race condition) - Only trigger Unity tests for unity-tests.yml and pr-tests.yml changes - Other CI workflow changes (auto-approve, etc.) no longer run Unity tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * fix(ci): use correct Copilot bot usernames - Reviews: copilot-pull-request-reviewer[bot] - Comments: Copilot Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * fix(ci): check unresolved Copilot threads instead of all comments Resolved threads should not block auto-approve. Use GraphQL to count only unresolved review threads from Copilot. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> * fix(ci): simplify GraphQL query to avoid variable escaping issues Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> --------- Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent da89a80 commit e64961d

File tree

4 files changed

+28
-117
lines changed

4 files changed

+28
-117
lines changed

.github/workflows/auto-approve.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
types: [completed]
77
# Also trigger on workflow run completion for reusable workflows
88
workflow_run:
9-
workflows: ["PR Tests", "Claude Code Review"]
9+
workflows: ["PR Tests"]
1010
types: [completed]
1111

1212
permissions: read-all
@@ -50,18 +50,29 @@ jobs:
5050
HEAD_SHA=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER --jq '.head.sha')
5151
echo "Head SHA: $HEAD_SHA"
5252
53-
# Check Claude review - look for "No issues found" comment from claude[bot]
54-
# Claude posts a PR comment with this message when review passes
55-
CLAUDE_COMMENTS=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" --jq '[.[] | select(.user.login == "claude[bot]") | .body] | join("\n")')
56-
57-
CLAUDE_APPROVED="false"
58-
if echo "$CLAUDE_COMMENTS" | grep -q "No issues found. Checked for bugs and CLAUDE.md compliance"; then
59-
echo "Claude review: No issues found"
60-
CLAUDE_APPROVED="true"
53+
# Check Copilot review - must verify Copilot has actually reviewed first
54+
# Copilot leaves "COMMENTED" reviews (never "APPROVED" or "CHANGES_REQUESTED")
55+
# We need to: 1) Confirm a review exists, 2) Check for UNRESOLVED comments
56+
# Note: Copilot uses "copilot-pull-request-reviewer[bot]" for reviews
57+
COPILOT_REVIEW=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" --jq '[.[] | select(.user.login == "copilot-pull-request-reviewer[bot]")] | length')
58+
59+
# Use GraphQL to count unresolved Copilot review threads
60+
REPO_OWNER="${{ github.repository_owner }}"
61+
REPO_NAME="${{ github.repository }}"
62+
REPO_NAME="${REPO_NAME#*/}" # Extract repo name from owner/repo
63+
UNRESOLVED_THREADS=$(gh api graphql -f query="query { repository(owner: \"$REPO_OWNER\", name: \"$REPO_NAME\") { pullRequest(number: $PR_NUMBER) { reviewThreads(first: 100) { nodes { isResolved comments(first: 1) { nodes { author { login } } } } } } } }" \
64+
--jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and .comments.nodes[0].author.login == "copilot-pull-request-reviewer")] | length')
65+
66+
COPILOT_OK="false"
67+
if [ "$COPILOT_REVIEW" -eq 0 ]; then
68+
echo "Copilot review: Not yet reviewed (no review found)"
69+
elif [ "$UNRESOLVED_THREADS" -eq 0 ]; then
70+
echo "Copilot review: Reviewed with no unresolved issues"
71+
COPILOT_OK="true"
6172
else
62-
echo "Claude review: Issues found or not yet complete"
73+
echo "Copilot review: Found $UNRESOLVED_THREADS unresolved threads - issues need addressing"
6374
fi
64-
echo "Claude approved: $CLAUDE_APPROVED"
75+
echo "Copilot OK: $COPILOT_OK"
6576
6677
# Check Unity Tests status (commit status, not check run)
6778
UNITY_STATUS=$(gh api repos/${{ github.repository }}/commits/$HEAD_SHA/status --jq '.statuses[] | select(.context == "Unity Tests") | .state' | head -1)
@@ -77,11 +88,11 @@ jobs:
7788
fi
7889
7990
# Determine if we should approve
80-
if [ "$CLAUDE_APPROVED" == "true" ] && [ "$UNITY_STATUS" == "success" ]; then
81-
echo "All required checks passed and Claude found no issues!"
91+
if [ "$COPILOT_OK" == "true" ] && [ "$UNITY_STATUS" == "success" ]; then
92+
echo "All required checks passed and Copilot found no issues!"
8293
echo "should_approve=true" >> $GITHUB_OUTPUT
8394
else
84-
echo "Required checks not yet passed or Claude found issues"
95+
echo "Required checks not yet passed or Copilot found issues"
8596
echo "should_approve=false" >> $GITHUB_OUTPUT
8697
fi
8798
@@ -111,6 +122,6 @@ jobs:
111122
run: |
112123
PR_NUMBER="${{ steps.pr.outputs.number }}"
113124
114-
gh pr review $PR_NUMBER -R ${{ github.repository }} --approve --body "Auto-approved: Claude review found no issues and Unity Tests passed (or were skipped for non-code changes)."
125+
gh pr review $PR_NUMBER -R ${{ github.repository }} --approve --body "Auto-approved: Copilot review found no issues and Unity Tests passed (or were skipped for non-code changes)."
115126
116127
echo "PR #$PR_NUMBER approved!"

.github/workflows/claude-code-review.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/claude.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/pr-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
- 'UnityProject/Packages/com.jasonxudeveloper.jengine.core/**'
3939
- 'UnityProject/Packages/com.jasonxudeveloper.jengine.util/**'
4040
- 'UnityProject/Assets/Tests/**'
41-
- '.github/workflows/**'
41+
- '.github/workflows/unity-tests.yml'
42+
- '.github/workflows/pr-tests.yml'
4243
4344
run-tests:
4445
name: Run Unity Tests

0 commit comments

Comments
 (0)