Skip to content

Commit

Permalink
Aider instead of openhands (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmayer authored Nov 30, 2024
1 parent 4502b80 commit 4bc3446
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 62 deletions.
71 changes: 54 additions & 17 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,93 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: main
pull_request:
branches: [main, master]
branches: main

name: R CMD CHECK

permissions: read-all

jobs:
# Only run R CMD check if there are changes to R-related files
# R/|data/|tests/|vignettes/|DESCRIPTION|NAMESPACE
check-if-r-changes:
runs-on: ubuntu-latest
outputs:
run-r-checks: ${{ steps.check-files.outputs.run-r-checks }}
steps:
- uses: actions/checkout@v4
- id: check-files
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "run-r-checks=true" >> "${GITHUB_OUTPUT}"
else
# Check if any R-related files changed
git fetch origin "${{ github.base_ref }}"
CHANGED_FILES="$(git diff --name-only "origin/${{ github.base_ref }}"..HEAD)"
if echo "${CHANGED_FILES}" | grep -qE '^(R/|data/|tests/|vignettes/|DESCRIPTION|NAMESPACE)'; then
echo "run-r-checks=true" >> "${GITHUB_OUTPUT}"
else
echo "run-r-checks=false" >> "${GITHUB_OUTPUT}"
fi
fi
R-CMD-check:
needs: check-if-r-changes
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix: # https://en.wikipedia.org/wiki/R_(programming_language)#Version_names
config: # https://github.com/r-hub/rversions rversions::r_versions()

# macOS / Widnows on latest
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}

# Ubuntu on latest, devel, release, oldrel as well as version in DESCRIPTION
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'} # rversions::r_release()
- {os: ubuntu-latest, r: 'oldrel-1'} # rversions::r_oldrel()
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
# - {os: ubuntu-latest, r: 'oldrel-4'} After the next major release add this back in
- {os: ubuntu-latest, r: '4.1.0'} # Oldest supported release. 2021-05-18: 3+ years old

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
- {os: ubuntu-latest, r: '4.1.0'}

steps:
- name: Check if R changes
id: should-run
shell: bash
run: |
if [ "${{ needs.check-if-r-changes.outputs.run-r-checks }}" = "true" ]; then
echo "should_run=true" >> "${GITHUB_OUTPUT}"
else
echo "should_run=false" >> "${GITHUB_OUTPUT}"
fi
- name: Skip Check
if: steps.should-run.outputs.should_run != 'true'
shell: bash
run: |
echo "Skipping R CMD check - no R-related changes"
exit 0
- uses: actions/checkout@v4
if: steps.should-run.outputs.should_run == 'true'

- uses: r-lib/actions/setup-pandoc@v2
if: steps.should-run.outputs.should_run == 'true'

- uses: r-lib/actions/setup-r@v2
if: steps.should-run.outputs.should_run == 'true'
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
if: steps.should-run.outputs.should_run == 'true'
with:
extra-packages: any::rcmdcheck
needs: check

- run: make check
if: steps.should-run.outputs.should_run == 'true'
88 changes: 88 additions & 0 deletions .github/workflows/aider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Aider Issue Fix
on:
workflow_dispatch:
inputs:
issue_number:
description: 'Issue number to fix'
required: true
type: string
model:
description: 'Model to use'
required: false
type: string
default: 'claude-3-5-sonnet-20241022'

permissions:
contents: write
pull-requests: write
issues: read

jobs:
aider-fix:
runs-on: ubuntu-latest
if: github.actor == 'zachmayer'
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Install Package
run: make install

- name: Get Issue Content
id: get-issue
uses: actions-cool/issues-helper@v3
with:
actions: 'get-issue'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.inputs.issue_number }}

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Aider
run: pip install -U aider-chat

- name: Prepare Instructions
run: |
echo "${{ steps.get-issue.outputs.issue-body }}" > issue.md
cat aider-instructions.md issue.md > combined_instructions.md
- name: Run Aider
run: |
aider \
--model anthropic/${{ github.event.inputs.model }} \
--no-analytics \
--yes-always \
--verbose \
--lint-cmd "make fix-style lint" \
--test-cmd "make test" \
--message-file combined_instructions.md \
--auto-commits
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "fix: Automated fixes for issue #${{ github.event.inputs.issue_number }}"
branch: aider-fix-issue-${{ github.event.inputs.issue_number }}
delete-branch: true
title: "fix: Automated fixes for issue #${{ github.event.inputs.issue_number }}"
body: |
This PR contains automated fixes for issue #${{ github.event.inputs.issue_number }} using aider.
Original issue: ${{ steps.get-issue.outputs.issue-title }}
45 changes: 0 additions & 45 deletions .github/workflows/openhands-resolver.yml

This file was deleted.

0 comments on commit 4bc3446

Please sign in to comment.