Skip to content

Commit

Permalink
Workflow for PR-ARENA (no errors)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiseungHong committed Oct 31, 2024
1 parent 031385e commit c701a4c
Showing 1 changed file with 30 additions and 44 deletions.
74 changes: 30 additions & 44 deletions .github/workflows/openhands-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ on:

issues:
types: [labeled]
pull_request:
types: [labeled]


permissions:
Expand Down Expand Up @@ -58,34 +56,25 @@ jobs:
fi
done
- name: Set issue number and type
run: |
if [ -n "${{ github.event.pull_request.number }}" ]; then
echo "ISSUE_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "ISSUE_TYPE=pr" >> $GITHUB_ENV
else
echo "ISSUE_NUMBER=${{ github.event.issue.number || inputs.issue_number }}" >> $GITHUB_ENV
echo "ISSUE_TYPE=issue" >> $GITHUB_ENV
fi
- name: Set issue number
run: echo "ISSUE_NUMBER=${{ github.event.issue.number || inputs.issue_number }}" >> $GITHUB_ENV

- name: Comment on issue with start message
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueType = process.env.ISSUE_TYPE;
const endpoint = issueType === 'pr' ? 'pulls' : 'issues';
github.rest[endpoint].createComment({
script: |
github.rest.issues.createComment({
issue_number: ${{ env.ISSUE_NUMBER }},
owner: context.repo.owner,
repo: context.repo.repo,
body: `OpenHands started fixing the ${issueType}! You can monitor the progress [here](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).`
body: `OpenHands started fixing the issue! You can monitor the progress [here](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).`
});
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/neulab/pr-arena.git
pip install git+https://github.com/JiseungHong/openhands-resolver.git
- name: Attempt to resolve issue
env:
Expand All @@ -97,11 +86,10 @@ jobs:
run: |
cd /tmp && python -m openhands_resolver.resolve_issues \
--repo ${{ github.repository }} \
--issue-numbers ${{ env.ISSUE_NUMBER }} \
--issue-type ${{ env.ISSUE_TYPE }}
--issue-numbers ${{ env.ISSUE_NUMBER }}
- name: Check resolution result
id: check_result
- name: Check resolution results
id: check_results
run: |
if cd /tmp && grep -q '"success":true' output/output1.jsonl; then
echo "MODEL1_RESOLUTION_SUCCESS=true" >> $GITHUB_OUTPUT
Expand All @@ -114,7 +102,7 @@ jobs:
echo "MODEL2_RESOLUTION_SUCCESS=false" >> $GITHUB_OUTPUT
fi
- name: Create draft PR or push branch
- name: Create draft PR or branch
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
LLM_MODELS: ${{ secrets.LLM_MODELS }}
Expand Down Expand Up @@ -158,34 +146,34 @@ jobs:
script: |
const fs = require('fs');
const issueNumber = ${{ env.ISSUE_NUMBER }};
const success = ${{ steps.check_result.outputs.MODEL1_RESOLUTION_SUCCESS }};
const success1 = "${{ steps.check_result.outputs.MODEL1_RESOLUTION_SUCCESS }}" === "true";
let prNumber = '';
let branchName = '';
let prNumber1 = '';
let branchName1 = '';
try {
if (success) {
prNumber = fs.readFileSync('/tmp/pr_number1.txt', 'utf8').trim();
if (success1) {
prNumber1 = fs.readFileSync('/tmp/pr_number1.txt', 'utf8').trim();
} else {
branchName = fs.readFileSync('/tmp/branch_name1.txt', 'utf8').trim();
branchName1 = fs.readFileSync('/tmp/branch_name1.txt', 'utf8').trim();
}
} catch (error) {
console.error('Error reading file:', error);
}
if (success && prNumber) {
if (success1 && prNumber1) {
github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `A potential fix has been generated and a draft PR #${prNumber} has been created. Please review the changes.`
body: `A potential fix has been generated and a draft PR #${prNumber1} has been created. Please review the changes.`
});
} else if (!success && branchName) {
} else if (!success1 && branchName1) {
github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named '${branchName}' has been created with the attempted changes. You can view the branch [here](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${branchName}). Manual intervention may be required.`
body: `An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named '${branchName1}' has been created with the attempted changes. You can view the branch [here](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${branchName1}). Manual intervention may be required.`
});
} else {
github.rest.issues.createComment({
Expand All @@ -196,36 +184,34 @@ jobs:
});
}
const fs = require('fs');
const issueNumber = ${{ env.ISSUE_NUMBER }};
const success = ${{ steps.check_result.outputs.MODEL2_RESOLUTION_SUCCESS }};
const success2 = "${{ steps.check_result.outputs.MODEL2_RESOLUTION_SUCCESS }}" === "true";
let prNumber = '';
let branchName = '';
let prNumber2 = '';
let branchName2 = '';
try {
if (success) {
prNumber = fs.readFileSync('/tmp/pr_number2.txt', 'utf8').trim();
if (success2) {
prNumber2 = fs.readFileSync('/tmp/pr_number2.txt', 'utf8').trim();
} else {
branchName = fs.readFileSync('/tmp/branch_name2.txt', 'utf8').trim();
branchName2 = fs.readFileSync('/tmp/branch_name2.txt', 'utf8').trim();
}
} catch (error) {
console.error('Error reading file:', error);
}
if (success && prNumber) {
if (success2 && prNumber2) {
github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `A potential fix has been generated and a draft PR #${prNumber} has been created. Please review the changes.`
body: `A potential fix has been generated and a draft PR #${prNumber2} has been created. Please review the changes.`
});
} else if (!success && branchName) {
} else if (!success2 && branchName2) {
github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named '${branchName}' has been created with the attempted changes. You can view the branch [here](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${branchName}). Manual intervention may be required.`
body: `An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named '${branchName2}' has been created with the attempted changes. You can view the branch [here](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${branchName2}). Manual intervention may be required.`
});
} else {
github.rest.issues.createComment({
Expand Down

0 comments on commit c701a4c

Please sign in to comment.