Skip to content

Commit 30e8d3b

Browse files
authored
Merge pull request #1828 from Kobzol/try-perf-rust
Add support for `rust-timer` merge bot and `try-perf`/`perf-tmp` branch protections
2 parents 7d3eac2 + 32b5201 commit 30e8d3b

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

repos/rust-lang/rust.toml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ merge-bots = ["homu"]
3838
pattern = "beta"
3939
merge-bots = ["homu"]
4040

41-
[[branch-protections]]
42-
pattern = "try"
43-
merge-bots = ["homu"]
44-
45-
[[branch-protections]]
46-
pattern = "auto"
47-
merge-bots = ["homu"]
48-
4941
[[branch-protections]]
5042
pattern = "*"
5143
merge-bots = ["homu"]
@@ -65,3 +57,27 @@ pr-required = false
6557
[[branch-protections]]
6658
pattern = "automation/bors/try"
6759
pr-required = false
60+
61+
# Required for running try builds created by homu.
62+
# Must support force-pushes.
63+
[[branch-protections]]
64+
pattern = "try"
65+
merge-bots = ["homu"]
66+
67+
# Required for running auto (merge) builds created by homu.
68+
# Must support force-pushes.
69+
[[branch-protections]]
70+
pattern = "auto"
71+
merge-bots = ["homu"]
72+
73+
# Required for unrolled PR builds created by perfbot.
74+
# Must support force-pushes.
75+
[[branch-protections]]
76+
pattern = "try-perf"
77+
merge-bots = ["rust-timer"]
78+
79+
# Required for unrolled PR builds created by perfbot.
80+
# Must support force-pushes.
81+
[[branch-protections]]
82+
pattern = "perf-tmp"
83+
merge-bots = ["rust-timer"]

rust_team_data/src/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ pub enum BranchProtectionMode {
246246
#[serde(rename_all = "snake_case")]
247247
pub enum MergeBot {
248248
Homu,
249+
RustTimer,
249250
}
250251

251252
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]

src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ pub(crate) enum RepoPermission {
870870
#[serde(rename_all = "kebab-case")]
871871
pub(crate) enum MergeBot {
872872
Homu,
873+
RustTimer,
873874
}
874875

875876
#[derive(serde_derive::Deserialize, Debug)]

src/static_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl<'a> Generator<'a> {
6666
.iter()
6767
.map(|bot| match bot {
6868
MergeBot::Homu => v1::MergeBot::Homu,
69+
MergeBot::RustTimer => v1::MergeBot::RustTimer,
6970
})
7071
.collect(),
7172
})

sync-team/src/github/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,10 @@ pub fn construct_branch_protection(
512512
expected_repo: &rust_team_data::v1::Repo,
513513
branch_protection: &rust_team_data::v1::BranchProtection,
514514
) -> api::BranchProtection {
515-
let uses_homu = branch_protection.merge_bots.contains(&MergeBot::Homu);
516-
// When homu manages a branch, we should not require a PR nor approvals
517-
// for that branch, because homu pushes to these branches directly.
518-
let branch_protection_mode = if uses_homu {
515+
let uses_merge_bot = !branch_protection.merge_bots.is_empty();
516+
// When a merge bot manages a branch, we should not require a PR nor approvals
517+
// for that branch, because it will (force) push to these branches directly.
518+
let branch_protection_mode = if uses_merge_bot {
519519
BranchProtectionMode::PrNotRequired
520520
} else {
521521
branch_protection.mode.clone()
@@ -542,10 +542,16 @@ pub fn construct_branch_protection(
542542
})
543543
.collect();
544544

545-
if uses_homu {
546-
push_allowances.push(PushAllowanceActor::User(api::UserPushAllowanceActor {
547-
login: "bors".to_owned(),
548-
}));
545+
for merge_bot in &branch_protection.merge_bots {
546+
let allowance = match merge_bot {
547+
MergeBot::Homu => PushAllowanceActor::User(api::UserPushAllowanceActor {
548+
login: "bors".to_owned(),
549+
}),
550+
MergeBot::RustTimer => PushAllowanceActor::User(api::UserPushAllowanceActor {
551+
login: "rust-timer".to_owned(),
552+
}),
553+
};
554+
push_allowances.push(allowance);
549555
}
550556

551557
let mut checks = match &branch_protection_mode {

0 commit comments

Comments
 (0)