Skip to content

πŸ™Œ OpenHands: AI-Driven Development

DogFood: Use OpenDevin to review PR (#1223)

Boxuan Li1210eea48d3a
diff --git a/.github/workflows/review-pr.yml b/.github/workflows/review-pr.yml
new file mode 100644
index 0000000000..2734f93cfc
--- /dev/null
+++ b/.github/workflows/review-pr.yml
@@ -0,0 +1,70 @@
+name: Use OpenDevin to Review Pull Request
+
+on:
+ pull_request:
+ types: [synchronize, labeled]
+
+permissions:
+ contents: write
+ pull-requests: write
+
+jobs:
+ dogfood:
+ if: contains(github.event.pull_request.labels.*.name, 'review-this')
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/opendevin/opendevin
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+
+ steps:
+ - name: install git, github cli
+ run: |
+ apt-get install -y git gh
+ git config --global --add safe.directory $PWD
+
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.base.ref }} # check out the target branch
+
+ - name: Download Diff
+ run: |
+ curl -O "${{ github.event.pull_request.diff_url }}" -L
+
+ - name: Write Task File
+ run: |
+ echo "Your coworker wants to apply a pull request to this project. Read and review it, and write your concise comments and suggestions to review-${{ github.event.pull_request.number }}.txt" > task.txt
+ echo "TITLE:" >> task.txt
+ echo "${{ github.event.pull_request.title }}" >> task.txt
+ echo "" >> task.txt
+ echo "BODY:" >> task.txt
+ echo "${{ github.event.pull_request.body }}" >> task.txt
+ echo "" >> task.txt
+ echo "The diff is:" >> task.txt
+ cat ${{ github.event.pull_request.number }}.diff >> task.txt
+ rm ${{ github.event.pull_request.number }}.diff
+
+ - name: Run OpenDevin
+ env:
+ LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ SANDBOX_TYPE: exec
+ run: |
+ python ./opendevin/main.py -i 50 -f task.txt -d ./
+ rm task.txt
+
+ - name: Check if review file is non-empty
+ id: check_file
+ run: |
+ ls -la
+ if [[ -s review-${{ github.event.pull_request.number }}.txt ]]; then
+ echo "non_empty=true" >> $GITHUB_OUTPUT
+ fi
+ shell: bash
+
+ - name: Create PR review if file is non-empty
+ env:
+ GH_TOKEN: ${{ github.token }}
+ if: steps.check_file.outputs.non_empty == 'true'
+ run: |
+ gh pr review ${{ github.event.pull_request.number }} --comment --body-file "review-${{ github.event.pull_request.number }}.txt"
diff --git a/.github/workflows/dogfood.yml b/.github/workflows/solve-issue.yml
similarity index 95%
rename from .github/workflows/dogfood.yml
rename to .github/workflows/solve-issue.yml
index 99a18ff502..6cef5f5170 100644
--- a/.github/workflows/dogfood.yml
+++ b/.github/workflows/solve-issue.yml
@@ -10,8 +10,8 @@ permissions:
issues: write
jobs:
- open-devin:
- if: github.event.label.name == 'dogfood-this'
+ dogfood:
+ if: github.event.label.name == 'solve-this'
runs-on: ubuntu-latest
container:
image: ghcr.io/opendevin/opendevin
@@ -43,7 +43,7 @@ jobs:
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SANDBOX_TYPE: exec
run: |
- python ./opendevin/main.py -d "./" -i 50 -f task.txt -d $GITHUB_WORKSPACE
+ python ./opendevin/main.py -i 50 -f task.txt -d $GITHUB_WORKSPACE
rm task.txt
- name: Setup Git, Create Branch, and Commit Changes