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