From a615eba94bc4ffefd0b4271260da0e90a38418d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 27 Jul 2022 15:51:52 +0200 Subject: [PATCH] move PRs with conflict to TO REBASE column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: https://github.com/status-im/status-mobile/issues/13497 Signed-off-by: Jakub SokoĊ‚owski --- bot_scripts/assign-approved-pr-to-test.js | 23 ++++++++++++++++------- lib/github-helpers.js | 12 ++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bot_scripts/assign-approved-pr-to-test.js b/bot_scripts/assign-approved-pr-to-test.js index e638233..d181b16 100644 --- a/bot_scripts/assign-approved-pr-to-test.js +++ b/bot_scripts/assign-approved-pr-to-test.js @@ -55,6 +55,7 @@ async function checkOpenPullRequests (robot, context) { const testedPullRequestLabelName = projectBoardConfig['tested-pr-label-name'] const contributorColumnName = projectBoardConfig['contributor-column-name'] + const toRebaseColumnName = projectBoardConfig['to-rebase-column-name'] const reviewColumnName = projectBoardConfig['review-column-name'] const testColumnName = projectBoardConfig['test-column-name'] const minReviewers = projectBoardConfig['min-reviewers'] || 1 @@ -76,12 +77,20 @@ async function checkOpenPullRequests (robot, context) { } try { - const contributorColumn = findColumnByName(ghcolumns, contributorColumnName) - const reviewColumn = findColumnByName(ghcolumns, reviewColumnName) - const testColumn = findColumnByName(ghcolumns, testColumnName) - const columns = { contributor: contributorColumn, review: reviewColumn, test: testColumn } + const columns = { + contributor: findColumnByName(ghcolumns, contributorColumnName), + rebase: findColumnByName(ghcolumns, toRebaseColumnName), + review: findColumnByName(ghcolumns, reviewColumnName), + test: findColumnByName(ghcolumns, testColumnName), + } - robot.log.debug(`${botName} - Fetched ${contributorColumn.name} (${contributorColumn.id}), ${reviewColumn.name} (${reviewColumn.id}), ${testColumn.name} (${testColumn.id}) columns`) + robot.log.debug(` + ${botName} - Fetched columns: + ${columns.contributor.name} (${columns.contributor.id}) + ${columns.rebase.name} (${columns.rebase.id}) + ${columns.review.name} (${columns.review.id}) + ${columns.test.name} (${columns.test.id}) + `) try { // Gather all open PRs in this repo @@ -210,8 +219,8 @@ function getColumns (state, columns) { return { srcColumns: [columns.contributor, columns.test], dstColumn: columns.review } case 'changes_requested': return { srcColumns: [columns.review, columns.test], dstColumn: columns.contributor } - case 'failed': - return { srcColumns: [columns.review, columns.test], dstColumn: columns.contributor } + case 'needs_rebase': + return { srcColumns: [columns.contributor, columns.review, columns.test], dstColumn: columns.rebase } case 'approved': return { srcColumns: [columns.contributor, columns.review], dstColumn: columns.test } default: diff --git a/lib/github-helpers.js b/lib/github-helpers.js index 835def6..b7d473e 100644 --- a/lib/github-helpers.js +++ b/lib/github-helpers.js @@ -39,11 +39,11 @@ async function _getReviewApprovalState (context, robot, prInfo, minReviewers, te const { github } = context // Get detailed pull request - const pullRequestPayload = await github.pullRequests.get(prInfo) - const pullRequest = pullRequestPayload.data + const pullrequestPayload = await github.pullRequests.get(prInfo) + const pullRequest = pullrequestPayload.data context.payload.pull_request = pullRequest - if (pullRequest.mergeable !== null && pullRequest.mergeable !== undefined && !pullRequest.mergeable) { - robot.log.debug(`pullRequest.mergeable is ${pullRequest.mergeable}, considering as failed`) + if (pullRequest.mergeable === false && pullRequest.mergeable_state != 'dirty') { + robot.log.debug(`pullRequest #${prInfo.number} - pullRequest.mergeable is ${pullRequest.mergeable} and not dirty, considering as failed`) return 'failed' } @@ -54,11 +54,11 @@ async function _getReviewApprovalState (context, robot, prInfo, minReviewers, te robot.log.debug(`Pull request is labeled '${testedPullRequestLabelName}', ignoring`) return null } - state = 'approved' break case 'dirty': - state = 'failed' + robot.log.debug(`PR #${prInfo.number} - pullRequest.mergeable_state=${pullRequest.mergeable_state}, pullRequest.mergeable=${pullRequest.mergeable}`) + state = 'needs_rebase' break case 'unstable': if (filterIgnoredStatusContextFn) {