Skip to content

Commit 8835ef0

Browse files
authored
Merge pull request #1623 from Kobzol/rollup-table
Improve PR rollup table formatting
2 parents 807f108 + 64a8b4a commit 8835ef0

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

site/src/github.rs

+40-7
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,63 @@ pub async fn unroll_rollup(
2929
previous_master: &str,
3030
rollup_pr_number: u32,
3131
) -> Result<(), String> {
32+
let commit_link = |sha: &str| format!("https://github.com/rust-lang-ci/rust/commit/{sha}");
33+
3234
let format_commit = |s: &str, truncate: bool| {
3335
let display = truncate.then(|| s.split_at(10).0).unwrap_or(s);
34-
format!("[{display}](https://github.com/rust-lang-ci/rust/commit/{s})")
36+
format!("[{display}]({})", commit_link(s))
3537
};
36-
let mapping = enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master)
37-
.await?
38+
39+
// Sort rolled up commits by their PR number in ascending order, so that they have the
40+
// same ordering as in the rollup PR description.
41+
let mut unrolled_builds: Vec<UnrolledCommit> =
42+
enqueue_unrolled_try_builds(ci_client, rollup_merges, previous_master).await?;
43+
// The number should really be an integer, but if not, we will just sort the "non-integer" PRs
44+
// first.
45+
unrolled_builds.sort_by_cached_key(|commit| commit.original_pr_number.parse::<u64>().ok());
46+
47+
let mapping = unrolled_builds
3848
.into_iter()
3949
.fold(String::new(), |mut string, c| {
4050
use std::fmt::Write;
4151
let commit = c
4252
.sha
4353
.as_deref()
44-
.map(|s| format_commit(s, false))
54+
.map(|s| {
55+
// Format the SHA as a code block to make it easy to copy-paste verbatim
56+
let link = commit_link(s);
57+
format!("`{s}` ([link]({link}))")
58+
})
4559
.unwrap_or_else(|| {
4660
let head = format_commit(&c.rolled_up_head, true);
4761
format!("❌ conflicts merging '{head}' into previous master ❌")
4862
});
49-
writeln!(&mut string, "|#{pr}|{commit}|", pr = c.original_pr_number).unwrap();
63+
let message = c
64+
.rollup_merge
65+
.message
66+
.split('\n')
67+
// Skip over "Rollup merge of ..." and an empty line
68+
.nth(2)
69+
.map(|m| {
70+
if m.len() <= 60 {
71+
m.to_string()
72+
} else {
73+
format!("{}…", m.split_at(59).0)
74+
}
75+
})
76+
.unwrap_or_else(|| format!("#{}", c.original_pr_number));
77+
writeln!(
78+
&mut string,
79+
"|#{pr}|{message}|{commit}|",
80+
pr = c.original_pr_number
81+
)
82+
.unwrap();
5083
string
5184
});
5285
let previous_master = format_commit(previous_master, true);
5386
let msg =
5487
format!("📌 Perf builds for each rolled up PR:\n\n\
55-
|PR# | Perf Build Sha|\n|----|:-----:|\n\
88+
|PR# | Message | Perf Build Sha|\n|----|:-----:|\n\
5689
{mapping}\n\n*previous master*: {previous_master}\n\nIn the case of a perf regression, \
5790
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`\n\
5891
{COMMENT_MARK_ROLLUP}");
@@ -108,7 +141,7 @@ async fn enqueue_unrolled_try_builds<'a>(
108141
.merge_branch(
109142
"perf-tmp",
110143
&rolled_up_head,
111-
&format!("Unrolled build for #{original_pr_number}"),
144+
&format!("Unrolled build for #{original_pr_number}\n{}", rollup_merge.message),
112145
)
113146
.await
114147
.map_err(|e| {

0 commit comments

Comments
 (0)