Skip to content

Commit 67ee920

Browse files
authored
Merge pull request #437 from Kobzol/fix-query
Fix merge queue PR query
2 parents 3eb84da + 724fb5f commit 67ee920

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

.sqlx/query-92d160378de8ed75192f25e393d1eceee06cd95b22cc6efe813e5d1c9812ee14.json renamed to .sqlx/query-5c3c81357e7329a9db4b2bf05c2615433b4a61c43f26f2ae39e68d02d609bf90.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bors/merge_queue.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ async fn process_repository(repo: &RepositoryState, ctx: &BorsContext) -> anyhow
134134
let pr_num = pr.number;
135135

136136
match pr.queue_status() {
137-
QueueStatus::NotApproved => unreachable!(),
138-
QueueStatus::Stalled(..) => unreachable!(),
137+
QueueStatus::NotApproved => unreachable!(
138+
"PR {pr:?} is not approved. It should not have been returned by `get_merge_queue_prs`, this is a bug."
139+
),
140+
QueueStatus::Stalled(..) => unreachable!(
141+
"PR {pr:?} is stalled. It should not have been returned by `get_merge_queue_prs`, this is a bug."
142+
),
139143
QueueStatus::Pending(..) => {
140144
// Build in progress - stop queue. We can only have one PR being built
141145
// at a time.
@@ -1115,4 +1119,21 @@ auto_build_failed = ["+foo", "+bar", "-baz"]
11151119
})
11161120
.await;
11171121
}
1122+
1123+
#[sqlx::test]
1124+
async fn run_empty_queue(pool: sqlx::PgPool) {
1125+
run_test(pool, async |tester: &mut BorsTester| {
1126+
// This PR should not be in the queue
1127+
let pr = tester.open_pr(default_repo_name(), |_| {}).await?;
1128+
// Make sure that bors knows about the DB
1129+
tester
1130+
.post_comment(Comment::new(pr.id(), "@bors info"))
1131+
.await?;
1132+
tester.expect_comments(pr.id(), 1).await;
1133+
1134+
tester.process_merge_queue().await;
1135+
Ok(())
1136+
})
1137+
.await;
1138+
}
11181139
}

src/database/operations.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,14 @@ pub(crate) async fn get_merge_queue_prs(
10071007
AND pr.status = 'open'
10081008
AND pr.approved_by IS NOT NULL
10091009
AND pr.mergeable_state = 'mergeable'
1010-
AND
1010+
AND (
10111011
-- We ALWAYS need to return pending and successful PRs, regardless of tree state
10121012
auto_build.status IN ('pending', 'success') OR (
10131013
-- For PRs without a build status, we check if they pass the tree state
10141014
-- priority check, if the tree is closed
10151015
auto_build.status IS NULL AND ($2::int IS NULL OR pr.priority >= $2)
10161016
)
1017+
)
10171018
"#,
10181019
repo as &GithubRepoName,
10191020
tree_priority

0 commit comments

Comments
 (0)