mirror of
https://github.com/status-im/status-github-bot.git
synced 2025-01-13 23:06:02 +00:00
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:
parent
c740507775
commit
a183bbfe88
@ -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)
|
||||
}
|
||||
|
@ -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':
|
||||
|
@ -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':
|
||||
|
Loading…
x
Reference in New Issue
Block a user