mirror of
https://github.com/status-im/status-github-bot.git
synced 2025-01-13 23:06:02 +00:00
Do not consider PR in test if there is any review requesting changes
This commit is contained in:
parent
8e0298c830
commit
d4f5a453f8
@ -31,11 +31,14 @@ async function getReviewApprovalState(github, payload) {
|
|||||||
const ownerName = payload.repository.owner.login
|
const ownerName = payload.repository.owner.login
|
||||||
const repoName = payload.repository.name
|
const repoName = payload.repository.name
|
||||||
const prNumber = payload.pull_request.number
|
const prNumber = payload.pull_request.number
|
||||||
|
|
||||||
const ghreviews = await github.pullRequests.getReviews({owner: ownerName, repo: repoName, number: prNumber})
|
const ghreviews = await github.pullRequests.getReviews({owner: ownerName, repo: repoName, number: prNumber})
|
||||||
const approvedReviews = ghreviews.data.filter(review => review.state === 'APPROVED')
|
const approvedReviews = ghreviews.data.filter(review => review.state === 'APPROVED')
|
||||||
if (approvedReviews.length >= 2) {
|
if (approvedReviews.length >= 2) {
|
||||||
return 'approved'
|
const reviewsWithChangesRequested = ghreviews.data.filter(review => review.state === 'CHANGES_REQUESTED')
|
||||||
|
if (reviewsWithChangesRequested.length == 0) {
|
||||||
|
return 'approved'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'pending'
|
return 'pending'
|
||||||
@ -124,11 +127,11 @@ async function assignPullRequestToTest(context, robot) {
|
|||||||
robot.log.error(`Failed to retrieve project card for the PR, aborting: ${err}`, srcColumn.id, payload.pull_request.issue_url)
|
robot.log.error(`Failed to retrieve project card for the PR, aborting: ${err}`, srcColumn.id, payload.pull_request.issue_url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ghcard) {
|
if (ghcard) {
|
||||||
try {
|
try {
|
||||||
robot.log.trace(`Found card in source column ${ghcard.id}`, srcColumn.id)
|
robot.log.trace(`Found card in source column ${ghcard.id}`, srcColumn.id)
|
||||||
|
|
||||||
// Found in the source column, let's move it to the destination column
|
// Found in the source column, let's move it to the destination column
|
||||||
await github.projects.moveProjectCard({id: ghcard.id, position: 'bottom', column_id: dstColumn.id})
|
await github.projects.moveProjectCard({id: ghcard.id, position: 'bottom', column_id: dstColumn.id})
|
||||||
|
|
||||||
@ -140,7 +143,7 @@ async function assignPullRequestToTest(context, robot) {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
robot.log.debug(`Didn't find card in source column`, srcColumn.id)
|
robot.log.debug(`Didn't find card in source column`, srcColumn.id)
|
||||||
|
|
||||||
// It wasn't in source column, let's create a new card for it in the destination column
|
// It wasn't in source column, let's create a new card for it in the destination column
|
||||||
ghcard = await github.projects.createProjectCard({
|
ghcard = await github.projects.createProjectCard({
|
||||||
column_id: dstColumn.id,
|
column_id: dstColumn.id,
|
||||||
@ -154,7 +157,7 @@ async function assignPullRequestToTest(context, robot) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send message to Slack
|
// Send message to Slack
|
||||||
const slackHelper = require('../lib/slack')
|
const slackHelper = require('../lib/slack')
|
||||||
slackHelper.sendMessage(robot, slackClient, config.slack.notification.room, `Assigned PR to ${dstColumnName} in ${projectBoardName} project\n${payload.pull_request.html_url}`)
|
slackHelper.sendMessage(robot, slackClient, config.slack.notification.room, `Assigned PR to ${dstColumnName} in ${projectBoardName} project\n${payload.pull_request.html_url}`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user