Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dev_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/title_check.js`);
script({github, context});

- name: Check Jira Issue
- name: Check Issue
if: |
(github.event.action == 'opened' ||
github.event.action == 'edited')
Expand All @@ -75,7 +75,7 @@ jobs:
debug: true
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/jira_check.js`);
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/issue_check.js`);
script({github, context});

- name: Assign GitHub labels
Expand Down
42 changes: 36 additions & 6 deletions .github/workflows/dev_pr/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
const https = require('https');

/**
* Given the title of a PullRequest return the ID of the JIRA issue
* Given the title of a PullRequest return the ID of the JIRA or GitHub issue
* @param {String} title
* @returns {String} the ID of the associated JIRA issue
* @returns {String} the ID of the associated JIRA or GitHub issue
*/
function detectJIRAID(title) {
function detectIssueID(title) {
if (!title) {
return null;
}
const matched = /^(WIP:?\s*)?((ARROW|PARQUET)-\d+)/.exec(title);
const matched = /^(WIP:?\s*)?((ARROW|PARQUET|GH)-\d+)/.exec(title);
if (!matched) {
return null;
}
Expand Down Expand Up @@ -69,8 +69,38 @@ async function getJiraInfo(jiraID) {
});
}

/**
* Retrieves information about a GitHub issue.
* @param {String} issueID
* @returns {Object} the information about a GitHub issue.
*/
async function getGitHubInfo(github, issueID, context) {
// TODO
return github.rest.issues.get({
issue_number: issueID,
owner: context.repo.owner,
repo: context.repo.repo,
})
}

/**
* Given the title of a PullRequest checks if it contains a GitHub issue ID
* @param {String} title
* @returns {Boolean} true if title starts with a GitHub ID or MINOR:
*/
function haveGitHubIssueID(title) {
if (!title) {
return false;
}
if (title.startsWith("MINOR: ")) {
return true;
}
return /^(WIP:?\s*)?(GH)-\d+/.test(title);
}

module.exports = {
detectJIRAID,
detectIssueID,
haveJIRAID,
getJiraInfo
getJiraInfo,
haveGitHubIssueID
};
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,36 @@ async function commentNotStartedTicket(github, context, pullRequestNumber) {
}
}

async function verifyGitHubIssue(github, context, pullRequestNumber, issueID) {
const issue = await github.rest.issues.get({
issue_number: issueID,
owner: context.repo.owner,
repo: context.repo.repo,
})
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: ":warning: Ticket **has not been started in JIRA**, please click 'Start Progress'." + issue
})
//if(!ticketInfo["fields"]["components"].length) {
// await commentMissingComponents(github, context, pullRequestNumber);
//}

//if(ticketInfo["fields"]["status"]["id"] == 1) {
// // "status": {"name":"Open","id":"1"
// // "description":"The issue is open and ready for the assignee to start work on it.",
// await commentNotStartedTicket(github, context, pullRequestNumber);
//}
}

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 issueID = helpers.detectIssueID(title)
if (helpers.haveJIRAID(title)) {
await verifyJIRAIssue(github, context, pullRequestNumber, issueID);
} else if(helpers.haveGitHubIssueID(title)) {
await verifyGitHubIssue(github, context, pullRequestNumber, issueID);
}
};
6 changes: 3 additions & 3 deletions .github/workflows/dev_pr/title_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const fs = require("fs");
const helpers = require("./helpers.js");

async function commentOpenJIRAIssue(github, context, pullRequestNumber) {
async function commentOpenGitHubIssue(github, context, pullRequestNumber) {
const {data: comments} = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -41,7 +41,7 @@ async function commentOpenJIRAIssue(github, context, pullRequestNumber) {
module.exports = async ({github, context}) => {
const pullRequestNumber = context.payload.number;
const title = context.payload.pull_request.title;
if (!helpers.haveJIRAID(title)) {
await commentOpenJIRAIssue(github, context, pullRequestNumber);
if (!helpers.haveJIRAID(title) || !helpers.haveGitHubIssueID(title)) {
await commentOpenGitHubIssue(github, context, pullRequestNumber);
}
};
12 changes: 8 additions & 4 deletions .github/workflows/dev_pr/title_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@

Thanks for opening a pull request!

If this is not a [minor PR](https://github.com/apache/arrow/blob/master/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on JIRA? https://issues.apache.org/jira/browse/ARROW
If this is not a [minor PR](https://github.com/apache/arrow/blob/master/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening JIRAs ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.

Then could you also rename pull request title in the following format?
Then could you also rename the pull request title in the following format?

ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

In the case of old issues on JIRA the title also supports:

JIRA-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

See also:

* [Other pull requests](https://github.com/apache/arrow/pulls/)
Expand Down