1
1
use crate :: api:: { github, ServerResult } ;
2
2
use crate :: github:: {
3
- branch_for_rollup, client, enqueue_sha, get_authorized_users , parse_homu_comment ,
4
- pr_and_try_for_rollup,
3
+ branch_for_rollup, client, enqueue_sha, enqueue_unrolled_try_builds , get_authorized_users ,
4
+ parse_homu_comment , pr_and_try_for_rollup,
5
5
} ;
6
6
use crate :: load:: SiteCtxt ;
7
7
@@ -43,8 +43,8 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
43
43
if push. r#ref != "refs/heads/master" {
44
44
return Ok ( github:: Response ) ;
45
45
}
46
- let pr = rollup_pr ( & ci_client , & push) . await ?;
47
- let pr = match pr {
46
+ let rollup_pr = rollup_pr ( & main_repo_client , & push) . await ?;
47
+ let rollup_pr = match rollup_pr {
48
48
Some ( pr) => pr,
49
49
None => return Ok ( github:: Response ) ,
50
50
} ;
@@ -57,68 +57,32 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
57
57
. skip ( 1 ) // skip the head commit
58
58
. take_while ( |c| c. message . starts_with ( "Rollup merge of " ) ) ;
59
59
60
- let mut prs = Vec :: new ( ) ;
61
- for rollup_merge in rollup_merges {
62
- let pr_num = ROLLUPED_PR_NUMBER
63
- . captures ( & rollup_merge. message )
64
- . and_then ( |c| c. get ( 0 ) )
65
- . map ( |m| m. as_str ( ) )
66
- . ok_or_else ( || {
67
- format ! (
68
- "Could not get PR number from message: '{}'" ,
69
- rollup_merge. message
70
- )
71
- } ) ?;
72
- // Fetch the rollup merge commit which should have two parents.
73
- // The first parent is in the chain of rollup merge commits all the way back to `previous_master`.
74
- // The second parent is the head of the PR that was rolled up. We want the second parent.
75
- let commit = ci_client. get_commit ( & rollup_merge. sha ) . await . map_err ( |e| {
76
- format ! (
77
- "Error getting rollup merge commit '{}': {e:?}" ,
78
- rollup_merge. sha
79
- )
80
- } ) ?;
81
- assert ! (
82
- commit. parents. len( ) == 2 ,
83
- "What we thought was a merge commit was not a merge commit. sha: {}" ,
84
- rollup_merge. sha
85
- ) ;
86
- let rolled_up_head = & commit. parents [ 1 ] . sha ;
87
-
88
- // Reset perf-tmp to the previous master
89
- ci_client
90
- . update_branch ( "perf-tmp" , previous_master)
91
- . await
92
- . map_err ( |e| format ! ( "Error updating perf-tmp with previous master: {e:?}" ) ) ?;
93
-
94
- // Merge in the rolled up PR's head commit into the previous master
95
- let sha = ci_client
96
- . merge_branch ( "perf-tmp" , rolled_up_head, "merge" )
97
- . await
98
- . map_err ( |e| format ! ( "Error merging commit into perf-tmp: {e:?}" ) ) ?;
99
-
100
- // Force the `try-perf` branch to point to what the perf-tmp branch points to
101
- ci_client
102
- . update_branch ( "try-perf" , & sha)
103
- . await
104
- . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
60
+ let mapping = enqueue_unrolled_try_builds ( ci_client, rollup_merges, previous_master) . await ?;
105
61
106
- prs. push ( ( pr_num, sha) ) ;
107
- // Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
108
- tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 15 ) ) . await
109
- }
110
-
111
- // Post comment to the rollup PR with the mapping between individual PRs and the new try commits
112
- let mapping = prs
62
+ let mapping = mapping
113
63
. into_iter ( )
114
- . fold ( String :: new ( ) , |mut string, ( pr, commit) | {
64
+ . map ( |( rollup_merge, sha) | {
65
+ ROLLUPED_PR_NUMBER
66
+ . captures ( & rollup_merge. message )
67
+ . and_then ( |c| c. get ( 0 ) )
68
+ . map ( |m| ( m. as_str ( ) , sha) )
69
+ . ok_or_else ( || {
70
+ format ! (
71
+ "Could not get PR number from message: '{}'" ,
72
+ rollup_merge. message
73
+ )
74
+ } )
75
+ } )
76
+ . fold ( ServerResult :: Ok ( String :: new ( ) ) , |string, n| {
115
77
use std:: fmt:: Write ;
78
+ let ( pr, commit) = n?;
79
+ let mut string = string?;
116
80
write ! ( & mut string, "#{pr}: {commit}\n " ) . unwrap ( ) ;
117
- string
118
- } ) ;
81
+ Ok ( string)
82
+ } ) ? ;
119
83
let msg =
120
84
format ! ( "Try perf builds for each individual rolled up PR have been enqueued:\n {mapping}" ) ;
121
- main_repo_client. post_comment ( pr , msg) . await ;
85
+ main_repo_client. post_comment ( rollup_pr , msg) . await ;
122
86
Ok ( github:: Response )
123
87
}
124
88
0 commit comments