-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-18380: [Dev] Update dev_pr GitHub workflows to accept both GitHub issues and JIRA #14731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
ffc409f
a0ef031
8c27c9d
6d7dadb
4cc26eb
fe9eb51
3a36abf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,16 @@ | |
|
|
||
| const helpers = require("./helpers.js"); | ||
|
|
||
| /** | ||
| * Performs checks on the JIRA Issue: | ||
| * - The issue is started in JIRA. | ||
| * - The issue contains components. | ||
| * | ||
| * @param {Object} github | ||
| * @param {Object} context | ||
| * @param {String} pullRequestNumber | ||
| * @param {String} jiraID | ||
| */ | ||
| async function verifyJIRAIssue(github, context, pullRequestNumber, jiraID) { | ||
| const ticketInfo = await helpers.getJiraInfo(jiraID); | ||
| if(!ticketInfo["fields"]["components"].length) { | ||
|
|
@@ -30,6 +40,13 @@ async function verifyJIRAIssue(github, context, pullRequestNumber, jiraID) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Adds a comment to add components on the JIRA ticket. | ||
| * | ||
| * @param {Object} github | ||
| * @param {Object} context | ||
| * @param {String} pullRequestNumber | ||
| */ | ||
| async function commentMissingComponents(github, context, pullRequestNumber) { | ||
| const {data: comments} = await github.issues.listComments({ | ||
| owner: context.repo.owner, | ||
|
|
@@ -54,6 +71,13 @@ async function commentMissingComponents(github, context, pullRequestNumber) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Adds a comment to start the ticket in JIRA. | ||
| * | ||
| * @param {Object} github | ||
| * @param {Object} context | ||
| * @param {String} pullRequestNumber | ||
| */ | ||
| async function commentNotStartedTicket(github, context, pullRequestNumber) { | ||
| const {data: comments} = await github.issues.listComments({ | ||
| owner: context.repo.owner, | ||
|
|
@@ -78,11 +102,73 @@ async function commentNotStartedTicket(github, context, pullRequestNumber) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Assigns the Github Issue to the PR creator. | ||
| * | ||
| * @param {Object} github | ||
| * @param {Object} context | ||
| * @param {String} pullRequestNumber | ||
| * @param {Object} issueInfo | ||
| */ | ||
| async function assignGitHubIssue(github, context, pullRequestNumber, issueInfo) { | ||
| await github.issues.addAssignees({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issueInfo.number, | ||
| assignees: context.payload.pull_request.user.login | ||
| }); | ||
| await github.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequestNumber, | ||
| body: ":warning: GitHub issue #" + issueInfo.number + " **has been automatically assigned in GitHub** to PR creator." | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Performs checks on the GitHub Issue: | ||
| * - The issue is assigned to someone. If not assign it gets automatically | ||
| * assigned to the PR creator. | ||
| * - The issue contains any label. | ||
| * | ||
| * @param {Object} github | ||
| * @param {Object} context | ||
| * @param {String} pullRequestNumber | ||
| * @param {String} issueID | ||
| */ | ||
| async function verifyGitHubIssue(github, context, pullRequestNumber, issueID) { | ||
| const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber); | ||
| if (issueInfo) { | ||
| if (!issueInfo.assignees.length) { | ||
| await assignGitHubIssue(github, context, pullRequestNumber, issueInfo); | ||
| } | ||
| if(!issueInfo.labels.length) { | ||
|
||
| await github.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequestNumber, | ||
| body: ":warning: GitHub issue #" + issueID + " **has no labels in GitHub**, please add labels for components." | ||
| }) | ||
| } | ||
| } else { | ||
| await github.issues.createComment({ | ||
raulcd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequestNumber, | ||
| body: ":x: GitHub issue #" + issueID + " could not be retrieved." | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| module.exports = async ({github, context}) => { | ||
| const pullRequestNumber = context.payload.number; | ||
| const title = context.payload.pull_request.title; | ||
| const jiraID = helpers.detectJIRAID(title); | ||
| if (jiraID) { | ||
| await verifyJIRAIssue(github, context, pullRequestNumber, jiraID); | ||
| const issue = helpers.detectIssue(title) | ||
| if (issue){ | ||
| if (issue.kind == "jira") { | ||
| await verifyJIRAIssue(github, context, pullRequestNumber, issue.id); | ||
| } else if(issue.kind == "github") { | ||
| await verifyGitHubIssue(github, context, pullRequestNumber, issue.id); | ||
| } | ||
| } | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.