review-pr.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Workflow that uses OpenDevin to review a pull request. PR must be labeled 'review-this'
  2. name: Use OpenDevin to Review Pull Request
  3. on:
  4. pull_request:
  5. types: [synchronize, labeled]
  6. permissions:
  7. contents: write
  8. pull-requests: write
  9. jobs:
  10. dogfood:
  11. if: contains(github.event.pull_request.labels.*.name, 'review-this')
  12. runs-on: ubuntu-latest
  13. steps:
  14. - uses: actions/checkout@v4
  15. - name: Set up Python
  16. uses: actions/setup-python@v5
  17. with:
  18. python-version: '3.11'
  19. - name: install git, github cli
  20. run: |
  21. sudo apt-get install -y git gh
  22. git config --global --add safe.directory $PWD
  23. - name: Checkout Repository
  24. uses: actions/checkout@v4
  25. with:
  26. ref: ${{ github.event.pull_request.base.ref }} # check out the target branch
  27. - name: Download Diff
  28. run: |
  29. curl -O "${{ github.event.pull_request.diff_url }}" -L
  30. - name: Write Task File
  31. run: |
  32. echo "Your coworker wants to apply a pull request to this project." > task.txt
  33. echo "Read and review ${{ github.event.pull_request.number }}.diff file. Create a review-${{ github.event.pull_request.number }}.txt and write your concise comments and suggestions there." >> task.txt
  34. echo "Do not ask me for confirmation at any point." >> task.txt
  35. echo "" >> task.txt
  36. echo "Title" >> task.txt
  37. echo "${{ github.event.pull_request.title }}" >> task.txt
  38. echo "" >> task.txt
  39. echo "Description" >> task.txt
  40. echo "${{ github.event.pull_request.body }}" >> task.txt
  41. echo "" >> task.txt
  42. echo "Diff file is: ${{ github.event.pull_request.number }}.diff" >> task.txt
  43. - name: Set up environment
  44. run: |
  45. curl -sSL https://install.python-poetry.org | python3 -
  46. export PATH="/github/home/.local/bin:$PATH"
  47. poetry install --without evaluation,llama-index
  48. poetry run playwright install --with-deps chromium
  49. - name: Run OpenDevin
  50. env:
  51. LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
  52. LLM_MODEL: ${{ vars.LLM_MODEL }}
  53. run: |
  54. # Append path to launch poetry
  55. export PATH="/github/home/.local/bin:$PATH"
  56. # Append path to correctly import package, note: must set pwd at first
  57. export PYTHONPATH=$(pwd):$PYTHONPATH
  58. export WORKSPACE_MOUNT_PATH=$GITHUB_WORKSPACE
  59. export WORKSPACE_BASE=$GITHUB_WORKSPACE
  60. echo -e "/exit\n" | poetry run python opendevin/core/main.py -i 50 -f task.txt
  61. rm task.txt
  62. - name: Check if review file is non-empty
  63. id: check_file
  64. run: |
  65. ls -la
  66. if [[ -s review-${{ github.event.pull_request.number }}.txt ]]; then
  67. echo "non_empty=true" >> $GITHUB_OUTPUT
  68. fi
  69. shell: bash
  70. - name: Create PR review if file is non-empty
  71. env:
  72. GH_TOKEN: ${{ github.token }}
  73. if: steps.check_file.outputs.non_empty == 'true'
  74. run: |
  75. gh pr review ${{ github.event.pull_request.number }} --comment --body-file "review-${{ github.event.pull_request.number }}.txt"