Skip to content

Merge queue #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2025
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.

2 changes: 2 additions & 0 deletions rust-bors.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ approve = ["+approved"]
try = ["+foo", "-bar"]
try_succeed = ["+foobar", "+foo", "+baz"]
try_failed = []
auto_build_succeeded = ["+foo", "+bar"]
auto_build_failed = ["+foo", "+bar"]

# Labels that will block approval when present on a PR
# (Optional)
Expand Down
30 changes: 30 additions & 0 deletions src/bors/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,33 @@ fn list_workflows_status(workflows: &[WorkflowModel]) -> String {
.collect::<Vec<_>>()
.join("\n")
}

pub fn auto_build_started_comment(head_sha: &CommitSha, merge_sha: &CommitSha) -> Comment {
Comment::new(format!(
":hourglass: Testing commit {} with merge {}...",
head_sha, merge_sha
))
}

pub fn auto_build_succeeded_comment(
workflows: &[WorkflowModel],
approved_by: &str,
merge_sha: &CommitSha,
base_ref: &str,
) -> Comment {
let urls = workflows
.iter()
.map(|w| format!("[{}]({})", w.name, w.url))
.collect::<Vec<_>>()
.join(", ");

Comment::new(format!(
":sunny: Test successful - {urls}\nApproved by: `{approved_by}`\nPushing {merge_sha} to `{base_ref}`...",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the raw string change got reverted here in the latest push? But I don't want to block this PR any further, it can be changed to a raw string again in some follow-up PR.

))
}

