-
Notifications
You must be signed in to change notification settings - Fork 178
CI: autofix dependabot reth PR with claude #836
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
Open
metachris
wants to merge
1
commit into
develop
Choose a base branch
from
deps-fix2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| name: Dependabot Auto-fix | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build-and-fix: | ||
| # Only run on Dependabot PRs | ||
| if: github.actor == 'dependabot[bot]' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Rust | ||
| uses: dtolnay/rust-action@stable | ||
|
|
||
| - name: Cache cargo registry | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| target | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
|
||
| - name: Build and capture errors | ||
| id: build | ||
| continue-on-error: true | ||
| run: | | ||
| cargo build 2>&1 | tee build_output.txt | ||
| echo "exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Run Claude to fix issues | ||
| if: steps.build.outputs.exit_code != '0' | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| prompt: | | ||
| The Dependabot PR to update reth dependencies has build failures. | ||
|
|
||
| Build output is in build_output.txt. Please: | ||
| 1. Read the build errors | ||
| 2. Analyze what changes are needed to fix compatibility issues | ||
| 3. Make the necessary code fixes | ||
| 4. Do NOT change the dependency versions back - fix the code to work with the new versions | ||
|
|
||
| Focus on: | ||
| - API changes in reth crates | ||
| - Type signature changes | ||
| - Removed or renamed functions/structs | ||
| - New required trait implementations | ||
|
|
||
| - name: Generate diff | ||
| if: steps.build.outputs.exit_code != '0' | ||
| id: diff | ||
| run: | | ||
| git diff > suggested_fixes.diff | ||
| if [ -s suggested_fixes.diff ]; then | ||
| echo "has_changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "has_changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Comment on PR with suggested fixes | ||
| if: steps.build.outputs.exit_code != '0' && steps.diff.outputs.has_changes == 'true' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const diff = fs.readFileSync('suggested_fixes.diff', 'utf8'); | ||
| const buildOutput = fs.readFileSync('build_output.txt', 'utf8'); | ||
|
|
||
| // Truncate build output if too long | ||
| const maxBuildLen = 3000; | ||
| const truncatedBuild = buildOutput.length > maxBuildLen | ||
| ? buildOutput.slice(-maxBuildLen) + '\n... (truncated)' | ||
| : buildOutput; | ||
|
|
||
| const body = `## 🤖 Claude Auto-fix Suggestions | ||
|
|
||
| The build failed with the following errors: | ||
|
|
||
| <details> | ||
| <summary>Build Output</summary> | ||
|
|
||
| \`\`\` | ||
| ${truncatedBuild} | ||
| \`\`\` | ||
|
|
||
| </details> | ||
|
|
||
| ### Suggested Fixes | ||
|
|
||
| Claude analyzed the build failures and suggests the following changes: | ||
|
|
||
| \`\`\`diff | ||
| ${diff} | ||
| \`\`\` | ||
|
|
||
| <details> | ||
| <summary>Apply this patch</summary> | ||
|
|
||
| \`\`\`bash | ||
| curl -sL ${{ github.event.pull_request.html_url }}.diff | git apply | ||
| # Or copy the diff above and run: git apply < suggested_fixes.diff | ||
| \`\`\` | ||
|
|
||
| </details> | ||
|
|
||
| --- | ||
| *Generated with [Claude Code](https://claude.ai/claude-code)*`; | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: body | ||
| }); | ||
|
|
||
| - name: Comment if no fixes found | ||
| if: steps.build.outputs.exit_code != '0' && steps.diff.outputs.has_changes == 'false' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const buildOutput = fs.readFileSync('build_output.txt', 'utf8'); | ||
|
|
||
| const maxBuildLen = 5000; | ||
| const truncatedBuild = buildOutput.length > maxBuildLen | ||
| ? buildOutput.slice(-maxBuildLen) + '\n... (truncated)' | ||
| : buildOutput; | ||
|
|
||
| const body = `## 🤖 Claude Auto-fix Analysis | ||
|
|
||
| The build failed but Claude was unable to automatically generate fixes. | ||
|
|
||
| <details> | ||
| <summary>Build Output</summary> | ||
|
|
||
| \`\`\` | ||
| ${truncatedBuild} | ||
| \`\`\` | ||
|
|
||
| </details> | ||
|
|
||
| Manual intervention may be required to resolve these compatibility issues. | ||
|
|
||
| --- | ||
| *Generated with [Claude Code](https://claude.ai/claude-code)*`; | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: body | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The curl command downloads the entire PR diff, not the suggested fixes. This should download the suggested_fixes.diff file instead. Consider using GitHub's artifact upload/download or generating a raw link to the diff file.