Improve bot so that it doesn't consider issue for IN TEST column if it is labeled as already tested

This commit is contained in:
Pedro Pombeiro 2018-03-14 14:06:59 +01:00
parent c740507775
commit a183bbfe88
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
3 changed files with 11 additions and 5 deletions

View File

@ -36,6 +36,7 @@ async function checkOpenPullRequests (robot, context) {
return
}
const testedPullRequestLabelName = projectBoardConfig['tested-pr-label-name']
const contributorColumnName = projectBoardConfig['contributor-column-name']
const reviewColumnName = projectBoardConfig['review-column-name']
const testColumnName = projectBoardConfig['test-column-name']
@ -74,7 +75,7 @@ async function checkOpenPullRequests (robot, context) {
for (const pullRequest of allPullRequests) {
try {
const columns = { contributor: contributorColumn, review: reviewColumn, test: testColumn }
await assignPullRequestToCorrectColumn(github, robot, repo, pullRequest, columns, config.slack.notification.room)
await assignPullRequestToCorrectColumn(github, robot, repo, pullRequest, columns, testedPullRequestLabelName, config.slack.notification.room)
} catch (err) {
robot.log.error(`${botName} - Unhandled exception while processing PR: ${err}`, repoInfo)
}
@ -87,12 +88,12 @@ async function checkOpenPullRequests (robot, context) {
}
}
async function assignPullRequestToCorrectColumn (github, robot, repo, pullRequest, columns, room) {
async function assignPullRequestToCorrectColumn (github, robot, repo, pullRequest, testedPullRequestLabelName, columns, room) {
const prInfo = { owner: repo.owner.login, repo: repo.name, number: pullRequest.number }
let state = null
try {
state = await gitHubHelpers.getReviewApprovalState(github, robot, prInfo)
state = await gitHubHelpers.getReviewApprovalState(github, robot, prInfo, testedPullRequestLabelName)
} catch (err) {
robot.log.error(`${botName} - Couldn't calculate the PR approval state: ${err}`, prInfo)
}

View File

@ -106,7 +106,7 @@ async function processPullRequest (github, robot, prInfo, fullJobName) {
pendingPullRequests.delete(prInfo.number)
try {
const state = await gitHubHelpers.getReviewApprovalState(github, robot, prInfo)
const state = await gitHubHelpers.getReviewApprovalState(github, robot, prInfo, null)
switch (state) {
case 'unstable':

View File

@ -34,7 +34,7 @@ async function _getPullRequestReviewStates (github, prInfo) {
return Array.from(finalReviewsMap.values())
}
async function _getReviewApprovalState (github, robot, prInfo) {
async function _getReviewApprovalState (github, robot, prInfo, testedPullRequestLabelName) {
// Get detailed pull request
const pullRequestPayload = await github.pullRequests.get(prInfo)
const pullRequest = pullRequestPayload.data
@ -46,6 +46,11 @@ async function _getReviewApprovalState (github, robot, prInfo) {
let state
switch (pullRequest.mergeable_state) {
case 'clean':
if (testedPullRequestLabelName !== null && pullRequest.labels.find(label => label.name === testedPullRequestLabelName)) {
robot.log.debug(`Pull request is labeled '${testedPullRequestLabelName}', ignoring`)
return null
}
state = 'approved'
break
case 'dirty':