pub fn auto_build_push_failed_comment(error: &str) -> Comment {
Comment::new(format!(
":eyes: Test was successful, but fast-forwarding failed: {error}"
))
}
24 changes: 16 additions & 8 deletions src/bors/handlers/pr_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,18 +659,22 @@ mod tests {
#[sqlx::test]
async fn enqueue_prs_on_push_to_branch(pool: sqlx::PgPool) {
run_test(pool, async |tester| {
tester.open_pr(default_repo_name(), false).await?;
let pr = tester.open_pr(default_repo_name(), false).await?;
tester.push_to_branch(default_branch_name()).await?;
tester
.wait_for_default_pr(|pr| pr.mergeable_state == MergeableState::Unknown)
.wait_for_pr(default_repo_name(), pr.number.0, |pr| {
pr.mergeable_state == MergeableState::Unknown
})
.await?;
tester
.default_repo()
.lock()
.get_pr_mut(default_pr_number())
.get_pr_mut(pr.number.0)
.mergeable_state = OctocrabMergeableState::Dirty;
tester
.wait_for_default_pr(|pr| pr.mergeable_state == MergeableState::HasConflicts)
.wait_for_pr(default_repo_name(), pr.number.0, |pr| {
pr.mergeable_state == MergeableState::HasConflicts
})
.await?;
Ok(())
})
Expand All @@ -680,17 +684,21 @@ mod tests {
#[sqlx::test]
async fn enqueue_prs_on_pr_opened(pool: sqlx::PgPool) {
run_test(pool, async |tester| {
tester.open_pr(default_repo_name(), false).await?;
let pr = tester.open_pr(default_repo_name(), false).await?;
tester
.wait_for_default_pr(|pr| pr.mergeable_state == MergeableState::Unknown)
.wait_for_pr(default_repo_name(), pr.number.0, |pr| {
pr.mergeable_state == MergeableState::Unknown
})
.await?;
tester
.default_repo()
.lock()
.get_pr_mut(default_pr_number())
.get_pr_mut(pr.number.0)
.mergeable_state = OctocrabMergeableState::Dirty;
tester
.wait_for_default_pr(|pr| pr.mergeable_state == MergeableState::HasConflicts)
.wait_for_pr(default_repo_name(), pr.number.0, |pr| {
pr.mergeable_state == MergeableState::HasConflicts
})
.await?;
Ok(())
})
Expand Down
10 changes: 3 additions & 7 deletions src/bors/handlers/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,9 @@ mod tests {
gh.check_sha_history(
default_repo_name(),
TRY_MERGE_BRANCH_NAME,
&["main-sha1", "merge-main-sha1-pr-1-sha-0"],
);
gh.check_sha_history(
default_repo_name(),
TRY_BRANCH_NAME,
&["merge-main-sha1-pr-1-sha-0"],
&["main-sha1", "merge-0-pr-1"],
);
gh.check_sha_history(default_repo_name(), TRY_BRANCH_NAME, &["merge-0-pr-1"]);
}

#[sqlx::test]
Expand Down Expand Up @@ -1130,7 +1126,7 @@ mod tests {

tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand Down
51 changes: 24 additions & 27 deletions src/bors/handlers/trybuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ mod tests {
tester.get_comment().await?,
@r#"
:sunny: Try build successful ([Workflow1](https://github.com/workflows/Workflow1/1))
Build commit: merge-main-sha1-pr-1-sha-0 (`merge-main-sha1-pr-1-sha-0`, parent: `main-sha1`)
Build commit: merge-0-pr-1 (`merge-0-pr-1`, parent: `main-sha1`)

<!-- homu: {"type":"TryBuildCompleted","merge_sha":"merge-main-sha1-pr-1-sha-0"} -->
<!-- homu: {"type":"TryBuildCompleted","merge_sha":"merge-0-pr-1"} -->
"#
);
Ok(())
Expand Down Expand Up @@ -507,7 +507,7 @@ mod tests {
insta::assert_snapshot!(
tester.get_comment().await?,
@r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
"
Expand All @@ -524,7 +524,7 @@ mod tests {
insta::assert_snapshot!(
tester.get_comment().await?,
@r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
"
Expand Down Expand Up @@ -631,13 +631,9 @@ try-job: Bar
gh.check_sha_history(
default_repo_name(),
TRY_MERGE_BRANCH_NAME,
&["main-sha1", "merge-main-sha1-pr-1-sha-0"],
);
gh.check_sha_history(
default_repo_name(),
TRY_BRANCH_NAME,
&["merge-main-sha1-pr-1-sha-0"],
&["main-sha1", "merge-0-pr-1"],
);
gh.check_sha_history(default_repo_name(), TRY_BRANCH_NAME, &["merge-0-pr-1"]);
}

#[sqlx::test]
Expand All @@ -653,10 +649,7 @@ try-job: Bar
gh.check_sha_history(
default_repo_name(),
TRY_MERGE_BRANCH_NAME,
&[
"ea9c1b050cc8b420c2c211d2177811e564a4dc60",
"merge-ea9c1b050cc8b420c2c211d2177811e564a4dc60-pr-1-sha-0",
],
&["ea9c1b050cc8b420c2c211d2177811e564a4dc60", "merge-0-pr-1"],
);
}

Expand All @@ -671,7 +664,7 @@ try-job: Bar
tester.expect_comments(1).await;
tester.post_comment("@bors try parent=last").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-ea9c1b050cc8b420c2c211d2177811e564a4dc60-pr-1-sha-1…
:hourglass: Trying commit pr-1-sha with merge merge-1-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand All @@ -683,9 +676,9 @@ try-job: Bar
TRY_MERGE_BRANCH_NAME,
&[
"ea9c1b050cc8b420c2c211d2177811e564a4dc60",
"merge-ea9c1b050cc8b420c2c211d2177811e564a4dc60-pr-1-sha-0",
"merge-0-pr-1",
"ea9c1b050cc8b420c2c211d2177811e564a4dc60",
"merge-ea9c1b050cc8b420c2c211d2177811e564a4dc60-pr-1-sha-1",
"merge-1-pr-1",
],
);
}
Expand Down Expand Up @@ -773,7 +766,7 @@ try-job: Bar
tester.expect_comments(1).await;
tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-1…
:hourglass: Trying commit pr-1-sha with merge merge-1-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand All @@ -795,7 +788,7 @@ try-job: Bar
)
.await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand All @@ -816,7 +809,7 @@ try-job: Bar

tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-1…
:hourglass: Trying commit pr-1-sha with merge merge-1-pr-1…

(The previously running try build was automatically cancelled.)

Expand All @@ -840,18 +833,22 @@ try-job: Bar

tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-1…
:hourglass: Trying commit pr-1-sha with merge merge-1-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
tester
.workflow_full_success(WorkflowRunData::from(tester.try_branch()).with_run_id(2).with_check_suite_id(2))
.workflow_full_success(
WorkflowRunData::from(tester.try_branch())
.with_run_id(2)
.with_check_suite_id(2),
)
.await?;
insta::assert_snapshot!(tester.get_comment().await?, @r#"
:sunny: Try build successful ([Workflow1](https://github.com/workflows/Workflow1/2))
Build commit: merge-main-sha1-pr-1-sha-1 (`merge-main-sha1-pr-1-sha-1`, parent: `main-sha1`)
Build commit: merge-1-pr-1 (`merge-1-pr-1`, parent: `main-sha1`)

<!-- homu: {"type":"TryBuildCompleted","merge_sha":"merge-main-sha1-pr-1-sha-1"} -->
<!-- homu: {"type":"TryBuildCompleted","merge_sha":"merge-1-pr-1"} -->
"#);
Ok(())
})
Expand Down Expand Up @@ -988,7 +985,7 @@ try = ["+foo", "+bar", "-baz"]
.run_test(async |tester| {
tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand All @@ -1013,7 +1010,7 @@ try_succeed = ["+foo", "+bar", "-baz"]
.run_test(async |tester| {
tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand Down Expand Up @@ -1043,7 +1040,7 @@ try_failed = ["+foo", "+bar", "-baz"]
.run_test(async |tester| {
tester.post_comment("@bors try").await?;
insta::assert_snapshot!(tester.get_comment().await?, @r"
:hourglass: Trying commit pr-1-sha with merge merge-main-sha1-pr-1-sha-0
:hourglass: Trying commit pr-1-sha with merge merge-0-pr-1…

To cancel the try build, run the command `@bors try cancel`.
");
Expand Down
Loading