Make minimum number of approvers configurable
This commit is contained in:
parent
823d4d3298
commit
6d63663d11
|
@ -57,6 +57,7 @@ async function checkOpenPullRequests (robot, context) {
|
|||
const contributorColumnName = projectBoardConfig['contributor-column-name']
|
||||
const reviewColumnName = projectBoardConfig['review-column-name']
|
||||
const testColumnName = projectBoardConfig['test-column-name']
|
||||
const minReviewers = projectBoardConfig['min-reviewers'] || 1
|
||||
|
||||
// Find 'Pipeline for QA' project
|
||||
const project = await gitHubHelpers.getRepoProjectByName(github, robot, repoInfo, projectBoardConfig.name, botName)
|
||||
|
@ -92,7 +93,7 @@ async function checkOpenPullRequests (robot, context) {
|
|||
// And make sure they are assigned to the correct project column
|
||||
for (const pullRequest of allPullRequests) {
|
||||
try {
|
||||
await assignPullRequestToCorrectColumn(context, robot, repo, pullRequest, testedPullRequestLabelName, columns, config.slack.notification.room)
|
||||
await assignPullRequestToCorrectColumn(context, robot, repo, pullRequest, minReviewers, testedPullRequestLabelName, columns, config.slack.notification.room)
|
||||
} catch (err) {
|
||||
robot.log.error(`${botName} - Unhandled exception while processing PR: ${err}`, repoInfo)
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ async function checkOpenPullRequests (robot, context) {
|
|||
}
|
||||
}
|
||||
|
||||
async function assignPullRequestToCorrectColumn (context, robot, repo, pullRequest, testedPullRequestLabelName, columns, room) {
|
||||
async function assignPullRequestToCorrectColumn (context, robot, repo, pullRequest, minReviewers, testedPullRequestLabelName, columns, room) {
|
||||
const { github } = context
|
||||
const prInfo = { owner: repo.owner.login, repo: repo.name, number: pullRequest.number }
|
||||
|
||||
|
@ -116,7 +117,7 @@ async function assignPullRequestToCorrectColumn (context, robot, repo, pullReque
|
|||
status.creator &&
|
||||
(status.creator.login === 'status-github-bot[bot]' || status.creator.login === 'e2e-tests-check-bot[bot]'))
|
||||
|
||||
state = await gitHubHelpers.getReviewApprovalState(context, robot, prInfo, testedPullRequestLabelName, filterFn)
|
||||
state = await gitHubHelpers.getReviewApprovalState(context, robot, prInfo, minReviewers, testedPullRequestLabelName, filterFn)
|
||||
} catch (err) {
|
||||
robot.log.error(`${botName} - Couldn't calculate the PR approval state: ${err}`, prInfo)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ async function _getPullRequestReviewStates (github, prInfo) {
|
|||
return Array.from(finalReviewsMap.values())
|
||||
}
|
||||
|
||||
async function _getReviewApprovalState (context, robot, prInfo, testedPullRequestLabelName, filterIgnoredStatusContextFn) {
|
||||
async function _getReviewApprovalState (context, robot, prInfo, minReviewers, testedPullRequestLabelName, filterIgnoredStatusContextFn) {
|
||||
const { github } = context
|
||||
|
||||
// Get detailed pull request
|
||||
|
@ -76,7 +76,7 @@ async function _getReviewApprovalState (context, robot, prInfo, testedPullReques
|
|||
return state
|
||||
}
|
||||
|
||||
const threshold = 2 // Minimum number of approvers
|
||||
const threshold = minReviewers // Minimum number of approvers
|
||||
|
||||
const finalReviews = await _getPullRequestReviewStates(github, prInfo)
|
||||
robot.log.debug(finalReviews)
|
||||
|
|
Loading…
Reference in New Issue