@@ -6,6 +6,7 @@ use serde::Deserialize;
6
6
7
7
use regex:: Regex ;
8
8
use reqwest:: header:: USER_AGENT ;
9
+ use std:: { sync:: Arc , time:: Duration } ;
9
10
10
11
lazy_static:: lazy_static! {
11
12
static ref BODY_TRY_COMMIT : Regex =
@@ -36,11 +37,11 @@ async fn get_authorized_users() -> ServerResult<Vec<usize>> {
36
37
37
38
pub async fn handle_github (
38
39
request : github:: Request ,
39
- data : & InputData ,
40
+ data : Arc < InputData > ,
40
41
) -> ServerResult < github:: Response > {
41
42
if request. comment . body . contains ( " homu: " ) {
42
43
if let Some ( sha) = handle_homu_res ( & request) . await {
43
- return enqueue_sha ( request, data, sha) . await ;
44
+ return enqueue_sha ( request, & data, sha) . await ;
44
45
}
45
46
}
46
47
@@ -83,7 +84,7 @@ pub async fn handle_github(
83
84
let conn = data. conn ( ) . await ;
84
85
conn. queue_pr ( request. issue . number ) . await ;
85
86
}
86
- let f = enqueue_sha ( request, data, commit. to_owned ( ) ) ;
87
+ let f = enqueue_sha ( request, & data, commit. to_owned ( ) ) ;
87
88
return f. await ;
88
89
}
89
90
}
@@ -98,7 +99,7 @@ pub async fn handle_github(
98
99
let client = reqwest:: Client :: new ( ) ;
99
100
pr_and_try_for_rollup (
100
101
& client,
101
- & data,
102
+ data. clone ( ) ,
102
103
& request. issue . repository_url ,
103
104
& rollup_merge,
104
105
& request. comment . html_url ,
@@ -121,7 +122,7 @@ pub async fn handle_github(
121
122
// between us updating the commit and merging things.
122
123
let client = reqwest:: Client :: new ( ) ;
123
124
let branch =
124
- branch_for_rollup ( & client, data, & request. issue . repository_url , rollup_merge)
125
+ branch_for_rollup ( & client, & data, & request. issue . repository_url , rollup_merge)
125
126
. await
126
127
. map_err ( |e| e. to_string ( ) ) ?;
127
128
post_comment (
@@ -139,7 +140,7 @@ pub async fn handle_github(
139
140
// Returns the PR number
140
141
async fn pr_and_try_for_rollup (
141
142
client : & reqwest:: Client ,
142
- data : & InputData ,
143
+ data : Arc < InputData > ,
143
144
repository_url : & str ,
144
145
rollup_merge_sha : & str ,
145
146
origin_url : & str ,
@@ -149,11 +150,11 @@ async fn pr_and_try_for_rollup(
149
150
repository_url,
150
151
rollup_merge_sha
151
152
) ;
152
- let branch = branch_for_rollup ( client, data, repository_url, rollup_merge_sha) . await ?;
153
+ let branch = branch_for_rollup ( client, & data, repository_url, rollup_merge_sha) . await ?;
153
154
154
155
let pr = create_pr (
155
156
client,
156
- data,
157
+ & data,
157
158
repository_url,
158
159
& format ! (
159
160
"[DO NOT MERGE] perf-test for #{}" ,
@@ -165,42 +166,49 @@ async fn pr_and_try_for_rollup(
165
166
"This is an automatically generated pull request (from [here]({})) to \
166
167
run perf tests for #{} which merged in a rollup.
167
168
168
- r? @ghost",
169
+ r? @ghost" ,
169
170
origin_url, branch. rolled_up_pr_number
170
171
) ,
171
172
)
172
173
. await
173
174
. context ( "Created PR" ) ?;
174
175
175
- // This provides the master SHA so that we can check that we only queue
176
- // an appropriate try build. If there's ever a race condition, i.e.,
177
- // master was pushed while this command was running, the user will have to
178
- // take manual action to detect it.
179
- //
180
- // Eventually we'll want to handle this automatically, but that's a ways
181
- // off: we'd need to store the state in the database and handle the try
182
- // build starting and generally that's a lot of work for not too much gain.
183
- post_comment (
184
- & data. config ,
185
- pr. number ,
186
- & format ! (
187
- "@bors try @rust-timer queue\n
188
- The try commit's (master) parent should be {master}. If it isn't, \
189
- then please:
190
-
191
- * Stop this try build (`try-`).
192
- * Run `@rust-timer update-pr-for {merge}`.
193
- * Rerun `bors try`.
194
-
195
- You do not need to reinvoke the queue command as long as the perf \
196
- build hasn't yet started.",
197
- master = branch. master_base_sha,
198
- merge = rollup_merge_sha,
199
- ) ,
200
- )
201
- . await ;
176
+ let pr_number = pr. number ;
177
+ let rollup_merge_sha = rollup_merge_sha. to_owned ( ) ;
178
+ tokio:: task:: spawn ( async move {
179
+ // Give github time to create the merge commit reference
180
+ tokio:: time:: delay_for ( Duration :: from_secs ( 1 ) ) . await ;
181
+ // This provides the master SHA so that we can check that we only queue
182
+ // an appropriate try build. If there's ever a race condition, i.e.,
183
+ // master was pushed while this command was running, the user will have to
184
+ // take manual action to detect it.
185
+ //
186
+ // Eventually we'll want to handle this automatically, but that's a ways
187
+ // off: we'd need to store the state in the database and handle the try
188
+ // build starting and generally that's a lot of work for not too much gain.
189
+ post_comment (
190
+ & data. config ,
191
+ pr. number ,
192
+ & format ! (
193
+ "@bors try @rust-timer queue
194
+
195
+ The try commit's (master) parent should be {master}. If it isn't, \
196
+ then please:
197
+
198
+ * Stop this try build (`try-`).
199
+ * Run `@rust-timer update-pr-for {merge}`.
200
+ * Rerun `bors try`.
201
+
202
+ You do not need to reinvoke the queue command as long as the perf \
203
+ build hasn't yet started.",
204
+ master = branch. master_base_sha,
205
+ merge = rollup_merge_sha,
206
+ ) ,
207
+ )
208
+ . await ;
209
+ } ) ;
202
210
203
- Ok ( pr . number )
211
+ Ok ( pr_number )
204
212
}
205
213
206
214
struct RollupBranch {
0 commit comments