Skip to content

Commit ffff7ad

Browse files
committed
Process successful auto builds before pending ones
1 parent 1f4c280 commit ffff7ad

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/bors/merge_queue.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub async fn handle_merge_queue(ctx: Arc<BorsContext>) -> anyhow::Result<()> {
5656
let prs = ctx.db.get_merge_queue_prs(repo_name, priority).await?;
5757

5858
// Sort PRs according to merge queue priority rules.
59-
// Pending PRs come first - this is important as we make sure to block the queue to
60-
// prevent starting simultaneous auto-builds.
59+
// Successful builds come first so they can be merged immediately,
60+
// then pending builds (which block the queue to prevent starting simultaneous auto-builds).
6161
let prs = sort_queue_prs(prs);
6262

6363
for pr in prs {
@@ -67,11 +67,6 @@ pub async fn handle_merge_queue(ctx: Arc<BorsContext>) -> anyhow::Result<()> {
6767
let commit_sha = CommitSha(auto_build.commit_sha.clone());
6868

6969
match auto_build.status {
70-
// Build in progress - stop queue. We can only have one PR built at a time.
71-
BuildStatus::Pending => {
72-
tracing::info!("PR {pr_num} has a pending build - blocking queue");
73-
break;
74-
}
7570
// Build successful - point the base branch to the merged commit.
7671
BuildStatus::Success => {
7772
match repo
@@ -140,6 +135,11 @@ pub async fn handle_merge_queue(ctx: Arc<BorsContext>) -> anyhow::Result<()> {
140135

141136
continue;
142137
}
138+
// Build in progress - stop queue. We can only have one PR built at a time.
139+
BuildStatus::Pending => {
140+
tracing::info!("PR {pr_num} has a pending build - blocking queue");
141+
break;
142+
}
143143
BuildStatus::Failure | BuildStatus::Cancelled | BuildStatus::Timeouted => {
144144
unreachable!("Failed auto builds should be filtered out by SQL query");
145145
}

src/utils/sort_queue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ pub fn sort_queue_prs(mut prs: Vec<PullRequestModel>) -> Vec<PullRequestModel> {
2929
fn get_status_priority(pr: &PullRequestModel) -> i32 {
3030
match &pr.auto_build {
3131
Some(build) => match build.status {
32-
BuildStatus::Pending => 1,
33-
BuildStatus::Success => 6,
32+
BuildStatus::Success => 1,
33+
BuildStatus::Pending => 2,
3434
BuildStatus::Failure => 5,
3535
BuildStatus::Cancelled | BuildStatus::Timeouted => 4,
3636
},
3737
None => {
3838
if pr.is_approved() {
39-
2 // approved but no build
39+
3 // approved but no build
4040
} else {
41-
3 // no status
41+
4 // no status
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)