Skip to content

Commit 767ef77

Browse files
committed
Revert "Update check run on cancel_timed_out_builds"
This reverts commit fdc4394.
1 parent 64a904c commit 767ef77

File tree

3 files changed

+17
-47
lines changed

3 files changed

+17
-47
lines changed

src/bors/handlers/refresh.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::time::Duration;
33

44
use anyhow::Context;
55
use chrono::{DateTime, Utc};
6-
use octocrab::params::checks::{CheckRunConclusion, CheckRunStatus};
76
use std::collections::BTreeMap;
87

98
use crate::bors::Comment;
@@ -29,22 +28,6 @@ pub async fn cancel_timed_out_builds(
2928

3029
db.update_build_status(&build, BuildStatus::Cancelled)
3130
.await?;
32-
33-
if let Some(check_run_id) = build.check_run_id {
34-
if let Err(error) = repo
35-
.client
36-
.update_check_run(
37-
check_run_id as u64,
38-
CheckRunStatus::Completed,
39-
Some(CheckRunConclusion::TimedOut),
40-
None,
41-
)
42-
.await
43-
{
44-
tracing::error!("Could not update check run {check_run_id}: {error:?}");
45-
}
46-
}
47-
4831
if let Some(pr) = db.find_pr_by_build(&build).await? {
4932
if let Err(error) = cancel_build_workflows(&repo.client, db, &build).await {
5033
tracing::error!(
@@ -198,13 +181,11 @@ fn elapsed_time(date: DateTime<Utc>) -> Duration {
198181
mod tests {
199182
use crate::bors::PullRequestStatus;
200183
use crate::bors::handlers::refresh::MOCK_TIME;
201-
use crate::bors::handlers::trybuild::TRY_BUILD_CHECK_RUN_NAME;
202184
use crate::database::{MergeableState, OctocrabMergeableState};
203185
use crate::tests::mocks::{
204186
BorsBuilder, GitHubState, default_pr_number, default_repo_name, run_test,
205187
};
206188
use chrono::Utc;
207-
use octocrab::params::checks::{CheckRunConclusion, CheckRunStatus};
208189
use std::future::Future;
209190
use std::time::Duration;
210191
use tokio::runtime::RuntimeFlavor;
@@ -286,33 +267,6 @@ timeout = 3600
286267
.await;
287268
}
288269

289-
#[sqlx::test]
290-
async fn refresh_cancel_build_updates_check_run(pool: sqlx::PgPool) {
291-
BorsBuilder::new(pool)
292-
.github(gh_state_with_long_timeout())
293-
.run_test(|mut tester| async move {
294-
tester.post_comment("@bors try").await?;
295-
tester.expect_comments(1).await;
296-
297-
with_mocked_time(Duration::from_secs(4000), async {
298-
tester.cancel_timed_out_builds().await;
299-
})
300-
.await;
301-
tester.expect_comments(1).await;
302-
303-
tester.expect_check_run(
304-
&tester.default_pr().await.get_gh_pr().head_sha,
305-
TRY_BUILD_CHECK_RUN_NAME,
306-
"Bors try build",
307-
CheckRunStatus::Completed,
308-
Some(CheckRunConclusion::TimedOut),
309-
);
310-
311-
Ok(tester)
312-
})
313-
.await;
314-
}
315-
316270
#[sqlx::test]
317271
async fn refresh_cancel_workflow_after_timeout(pool: sqlx::PgPool) {
318272
let gh = BorsBuilder::new(pool)

src/bors/handlers/trybuild.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(super) const TRY_MERGE_BRANCH_NAME: &str = "automation/bors/try-merge";
3636
pub(super) const TRY_BRANCH_NAME: &str = "automation/bors/try";
3737

3838
// The name of the check run seen in the GitHub UI.
39-
pub(super) const TRY_BUILD_CHECK_RUN_NAME: &str = "Bors try build";
39+
const TRY_BUILD_CHECK_RUN_NAME: &str = "Bors try build";
4040

4141
/// Performs a so-called try build - merges the PR branch into a special branch designed
4242
/// for running CI checks.
@@ -910,6 +910,10 @@ try_failed = ["+foo", "+bar", "-baz"]
910910
None,
911911
);
912912

913+
let check_run = tester.get_check_run().await?;
914+
insta::assert_snapshot!(check_run.summary, @"");
915+
insta::assert_snapshot!(check_run.text, @"");
916+
913917
Ok(tester)
914918
})
915919
.await;

src/tests/mocks/bors.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::github::api::load_repositories;
2626
use crate::github::server::BorsProcess;
2727
use crate::github::{GithubRepoName, PullRequestNumber};
2828
use crate::tests::mocks::comment::{Comment, GitHubIssueCommentEventPayload};
29+
use crate::tests::mocks::repository;
2930
use crate::tests::mocks::workflow::{
3031
CheckSuite, GitHubCheckRunEventPayload, GitHubCheckSuiteEventPayload,
3132
GitHubWorkflowEventPayload, TestWorkflowStatus, Workflow, WorkflowEvent, WorkflowEventKind,
@@ -273,6 +274,17 @@ impl BorsTester {
273274
self.get_branch("automation/bors/try")
274275
}
275276

277+
/// Get the latest check run.
278+
pub async fn get_check_run(&mut self) -> anyhow::Result<repository::CheckRunData> {
279+
Ok(self
280+
.default_repo()
281+
.lock()
282+
.check_runs
283+
.last()
284+
.unwrap()
285+
.clone())
286+
}
287+
276288
/// Wait until the next bot comment is received on the default repo and the default PR.
277289
pub async fn get_comment(&mut self) -> anyhow::Result<String> {
278290
Ok(self

0 commit comments

Comments
 (0)