Skip to content

Commit

Permalink
Review comments: check labels are component labels and other minor ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
raulcd committed Nov 29, 2022
1 parent 642eb6f commit 58820a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dev_pr/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function detectIssue(title) {
if (matched_jira) {
return {"kind": "jira", "id": matched_jira[2]};
}
const matched_gh = /^(WIP:?\s*)?(GH-)(\d+)/.exec(title);
const matched_gh = /^(WIP:?\s*)?GH-(\d+)/.exec(title);
if (matched_gh) {
return {"kind": "github", "id": matched_gh[3]};
return {"kind": "github", "id": matched_gh[2]};
}
return null;
}
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/dev_pr/issue_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,25 @@ async function assignGitHubIssue(github, context, pullRequestNumber, issueInfo)
*/
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 {
if (!issueInfo) {
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: ":x: GitHub issue #" + issueID + " could not be retrieved."
})
}
if (!issueInfo.assignees.length) {
await assignGitHubIssue(github, context, pullRequestNumber, issueInfo);
}
if(!issueInfo.labels.filter((label) => label.startsWith("Component:")).length) {
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: ":warning: GitHub issue #" + issueID + " **has no components**, please add labels for components."
})
}
}

module.exports = async ({github, context}) => {
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/dev_pr/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ async function haveComment(github, context, pullRequestNumber, message) {
* @param {String} jiraID
*/
async function commentJIRAURL(github, context, pullRequestNumber, jiraID) {
const issueInfo = await helpers.getJiraInfo(jiraID);
const jiraURL = `https://issues.apache.org/jira/browse/${jiraID}`;
if (await haveComment(github, context, pullRequestNumber, jiraURL)) {
return;
}
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: jiraURL
});
if (issueInfo){
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber,
body: jiraURL
});
}
}

/**
Expand Down

0 comments on commit 58820a2

Please sign in to comment.