mirror of https://github.com/rancher/dashboard.git
Revert changes to pr-gh-project, Neil will update this separately
This commit is contained in:
parent
27c90c0668
commit
11393c83e4
|
|
@ -9,7 +9,7 @@ const request = require('./request');
|
||||||
const TECH_DEBT_LABEL = 'kind/tech-debt';
|
const TECH_DEBT_LABEL = 'kind/tech-debt';
|
||||||
const DEV_VALIDATE_LABEL = 'status/dev-validate';
|
const DEV_VALIDATE_LABEL = 'status/dev-validate';
|
||||||
const QA_NONE_LABEL = 'QA/None';
|
const QA_NONE_LABEL = 'QA/None';
|
||||||
const QA_DEV_AUTOMATION_LABEL = 'QA/dev-automation';
|
const QA_DEV_AUTOMATION_LABEL = 'QA/dev-automation'
|
||||||
|
|
||||||
const GH_PRJ_TO_TEST = 'To Test';
|
const GH_PRJ_TO_TEST = 'To Test';
|
||||||
const GH_PRJ_QA_REVIEW = 'QA Review';
|
const GH_PRJ_QA_REVIEW = 'QA Review';
|
||||||
|
|
@ -54,17 +54,12 @@ function getReferencedIssues(body) {
|
||||||
const regexp = /[Ff]ix(es|ed)?\s*#([0-9]*)|[Cc]lose(s|d)?\s*#([0-9]*)|[Rr]esolve(s|d)?\s*#([0-9]*)/g;
|
const regexp = /[Ff]ix(es|ed)?\s*#([0-9]*)|[Cc]lose(s|d)?\s*#([0-9]*)|[Rr]esolve(s|d)?\s*#([0-9]*)/g;
|
||||||
var v;
|
var v;
|
||||||
const issues = [];
|
const issues = [];
|
||||||
try {
|
|
||||||
do {
|
do {
|
||||||
v = regexp.exec(body);
|
v = regexp.exec(body);
|
||||||
if (v) {
|
if (v) {
|
||||||
issues.push(parseInt(v[2], 10));
|
issues.push(parseInt(v[2], 10));
|
||||||
}
|
}
|
||||||
} while (v);
|
} while (v);
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to find referenced issues', err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,6 +111,7 @@ async function processClosedAction() {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('======');
|
console.log('======');
|
||||||
console.log('Processing Closed PR #' + pr.number + ' : ' + pr.title);
|
console.log('Processing Closed PR #' + pr.number + ' : ' + pr.title);
|
||||||
console.log('======');
|
console.log('======');
|
||||||
|
|
@ -137,7 +133,7 @@ async function processClosedAction() {
|
||||||
// Need to get all open PRs to see if any other references the same issues that this PR says it fixes
|
// Need to get all open PRs to see if any other references the same issues that this PR says it fixes
|
||||||
const openPRs = event.repository.url + '/pulls?state=open&per_page=100';
|
const openPRs = event.repository.url + '/pulls?state=open&per_page=100';
|
||||||
const r = await request.fetch(openPRs);
|
const r = await request.fetch(openPRs);
|
||||||
const issueMap = issues.reduce((prev, issue) => { prev[issue] = true; return prev; }, {});
|
const issueMap = issues.reduce((prev, issue) => { prev[issue] = true; return prev; }, {})
|
||||||
|
|
||||||
// Go through all of the Open PRs and see if they fix any of the same issues that this PR does
|
// Go through all of the Open PRs and see if they fix any of the same issues that this PR does
|
||||||
// If not, then the issue has been completed, so we can process it
|
// If not, then the issue has been completed, so we can process it
|
||||||
|
|
@ -162,7 +158,7 @@ async function processClosedAction() {
|
||||||
fixed.forEach(async (i) => {
|
fixed.forEach(async (i) => {
|
||||||
const detail = event.repository.url + '/issues/' + i;
|
const detail = event.repository.url + '/issues/' + i;
|
||||||
const iss = await request.fetch(detail);
|
const iss = await request.fetch(detail);
|
||||||
console.log('');
|
console.log('')
|
||||||
console.log('Processing Issue #' + i + ' - ' + iss.title);
|
console.log('Processing Issue #' + i + ' - ' + iss.title);
|
||||||
|
|
||||||
// If the issue is a tech debt issue or says dev will validate then don't move it to 'To Test'
|
// If the issue is a tech debt issue or says dev will validate then don't move it to 'To Test'
|
||||||
|
|
@ -187,7 +183,7 @@ async function processClosedAction() {
|
||||||
// Is the issue on the board?
|
// Is the issue on the board?
|
||||||
if (!prjIssue?.[ghProject.id]) {
|
if (!prjIssue?.[ghProject.id]) {
|
||||||
// Issue is not on the board
|
// Issue is not on the board
|
||||||
console.log(`Issue ${i} is NOT on the project board - adding it ...`);
|
console.log(`Issue ${ i } is NOT on the project board - adding it ...`);
|
||||||
|
|
||||||
await request.ghAddIssueToProject(ghProject, iss);
|
await request.ghAddIssueToProject(ghProject, iss);
|
||||||
|
|
||||||
|
|
@ -267,12 +263,7 @@ async function processOpenOrEditAction() {
|
||||||
for (i of issues) {
|
for (i of issues) {
|
||||||
const detail = `${event.repository.url}/issues/${i}`;
|
const detail = `${event.repository.url}/issues/${i}`;
|
||||||
const iss = await request.fetch(detail);
|
const iss = await request.fetch(detail);
|
||||||
|
console.log('')
|
||||||
if (!iss) {
|
|
||||||
console.log(`Failed to find issue with number '${i}'. Body: :`, iss);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
console.log('');
|
|
||||||
console.log('Processing Issue #' + i + ' - ' + iss.title);
|
console.log('Processing Issue #' + i + ' - ' + iss.title);
|
||||||
|
|
||||||
if (pr.draft) {
|
if (pr.draft) {
|
||||||
|
|
@ -288,7 +279,7 @@ async function processOpenOrEditAction() {
|
||||||
// Is the issue on the board?
|
// Is the issue on the board?
|
||||||
if (!prjIssue?.[ghProject.id]) {
|
if (!prjIssue?.[ghProject.id]) {
|
||||||
// Issue is not on the board
|
// Issue is not on the board
|
||||||
console.log(`Issue ${i} is NOT on the project board - adding it ...`);
|
console.log(`Issue ${ i } is NOT on the project board - adding it ...`);
|
||||||
|
|
||||||
await request.ghAddIssueToProject(ghProject, iss);
|
await request.ghAddIssueToProject(ghProject, iss);
|
||||||
|
|
||||||
|
|
@ -307,11 +298,11 @@ async function processOpenOrEditAction() {
|
||||||
await moveIssueToProjectState(ghProject, prjIssue[ghProject.id], iss, GH_PRJ_IN_REVIEW);
|
await moveIssueToProjectState(ghProject, prjIssue[ghProject.id], iss, GH_PRJ_IN_REVIEW);
|
||||||
await removeZubeLabels(iss);
|
await removeZubeLabels(iss);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Can not move issue to state ${GH_PRJ_IN_REVIEW} - issue is not on the board`);
|
console.log(`Can not move issue to state ${ GH_PRJ_IN_REVIEW } - issue is not on the board`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iss?.milestone) {
|
if (iss.milestone) {
|
||||||
milestones[iss.milestone.title] = iss.milestone.number;
|
milestones[iss.milestone.title] = iss.milestone.number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue