forked from eclipse-openj9/openj9
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eclipse-openj9#19745 from Tigers-X/master
Add TriagerX workflows
- Loading branch information
Showing
4 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const axios = require('axios'); | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
|
||
async function run() { | ||
const sandboxIssueNumber = 19673; | ||
const sandboxOwner = 'eclipse-openj9'; | ||
const sandboxRepo = 'openj9'; | ||
|
||
const input = { | ||
issue_title: process.env.ISSUE_TITLE, | ||
issue_description: process.env.ISSUE_DESCRIPTION, | ||
}; | ||
|
||
const apiUrl = "http://140.211.168.122/recommendation"; | ||
const octokit = new github.getOctokit(process.env.GITHUB_TOKEN); | ||
|
||
try { | ||
const response = await axios.post(apiUrl, JSON.stringify(input), { | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
|
||
const issueComment = response.data; | ||
predictedAssignees = issueComment.recommended_developers; | ||
predictedLabels = issueComment.recommended_components; | ||
|
||
resultString += 'Status: Open\n'; | ||
resultString += `Recommended Components: ${predictedLabels.join(', ')}\n`; | ||
resultString += `Recommended Assignees: ${predictedAssignees.join(', ')}\n`; | ||
|
||
await octokit.rest.issues.createComment({ | ||
issue_number: sandboxIssueNumber, | ||
owner: sandboxOwner, | ||
repo: sandboxRepo, | ||
body: resultString | ||
}); | ||
} catch (error) { | ||
core.setFailed(`Action failed with error: ${error}`); | ||
await octokit.rest.issues.createComment({ | ||
issue_number: sandboxIssueNumber, | ||
owner: sandboxOwner, | ||
repo: sandboxRepo, | ||
body: `The TriagerX model is currently not responding to the issue ${issueNumber}. Please try again later.` | ||
}); | ||
} | ||
} | ||
run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Triager on Closed issues | ||
run-name: TriagerX for closed Issue | ||
|
||
on: | ||
issues: | ||
types: [closed] | ||
|
||
jobs: | ||
issue_closed: | ||
name: Issue Closed | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Commenting on the issue | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { data: issueData } = await github.issues.get({ | ||
issue_number: context.payload.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
const commentsUrl = issueData.comments_url; | ||
const { data: commentsData } = await github.request(commentsUrl); | ||
const sandboxIssueNumber = 19673; | ||
const sandboxOwner = context.repo.owner; | ||
const sandboxRepo = context.repo.repo; | ||
const actualLabels = issueData.labels.map(label => label['name']); | ||
let resultString = `Issue number: ${context.issue.number}\n`; | ||
resultString += 'Status: Closed\n'; | ||
if (actualLabels.length > 0) { | ||
resultString += `Actual components: ${actualLabels.join(', ')}\n`; | ||
} else { | ||
resultString += `Actual components: None :(\n`; | ||
} | ||
// Check if there is a closed/merged pull request associated with the issue | ||
// Check if the pull request has been merged | ||
let actualAssignees = []; | ||
const timeline = await github.issues.listEventsForTimeline({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}); | ||
let prAssignees = []; | ||
timeline.data.forEach(event => { | ||
if (event.event === 'cross-referenced' && event.source && event.source.issue.pull_request) { | ||
const pr = event.source.issue; | ||
if (pr.state === 'closed' || pr.merged === true) { | ||
prAssignees.push(pr.user.login); | ||
} | ||
} | ||
}); | ||
if (issueData.assignees.length != 0) { | ||
const assignees = issueData.assignees.map(assignee => assignee.login); | ||
actualAssignees.concat(assignees); | ||
} | ||
if (actualAssignees.length > 0) { | ||
resultString += `Actual assignees: ${actualAssignees.join(', ')}\n`; | ||
} else { | ||
resultString += `Actual assignees: No one :(\n`; | ||
} | ||
if (prAssignees.length > 0) { | ||
resultString += `PR assignees: ${prAssignees.join(', ')}`; | ||
} else { | ||
resultString += `PR assignees: No one :(`; | ||
} | ||
await github.issues.createComment({ | ||
issue_number: sandboxIssueNumber, | ||
owner: sandboxOwner, | ||
repo: sandboxRepo, | ||
body: resultString, | ||
body: resultString, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Triager on Opened issues | ||
run-name: Triage Opened Issue | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
issue_opened: | ||
name: Issue Opened | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: eclipse-openj9/openj9 | ||
ref: master | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: npm install [email protected] @actions/github @actions/core | ||
|
||
- name: Extract issue details | ||
id: extract_issue | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
core.setOutput('issue_title', context.payload.issue.title); | ||
core.setOutput('issue_description', context.payload.issue.body); | ||
core.setOutput('issue_number', context.issue.number.toString()); | ||
- name: Run recommendations | ||
run: node .github/recommendation.js | ||
env: | ||
ISSUE_TITLE: ${{ steps.extract_issue.outputs.issue_title }} | ||
ISSUE_DESCRIPTION: ${{ steps.extract_issue.outputs.issue_description }} | ||
ISSUE_NUMBER: ${{ steps.extract_issue.outputs.issue_number }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Run when "triagerx" is mentioned in an issue comment | ||
run-name: Triagerx Trigger | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
triagerx_trigger: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.event.comment.body, 'triagerx') | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: eclipse-openj9/openj9 | ||
ref: master | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Node Version | ||
run: node --version | ||
|
||
- name: Install dependencies | ||
run: npm install [email protected] @actions/github @actions/core | ||
|
||
- name: Extract issue details | ||
id: extract_issue | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const commentBody = context.payload.comment.body; | ||
const restCommentBody = commentBody.replace('triagerx', ''); | ||
let issueUrl = commentBody.includes('https') ? restCommentBody.trim() : context.payload.issue.html_url; | ||
let issueNumber = issueUrl.split('/').pop(); | ||
let issueOwner = issueUrl.split('/')[3]; | ||
let issueRepo = issueUrl.split('/')[4]; | ||
const { data: issueData } = await github.issues.get({ | ||
issue_number: issueNumber, | ||
owner: issueOwner, | ||
repo: issueRepo | ||
}); | ||
const issueTitle = issueData.title; | ||
const issueDescription = issueData.body; | ||
core.setOutput('issue_title', issueTitle); | ||
core.setOutput('issue_description', issueDescription); | ||
core.setOutput('issue_number', issueNumber); | ||
- name: Run recommendations | ||
run: node .github/recommendation.js | ||
env: | ||
ISSUE_TITLE: ${{ steps.extract_issue.outputs.issue_title }} | ||
ISSUE_DESCRIPTION: ${{ steps.extract_issue.outputs.issue_description }} | ||
ISSUE_NUMBER: ${{ steps.extract_issue.outputs.issue_number }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |