@@ -167,10 +167,6 @@ async fn try_complete_build(
167
167
return Ok ( ( ) ) ;
168
168
}
169
169
170
- let has_failure = checks
171
- . iter ( )
172
- . any ( |check| matches ! ( check. status, CheckSuiteStatus :: Failure ) ) ;
173
-
174
170
let mut workflows = db. get_workflows_for_build ( & build) . await ?;
175
171
workflows. sort_by ( |a, b| a. name . cmp ( & b. name ) ) ;
176
172
@@ -187,7 +183,7 @@ async fn try_complete_build(
187
183
}
188
184
189
185
let workflow_list = workflows
190
- . into_iter ( )
186
+ . iter ( )
191
187
. map ( |w| {
192
188
format ! (
193
189
"- [{}]({}) {}" ,
@@ -203,6 +199,10 @@ async fn try_complete_build(
203
199
. collect :: < Vec < _ > > ( )
204
200
. join ( "\n " ) ;
205
201
202
+ let has_failure = workflows
203
+ . iter ( )
204
+ . any ( |workflow| matches ! ( workflow. status, WorkflowStatus :: Failure ) ) ;
205
+
206
206
let ( status, trigger) = if has_failure {
207
207
( BuildStatus :: Failure , LabelTrigger :: TryBuildFailed )
208
208
} else {
@@ -234,7 +234,12 @@ mod tests {
234
234
use crate :: bors:: handlers:: trybuild:: TRY_BRANCH_NAME ;
235
235
use crate :: database:: operations:: get_all_workflows;
236
236
use crate :: database:: WorkflowStatus ;
237
- use crate :: tests:: mocks:: { run_test, Branch , CheckSuite , Workflow , WorkflowEvent } ;
237
+ use crate :: tests:: mocks:: {
238
+ run_test, BorsBuilder , Branch , CheckSuite , TestWorkflowStatus , Workflow , WorkflowEvent ,
239
+ World ,
240
+ } ;
241
+ use chrono:: Utc ;
242
+ use std:: time:: Duration ;
238
243
239
244
#[ sqlx:: test]
240
245
async fn workflow_started_unknown_build ( pool : sqlx:: PgPool ) {
@@ -414,4 +419,39 @@ mod tests {
414
419
} )
415
420
. await ;
416
421
}
422
+
423
+ #[ sqlx:: test]
424
+ async fn workflow_finished_too_quickly ( pool : sqlx:: PgPool ) {
425
+ let world = World :: default ( ) ;
426
+ world. default_repo ( ) . lock ( ) . set_config (
427
+ r#"
428
+ min_ci_time = 10
429
+ "# ,
430
+ ) ;
431
+ BorsBuilder :: new ( pool)
432
+ . world ( world)
433
+ . run_test ( |mut tester| async {
434
+ tester. create_branch ( TRY_BRANCH_NAME ) . expect_suites ( 1 ) ;
435
+ tester. post_comment ( "@bors try" ) . await ?;
436
+ tester. expect_comments ( 1 ) . await ;
437
+
438
+ tester
439
+ . workflow_full (
440
+ Workflow :: from ( tester. try_branch ( ) )
441
+ . with_end ( Utc :: now ( ) + Duration :: from_secs ( 1 ) ) ,
442
+ TestWorkflowStatus :: Success ,
443
+ )
444
+ . await ?;
445
+ tester
446
+ . check_suite ( CheckSuite :: completed ( tester. try_branch ( ) ) )
447
+ . await ?;
448
+
449
+ insta:: assert_snapshot!( tester. get_comment( ) . await ?, @r"
450
+ :broken_heart: Test failed
451
+ - [Workflow1](https://github.com/workflows/Workflow1/1) :x:
452
+ " ) ;
453
+ Ok ( tester)
454
+ } )
455
+ . await ;
456
+ }
417
457
}
0 commit comments