Triager Tester in GitHub Actions #13
This file contains 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
name: Testing Triager | |
run-name: Triager Tester in GitHub Actions | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
triager_test: | |
name: Triager Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install dependencies | |
run: npm install axios | |
- name: Collect 5 random closed issues from OpenJ9 | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
const axios = require('axios'); | |
let issues = []; | |
const owner = "eclipse-openj9"; | |
const repo = "openj9"; | |
closed_issues_collected = 0; | |
function getRandomInt(min, max) { | |
const minCeiled = Math.ceil(min); | |
const maxFloored = Math.floor(max); | |
return Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled); | |
} | |
while (closed_issues_collected < 5) { | |
const issue_number = getRandomInt(19358, 19658); | |
const { data } = await github.issues.get({ | |
owner, | |
repo, | |
issue_number | |
}); | |
if (data.status != 400 && data.state === "closed" && data.assignee != null && data.labels.length != 0) { | |
issues.push(data); | |
closed_issues_collected++; | |
} | |
} | |
modelOutputs = []; | |
for (let i = 0; i < issues.length; i++) { | |
let issue = issues[i]; | |
let input = { | |
"issue_title": issue["title"], | |
"issue_description": issue["body"], | |
} | |
const response = await axios.post('http://140.211.168.122/recommendation', JSON.stringify(input), { | |
headers: { | |
'accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
}); | |
modelOutputs.push(response.data); | |
} | |
resultString = ''; | |
for (let i = 0; i < issues.length; i++) { | |
actualLabels = issues[i]["labels"].map(label => label["name"]); | |
actualAssignees = issues[i]["assignees"].map(assignee => assignee["login"]); | |
predictedLabels = modelOutputs[i].recommended_components; | |
predictedAssignees = modelOutputs[i].recommended_developers; | |
resultString += `Issue Link: ${issues[i].html_url}\nTitle: ${issues[i].title}\n`; | |
resultString += `Actual Components: ${actualLabels.join(', ')}\nRecommended Components: ${predictedLabels.join(', ')}\n`; | |
resultString += `Actual Assignees: ${actualAssignees.join(', ')}\nRecommended Assignees: ${predictedAssignees.join(', ')}\n\n`; | |
} | |
await github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: resultString | |
}); |