Skip to content

Add support for rust-timer merge bot and try-perf/perf-tmp branch protections #1828

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 2 commits into from
May 20, 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
32 changes: 24 additions & 8 deletions repos/rust-lang/rust.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ merge-bots = ["homu"]
pattern = "beta"
merge-bots = ["homu"]

[[branch-protections]]
pattern = "try"
merge-bots = ["homu"]

[[branch-protections]]
pattern = "auto"
merge-bots = ["homu"]

[[branch-protections]]
pattern = "*"
merge-bots = ["homu"]
Expand All @@ -65,3 +57,27 @@ pr-required = false
[[branch-protections]]
pattern = "automation/bors/try"
pr-required = false

# Required for running try builds created by homu.
# Must support force-pushes.
[[branch-protections]]
pattern = "try"
merge-bots = ["homu"]

# Required for running auto (merge) builds created by homu.
# Must support force-pushes.
[[branch-protections]]
pattern = "auto"
merge-bots = ["homu"]

# Required for unrolled PR builds created by perfbot.
# Must support force-pushes.
[[branch-protections]]
pattern = "try-perf"
merge-bots = ["rust-timer"]

# Required for unrolled PR builds created by perfbot.
# Must support force-pushes.
[[branch-protections]]
pattern = "perf-tmp"
merge-bots = ["rust-timer"]
1 change: 1 addition & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ pub enum BranchProtectionMode {
#[serde(rename_all = "snake_case")]
pub enum MergeBot {
Homu,
RustTimer,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down
1 change: 1 addition & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ pub(crate) enum RepoPermission {
#[serde(rename_all = "kebab-case")]
pub(crate) enum MergeBot {
Homu,
RustTimer,
}

#[derive(serde_derive::Deserialize, Debug)]
Expand Down
1 change: 1 addition & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl<'a> Generator<'a> {
.iter()
.map(|bot| match bot {
MergeBot::Homu => v1::MergeBot::Homu,
MergeBot::RustTimer => v1::MergeBot::RustTimer,
})
.collect(),
})
Expand Down
22 changes: 14 additions & 8 deletions sync-team/src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ pub fn construct_branch_protection(
expected_repo: &rust_team_data::v1::Repo,
branch_protection: &rust_team_data::v1::BranchProtection,
) -> api::BranchProtection {
let uses_homu = branch_protection.merge_bots.contains(&MergeBot::Homu);
// When homu manages a branch, we should not require a PR nor approvals
// for that branch, because homu pushes to these branches directly.
let branch_protection_mode = if uses_homu {
let uses_merge_bot = !branch_protection.merge_bots.is_empty();
// When a merge bot manages a branch, we should not require a PR nor approvals
// for that branch, because it will (force) push to these branches directly.
let branch_protection_mode = if uses_merge_bot {
BranchProtectionMode::PrNotRequired
} else {
branch_protection.mode.clone()
Expand All @@ -542,10 +542,16 @@ pub fn construct_branch_protection(
})
.collect();

if uses_homu {
push_allowances.push(PushAllowanceActor::User(api::UserPushAllowanceActor {
login: "bors".to_owned(),
}));
for merge_bot in &branch_protection.merge_bots {
let allowance = match merge_bot {
MergeBot::Homu => PushAllowanceActor::User(api::UserPushAllowanceActor {
login: "bors".to_owned(),
}),
MergeBot::RustTimer => PushAllowanceActor::User(api::UserPushAllowanceActor {
login: "rust-timer".to_owned(),
}),
};
push_allowances.push(allowance);
}

let mut checks = match &branch_protection_mode {
Expand Down