From afcdb932302dfecf1228eb77a622d1d6867f36e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 20 May 2025 11:05:55 +0200 Subject: [PATCH 1/2] Add support for rust-timer bot It merges unrolled rollup builds into the `try-perf` and `perf-tmp` branches on `rust-lang-ci/rust`. --- rust_team_data/src/v1.rs | 1 + src/schema.rs | 1 + src/static_api.rs | 1 + sync-team/src/github/mod.rs | 22 ++++++++++++++-------- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/rust_team_data/src/v1.rs b/rust_team_data/src/v1.rs index 603e3233d..0ee7b3b91 100644 --- a/rust_team_data/src/v1.rs +++ b/rust_team_data/src/v1.rs @@ -246,6 +246,7 @@ pub enum BranchProtectionMode { #[serde(rename_all = "snake_case")] pub enum MergeBot { Homu, + RustTimer, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] diff --git a/src/schema.rs b/src/schema.rs index 948df2c94..601ca2218 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -870,6 +870,7 @@ pub(crate) enum RepoPermission { #[serde(rename_all = "kebab-case")] pub(crate) enum MergeBot { Homu, + RustTimer, } #[derive(serde_derive::Deserialize, Debug)] diff --git a/src/static_api.rs b/src/static_api.rs index 1a704b21c..b9da097b8 100644 --- a/src/static_api.rs +++ b/src/static_api.rs @@ -66,6 +66,7 @@ impl<'a> Generator<'a> { .iter() .map(|bot| match bot { MergeBot::Homu => v1::MergeBot::Homu, + MergeBot::RustTimer => v1::MergeBot::RustTimer, }) .collect(), }) diff --git a/sync-team/src/github/mod.rs b/sync-team/src/github/mod.rs index 65264997c..3f563e621 100644 --- a/sync-team/src/github/mod.rs +++ b/sync-team/src/github/mod.rs @@ -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() @@ -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 { From 32b5201142f0a13c34e5570a8a5e62fe38a59eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 20 May 2025 11:06:25 +0200 Subject: [PATCH 2/2] Add `try-perf` and `perf-tmp` branch protections to `rust-lang/rust` --- repos/rust-lang/rust.toml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/repos/rust-lang/rust.toml b/repos/rust-lang/rust.toml index 2c9f2554b..08c1c32d5 100644 --- a/repos/rust-lang/rust.toml +++ b/repos/rust-lang/rust.toml @@ -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"] @@ -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"]