Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions src/bors/merge_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ async fn process_repository(repo: &RepositoryState, ctx: &BorsContext) -> anyhow
let pr_num = pr.number;

match pr.queue_status() {
QueueStatus::NotApproved => unreachable!(),
QueueStatus::Stalled(..) => unreachable!(),
QueueStatus::NotApproved => unreachable!(
"PR {pr:?} is not approved. It should not have been returned by `get_merge_queue_prs`, this is a bug."
),
QueueStatus::Stalled(..) => unreachable!(
"PR {pr:?} is stalled. It should not have been returned by `get_merge_queue_prs`, this is a bug."
),
QueueStatus::Pending(..) => {
// Build in progress - stop queue. We can only have one PR being built
// at a time.
Expand Down Expand Up @@ -1115,4 +1119,21 @@ auto_build_failed = ["+foo", "+bar", "-baz"]
})
.await;
}

#[sqlx::test]
async fn run_empty_queue(pool: sqlx::PgPool) {
run_test(pool, async |tester: &mut BorsTester| {
// This PR should not be in the queue
let pr = tester.open_pr(default_repo_name(), |_| {}).await?;
// Make sure that bors knows about the DB
tester
.post_comment(Comment::new(pr.id(), "@bors info"))
.await?;
tester.expect_comments(pr.id(), 1).await;

tester.process_merge_queue().await;
Ok(())
})
.await;
}
}
3 changes: 2 additions & 1 deletion src/database/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,14 @@ pub(crate) async fn get_merge_queue_prs(
AND pr.status = 'open'
AND pr.approved_by IS NOT NULL
AND pr.mergeable_state = 'mergeable'
AND
AND (
-- We ALWAYS need to return pending and successful PRs, regardless of tree state
auto_build.status IN ('pending', 'success') OR (
-- For PRs without a build status, we check if they pass the tree state
-- priority check, if the tree is closed
auto_build.status IS NULL AND ($2::int IS NULL OR pr.priority >= $2)
)
)
"#,
repo as &GithubRepoName,
tree_priority
Expand Down