Skip to content

Triager Tester in GitHub Actions #18

Triager Tester in GitHub Actions

Triager Tester in GitHub Actions #18

Workflow file for this run

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);
try {
const { data } = await github.issues.get({
owner,
repo,
issue_number
});
if (data.status != 404 && data.state === "closed" && data.assignee != null && data.labels.length != 0) {
issues.push(data);
closed_issues_collected++;
}
} catch (error) {
if (error.response && error.response.status == 404) {
console.log(`Issue #${issue_number} not found.`);
} else {
console.error(`An error occurred while getting issue #${issue_number}: ${error}`);
}
}
}
modelOutputs = [];
for (let i = 0; i < issues.length; i++) {
let issue = issues[i];
let input = {
"issue_title": issue["title"] != null ? issue["title"] : "",
"issue_description": issue["body"] != null ? 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
});