@@ -100,3 +100,78 @@ jobs:
100100
101101 - name : Check code formatting
102102 run : cargo fmt -- --check
103+
104+ claude-ci-analysis :
105+ name : Claude CI Analysis
106+
107+ runs-on : ubuntu-latest
108+ needs : [test_all, clippy_check, fmt_check]
109+ if : failure() && contains(github.event.pull_request.labels.*.name, 'claude-debug')
110+
111+ permissions :
112+ contents : write
113+ pull-requests : write
114+ issues : read
115+ id-token : write
116+ actions : read
117+
118+ steps :
119+ - name : Checkout repository
120+ uses : actions/checkout@v5
121+ with :
122+ fetch-depth : 10
123+ ref : ${{ github.event.pull_request.head.ref }}
124+
125+ - name : Check Claude fix attempt count
126+ id : check-attempts
127+ run : |
128+ # Count how many times Claude has already tried to fix this
129+ ATTEMPT_COUNT=$(git log -10 --pretty=%B | grep -c "🤖 Claude CI fix attempt" || echo "0")
130+ echo "Current attempt count: $ATTEMPT_COUNT"
131+
132+ if [ "$ATTEMPT_COUNT" -ge 2 ]; then
133+ echo "skip=true" >> $GITHUB_OUTPUT
134+ echo "❌ Claude has already made 2 fix attempts. Stopping to prevent infinite loop."
135+ else
136+ NEXT_ATTEMPT=$((ATTEMPT_COUNT + 1))
137+ echo "skip=false" >> $GITHUB_OUTPUT
138+ echo "attempt_number=$NEXT_ATTEMPT" >> $GITHUB_OUTPUT
139+ echo "✅ Proceeding with fix attempt $NEXT_ATTEMPT/2"
140+ fi
141+
142+ - name : Run Claude CI Fix
143+ if : steps.check-attempts.outputs.skip != 'true'
144+ uses : anthropics/claude-code-action@v1
145+ with :
146+ claude_code_oauth_token : ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
147+ prompt : |
148+ REPO: ${{ github.repository }}
149+ PR NUMBER: ${{ github.event.pull_request.number }}
150+ PR BRANCH: ${{ github.event.pull_request.head.ref }}
151+ FIX ATTEMPT: ${{ steps.check-attempts.outputs.attempt_number }}/2
152+
153+ The CI workflow has failed. Your task is to:
154+ 1. Analyze the CI failure logs to identify the root cause
155+ 2. Fix the code to resolve the issue
156+ 3. Commit and push your fixes to the PR branch
157+
158+ IMPORTANT COMMIT MESSAGE FORMAT:
159+ Your commit message MUST include:
160+ - Clear description of what you fixed
161+ - The marker: "🤖 Claude CI fix attempt ${{ steps.check-attempts.outputs.attempt_number }}/2"
162+ - This prevents infinite loops and tracks attempt count
163+
164+ Example commit message:
165+ "Fix: [description of fix]
166+
167+ 🤖 Claude CI fix attempt ${{ steps.check-attempts.outputs.attempt_number }}/2
168+
169+ Co-authored-by: Claude <noreply@anthropic.com>"
170+
171+ GUIDELINES:
172+ - Make focused, minimal changes to fix the specific CI failure
173+ - Do not make unrelated improvements
174+ - Use git commands to commit and push your changes
175+ - After pushing, CI will run automatically
176+
177+ claude_args : ' --allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh api:*),Bash(gh run view:*),Bash(git status:*),Bash(git diff:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git log:*)"'
0 commit comments