@@ -177,22 +177,6 @@ def get_deployment(self, revision):
177
177
178
178
return deployments .pop () if len (deployments ) else None
179
179
180
- @guard ('core' )
181
- def deployment_is_pending (self , deployment ):
182
- url = '{}/repos/{}/deployments/{}/statuses' .format (
183
- self ._host , self ._github_project , deployment ['id' ]
184
- )
185
-
186
- statuses = sorted (
187
- gh_request ('GET' , url ),
188
- key = lambda status : status ['created_at' ]
189
- )
190
-
191
- if len (statuses ) == 0 :
192
- return False
193
-
194
- return statuses [- 1 ]['state' ] == 'pending'
195
-
196
180
@guard ('core' )
197
181
def update_deployment (self , target , deployment , state , description = '' ):
198
182
if state in ('pending' , 'success' ):
@@ -263,7 +247,7 @@ def is_deployed(host, deployment):
263
247
264
248
return response .text .strip () == deployment ['sha' ]
265
249
266
- def synchronize (host , github_project , target , remote_name , window ):
250
+ def synchronize (host , github_project , remote_name , window ):
267
251
'''Inspect all pull requests which have been modified in a given window of
268
252
time. Add or remove the "preview" label and update or delete the relevant
269
253
git refs according to the status of each pull request.'''
@@ -304,14 +288,10 @@ def synchronize(host, github_project, target, remote_name, window):
304
288
elif revision_open != revision_latest :
305
289
project .update_ref (refspec_open , revision_latest )
306
290
307
- deployment = project .get_deployment (revision_latest )
308
- if deployment is None :
309
- deployment = project .create_deployment (
291
+ if project .get_deployment (revision_latest ) is None :
292
+ project .create_deployment (
310
293
pull_request , revision_latest
311
294
)
312
-
313
- if not project .deployment_is_pending (deployment ):
314
- project .update_deployment (target , deployment , 'pending' )
315
295
else :
316
296
logger .info ('Pull request should not be mirrored' )
317
297
@@ -333,22 +313,20 @@ def detect(host, github_project, target, timeout):
333
313
334
314
logger .info ('Event data: %s' , json .dumps (data , indent = 2 ))
335
315
336
- if data ['deployment_status' ]['state' ] != 'pending' :
337
- logger .info ('Deployment is not pending. Exiting.' )
338
- return
339
-
340
316
deployment = data ['deployment' ]
341
317
342
318
if not deployment ['environment' ].startswith ('gh-' ):
343
319
logger .info ('Deployment environment is unrecognized. Exiting.' )
344
320
return
345
321
322
+ message = 'Waiting up to %d seconds for deployment %s to be available on %s'
346
323
logger .info (
347
- 'Waiting up to %d seconds for deployment %s to be available on %s' ,
324
+ message ,
348
325
timeout ,
349
326
deployment ['environment' ],
350
327
target
351
328
)
329
+ project .update_deployment (target , deployment , 'pending' , message )
352
330
353
331
start = time .time ()
354
332
@@ -372,7 +350,6 @@ def detect(host, github_project, target, timeout):
372
350
help = '''the GitHub organization and GitHub project name, separated by
373
351
a forward slash (e.g. "web-platform-tests/wpt")'''
374
352
)
375
- parser .add_argument ('--target' , required = True )
376
353
subparsers = parser .add_subparsers (title = 'subcommands' )
377
354
378
355
parser_sync = subparsers .add_parser (
@@ -383,6 +360,7 @@ def detect(host, github_project, target, timeout):
383
360
parser_sync .set_defaults (func = synchronize )
384
361
385
362
parser_detect = subparsers .add_parser ('detect' , help = detect .__doc__ )
363
+ parser_detect .add_argument ('--target' , required = True )
386
364
parser_detect .add_argument ('--timeout' , type = int , required = True )
387
365
parser_detect .set_defaults (func = detect )
388
366
0 commit comments