Skip to content

Commit cd8a3d6

Browse files
authored
Merge pull request #561 from Kobzol/timeout-ci-fail
Do not mark workflow as failed because of `min-ci-time` if it failed anyway
2 parents b8c9e5b + 7f4ffdf commit cd8a3d6

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/bors/handlers/workflow.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ pub(super) async fn handle_workflow_completed(
115115
}
116116

117117
let mut error_context = None;
118-
if let Some(running_time) = payload.running_time {
118+
if payload.status == WorkflowStatus::Success
119+
&& let Some(running_time) = payload.running_time
120+
{
119121
let running_time =
120122
chrono::Duration::to_std(&running_time).unwrap_or(Duration::from_secs(0));
121123
if let Some(min_ci_time) = repo.config.load().min_ci_time
@@ -384,6 +386,31 @@ min_ci_time = 10
384386
.await;
385387
}
386388

389+
#[sqlx::test]
390+
async fn min_ci_time_ignore_failed_workflow(pool: sqlx::PgPool) {
391+
BorsBuilder::new(pool)
392+
.github(GitHub::default().with_default_config(
393+
r#"
394+
min_ci_time = 10
395+
"#,
396+
))
397+
.run_test(async |ctx: &mut BorsTester| {
398+
ctx.post_comment("@bors try").await?;
399+
ctx.expect_comments((), 1).await;
400+
401+
let w1 = ctx.try_workflow();
402+
ctx.modify_workflow(w1, |w| w.set_duration(Duration::from_secs(1)));
403+
404+
// Too short workflow that failed anyway
405+
ctx
406+
.workflow_full_failure(w1)
407+
.await?;
408+
insta::assert_snapshot!(ctx.get_next_comment_text(()).await?, @":broken_heart: Test for merge-0-pr-1 failed: [Workflow1](https://github.com/rust-lang/borstest/actions/runs/1)");
409+
Ok(())
410+
})
411+
.await;
412+
}
413+
387414
#[sqlx::test]
388415
async fn min_ci_time_ignore_long_enough_workflow(pool: sqlx::PgPool) {
389416
BorsBuilder::new(pool)

0 commit comments

Comments
 (0)