@@ -18,24 +18,27 @@ pub async fn unroll_rollup(
18
18
previous_master : & str ,
19
19
rollup_pr_number : u32 ,
20
20
) -> Result < ( ) , String > {
21
+ let format_commit = |s : & str | {
22
+ let ( short, _) = s. split_at ( 8 ) ;
23
+ format ! ( "[{short}](https://github.com/rust-lang-ci/rust/commit/{s})" )
24
+ } ;
21
25
let mapping = enqueue_unrolled_try_builds ( ci_client, rollup_merges, previous_master)
22
26
. await ?
23
27
. into_iter ( )
24
28
. fold ( String :: new ( ) , |mut string, c| {
25
29
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 ( ) ;
30
+ let commit = c. sha . as_deref ( ) . map ( format_commit) . unwrap_or_else ( || {
31
+ let head = format_commit ( & c. rolled_up_head ) ;
32
+ format ! ( "❌ conflicts merging '{head}' into previous master ❌" )
33
+ } ) ;
34
+ write ! ( & mut string, "|#{pr}|{commit}|\n " , pr = c. original_pr_number) . unwrap ( ) ;
33
35
string
34
36
} ) ;
37
+ let previous_master = format_commit ( previous_master) ;
35
38
let msg =
36
39
format ! ( "📌 Perf builds for each rolled up PR:\n \n \
37
- |PR# | Perf Build Sha|\n |----|-----|\n \
38
- {mapping}\n In the case of a perf regression, \
40
+ |PR# | Perf Build Sha|\n |----|: -----: |\n \
41
+ {mapping}\n \n *previous master*: {previous_master} \n \ n In the case of a perf regression, \
39
42
run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`") ;
40
43
main_repo_client. post_comment ( rollup_pr_number, msg) . await ;
41
44
Ok ( ( ) )
@@ -76,35 +79,49 @@ async fn enqueue_unrolled_try_builds<'a>(
76
79
"What we thought was a merge commit was not a merge commit. sha: {}" ,
77
80
rollup_merge. sha
78
81
) ;
79
- let rolled_up_head = & commit. parents [ 1 ] . sha ;
82
+ let rolled_up_head = commit. parents [ 1 ] . sha . clone ( ) ;
80
83
81
84
// Reset perf-tmp to the previous master
82
85
client
83
86
. update_branch ( "perf-tmp" , previous_master)
84
87
. await
85
88
. map_err ( |e| format ! ( "Error updating perf-tmp with previous master: {e:?}" ) ) ?;
86
89
87
- // Merge in the rolled up PR's head commit into the previous master
90
+ // Try to merge in the rolled up PR's head commit into the previous master
88
91
let sha = client
89
92
. merge_branch (
90
93
"perf-tmp" ,
91
- rolled_up_head,
92
- & format ! ( "Unrolled build for #{}" , original_pr_number ) ,
94
+ & rolled_up_head,
95
+ & format ! ( "Unrolled build for #{original_pr_number}" ) ,
93
96
)
94
97
. await
95
98
. map_err ( |e| {
96
99
format ! ( "Error merging #{original_pr_number}'s commit '{rolled_up_head}' into perf-tmp: {e:?}" )
97
100
} ) ?;
98
101
99
- // Force the `try-perf` branch to point to what the perf-tmp branch points to
100
- client
101
- . update_branch ( "try-perf" , & sha)
102
- . await
103
- . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
102
+ // Handle success and merge conflicts
103
+ match & sha {
104
+ Some ( s) => {
105
+ // Force the `try-perf` branch to point to what the perf-tmp branch points to
106
+ client
107
+ . update_branch ( "try-perf" , s)
108
+ . await
109
+ . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
110
+ }
111
+ None => {
112
+ // Merge conflict
113
+ log:: debug!(
114
+ "Could not create unrolled commit for #{original_pr_number}. \
115
+ Merging the rolled up HEAD '{rolled_up_head}' into the previous master \
116
+ '{previous_master}' leads to a merge conflict."
117
+ ) ;
118
+ }
119
+ } ;
104
120
105
121
mapping. push ( UnrolledCommit {
106
122
original_pr_number,
107
123
rollup_merge,
124
+ rolled_up_head,
108
125
sha,
109
126
} ) ;
110
127
// Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
@@ -120,8 +137,10 @@ pub struct UnrolledCommit<'a> {
120
137
pub original_pr_number : & ' a str ,
121
138
/// The original rollup merge commit
122
139
pub rollup_merge : & ' a Commit ,
123
- /// The sha of the new unrolled merge commit
124
- pub sha : String ,
140
+ /// The HEAD commit for the rolled up PR
141
+ pub rolled_up_head : String ,
142
+ /// The sha of the new unrolled merge commit. `None` when creation failed due to merge conflicts.
143
+ pub sha : Option < String > ,
125
144
}
126
145
127
146
lazy_static:: lazy_static! {
0 commit comments