Skip to content

Commit 5a6a48d

Browse files
committed
Make the unrolling logic independent of the merge event
1 parent 4cd5ced commit 5a6a48d

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

site/src/github.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,40 @@ type BoxedError = Box<dyn std::error::Error + Send + Sync>;
1010

1111
pub use comparison_summary::post_finished;
1212

13+
/// Enqueues try build artifacts and posts a message about them on the original rollup PR
14+
pub async fn unroll_rollup(
15+
ci_client: client::Client,
16+
main_repo_client: client::Client,
17+
rollup_merges: impl Iterator<Item = &Commit>,
18+
previous_master: &str,
19+
rollup_pr_number: u32,
20+
) -> Result<(), String> {
21+
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master)
22+
.await?
23+
.into_iter()
24+
.fold(String::new(), |mut string, c| {
25+
use std::fmt::Write;
26+
write!(
27+
&mut string,
28+
"|#{pr}|[{commit}](https://github.com/rust-lang-ci/rust/commit/{commit})|\n",
29+
pr = c.original_pr_number,
30+
commit = c.sha
31+
)
32+
.unwrap();
33+
string
34+
});
35+
let msg =
36+
format!("📌 Perf builds for each rolled up PR:\n\n\
37+
|PR# | Perf Build Sha|\n|----|-----|\n\
38+
{mapping}\nIn the case of a perf regression, \
39+
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`");
40+
main_repo_client.post_comment(rollup_pr_number, msg).await;
41+
Ok(())
42+
}
43+
1344
/// Enqueues try builds on the try-perf branch for every rollup merge in `rollup_merges`.
1445
/// Returns a mapping between the rollup merge commit and the try build sha.
15-
///
16-
/// `rollup_merges` must only include actual rollup merge commits.
17-
pub async fn enqueue_unrolled_try_builds<'a>(
46+
async fn enqueue_unrolled_try_builds<'a>(
1847
client: client::Client,
1948
rollup_merges: impl Iterator<Item = &'a Commit>,
2049
previous_master: &str,

site/src/request_handlers/github.rs

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::api::{github, ServerResult};
2-
use crate::github::{
3-
client, enqueue_sha, enqueue_unrolled_try_builds, parse_homu_comment, rollup_pr_number,
4-
};
2+
use crate::github::{client, enqueue_sha, parse_homu_comment, rollup_pr_number, unroll_rollup};
53
use crate::load::SiteCtxt;
64

75
use std::sync::Arc;
@@ -50,10 +48,15 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
5048
// GitHub webhooks have a timeout of 10 seconds, so we process this
5149
// in the background.
5250
tokio::spawn(async move {
53-
let result = handle_rollup_merge(
51+
let rollup_merges = commits
52+
.iter()
53+
.rev()
54+
.skip(1) // skip the head commit
55+
.take_while(|c| c.message.starts_with("Rollup merge of "));
56+
let result = unroll_rollup(
5457
ci_client,
5558
main_repo_client,
56-
commits,
59+
rollup_merges,
5760
&previous_master,
5861
rollup_pr_number,
5962
)
@@ -63,42 +66,6 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
6366
Ok(github::Response)
6467
}
6568

66-
/// Handler for when a rollup has been merged
67-
async fn handle_rollup_merge(
68-
ci_client: client::Client,
69-
main_repo_client: client::Client,
70-
commits: Vec<github::Commit>,
71-
previous_master: &str,
72-
rollup_pr_number: u32,
73-
) -> Result<(), String> {
74-
let rollup_merges = commits
75-
.iter()
76-
.rev()
77-
.skip(1) // skip the head commit
78-
.take_while(|c| c.message.starts_with("Rollup merge of "));
79-
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master)
80-
.await?
81-
.into_iter()
82-
.fold(String::new(), |mut string, c| {
83-
use std::fmt::Write;
84-
write!(
85-
&mut string,
86-
"|#{pr}|[{commit}](https://github.com/rust-lang-ci/rust/commit/{commit})|\n",
87-
pr = c.original_pr_number,
88-
commit = c.sha
89-
)
90-
.unwrap();
91-
string
92-
});
93-
let msg =
94-
format!("📌 Perf builds for each rolled up PR:\n\n\
95-
|PR# | Perf Build Sha|\n|----|-----|\n\
96-
{mapping}\nIn the case of a perf regression, \
97-
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`");
98-
main_repo_client.post_comment(rollup_pr_number, msg).await;
99-
Ok(())
100-
}
101-
10269
async fn handle_issue(
10370
ctxt: Arc<SiteCtxt>,
10471
issue: github::Issue,

0 commit comments

Comments
 (0)