Skip to content

Commit 4cd5ced

Browse files
committed
Make unrolled commit message more descriptive
1 parent 727b532 commit 4cd5ced

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

site/src/github.rs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ pub async fn enqueue_unrolled_try_builds<'a>(
1818
client: client::Client,
1919
rollup_merges: impl Iterator<Item = &'a Commit>,
2020
previous_master: &str,
21-
) -> Result<Vec<(&'a Commit, String)>, String> {
21+
) -> Result<Vec<UnrolledCommit<'a>>, String> {
2222
let mut mapping = Vec::new();
2323
for rollup_merge in rollup_merges {
24+
// Grab the number of the rolled up PR from its commit message
25+
let original_pr_number = ROLLEDUP_PR_NUMBER
26+
.captures(&rollup_merge.message)
27+
.and_then(|c| c.get(1))
28+
.map(|m| m.as_str())
29+
.ok_or_else(|| {
30+
format!(
31+
"Could not get PR number from message: '{}'",
32+
rollup_merge.message
33+
)
34+
})?;
35+
2436
// Fetch the rollup merge commit which should have two parents.
2537
// The first parent is in the chain of rollup merge commits all the way back to `previous_master`.
2638
// The second parent is the head of the PR that was rolled up. We want the second parent.
@@ -45,7 +57,11 @@ pub async fn enqueue_unrolled_try_builds<'a>(
4557

4658
// Merge in the rolled up PR's head commit into the previous master
4759
let sha = client
48-
.merge_branch("perf-tmp", rolled_up_head, "merge")
60+
.merge_branch(
61+
"perf-tmp",
62+
rolled_up_head,
63+
&format!("Unrolled build for #{}", original_pr_number),
64+
)
4965
.await
5066
.map_err(|e| format!("Error merging commit into perf-tmp: {e:?}"))?;
5167

@@ -55,17 +71,33 @@ pub async fn enqueue_unrolled_try_builds<'a>(
5571
.await
5672
.map_err(|e| format!("Error updating the try-perf branch: {e:?}"))?;
5773

58-
mapping.push((rollup_merge, sha));
74+
mapping.push(UnrolledCommit {
75+
original_pr_number,
76+
rollup_merge,
77+
sha,
78+
});
5979
// Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
6080
tokio::time::sleep(std::time::Duration::from_secs(15)).await
6181
}
6282

6383
Ok(mapping)
6484
}
6585

86+
/// A commit representing a rolled up PR as if it had been merged into master directly
87+
pub struct UnrolledCommit<'a> {
88+
/// The PR number that was rolled up
89+
pub original_pr_number: &'a str,
90+
/// The original rollup merge commit
91+
pub rollup_merge: &'a Commit,
92+
/// The sha of the new unrolled merge commit
93+
pub sha: String,
94+
}
95+
6696
lazy_static::lazy_static! {
6797
static ref ROLLUP_PR_NUMBER: regex::Regex =
6898
regex::Regex::new(r#"^Auto merge of #(\d+)"#).unwrap();
99+
static ref ROLLEDUP_PR_NUMBER: regex::Regex =
100+
regex::Regex::new(r#"^Rollup merge of #(\d+)"#).unwrap();
69101
}
70102

71103
// Gets the pr number for the associated rollup PR message. Returns None if this is not a rollup PR

site/src/request_handlers/github.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ use std::sync::Arc;
99
use regex::Regex;
1010

1111
lazy_static::lazy_static! {
12-
static ref ROLLUP_PR_NUMBER: Regex =
13-
Regex::new(r#"^Auto merge of #(\d+)"#).unwrap();
14-
static ref ROLLEDUP_PR_NUMBER: Regex =
15-
Regex::new(r#"^Rollup merge of #(\d+)"#).unwrap();
1612
static ref BODY_TRY_COMMIT: Regex =
1713
Regex::new(r#"(?:\W|^)@rust-timer\s+build\s+(\w+)(?:\W|$)(?:include=(\S+))?\s*(?:exclude=(\S+))?\s*(?:runs=(\d+))?"#).unwrap();
1814
static ref BODY_QUEUE: Regex =
@@ -80,32 +76,20 @@ async fn handle_rollup_merge(
8076
.rev()
8177
.skip(1) // skip the head commit
8278
.take_while(|c| c.message.starts_with("Rollup merge of "));
83-
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master).await?;
84-
let mapping = mapping
79+
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master)
80+
.await?
8581
.into_iter()
86-
.map(|(rollup_merge, sha)| {
87-
ROLLEDUP_PR_NUMBER
88-
.captures(&rollup_merge.message)
89-
.and_then(|c| c.get(1))
90-
.map(|m| (m.as_str(), sha))
91-
.ok_or_else(|| {
92-
format!(
93-
"Could not get PR number from message: '{}'",
94-
rollup_merge.message
95-
)
96-
})
97-
})
98-
.fold(ServerResult::Ok(String::new()), |string, n| {
82+
.fold(String::new(), |mut string, c| {
9983
use std::fmt::Write;
100-
let (pr, commit) = n?;
101-
let mut string = string?;
10284
write!(
10385
&mut string,
104-
"|#{pr}|[{commit}](https://github.com/rust-lang-ci/rust/commit/{commit})|\n"
86+
"|#{pr}|[{commit}](https://github.com/rust-lang-ci/rust/commit/{commit})|\n",
87+
pr = c.original_pr_number,
88+
commit = c.sha
10589
)
10690
.unwrap();
107-
Ok(string)
108-
})?;
91+
string
92+
});
10993
let msg =
11094
format!("📌 Perf builds for each rolled up PR:\n\n\
11195
|PR# | Perf Build Sha|\n|----|-----|\n\

0 commit comments

Comments
 (0)