From bcd869dc14103fa2df145457f2dc8d12408754ec Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 14 Mar 2024 18:42:09 +0800 Subject: [PATCH] feat: rerequest github check run upon job restart --- Cargo.lock | 4 ++-- buildit-utils/Cargo.toml | 2 +- server/Cargo.toml | 2 +- server/src/api.rs | 2 +- server/src/routes/job.rs | 17 ++++++++--------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29532fe..a674000 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2313,9 +2313,9 @@ dependencies = [ [[package]] name = "octocrab" -version = "0.34.3" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4e00a4268539fda6c431a0fd01d016d4b44c361f9c283d0eb8f1ab7408a517" +checksum = "a6d07f2ea5f11065486c5d66e7fa592833038377c8b55c0b8694a624732fee32" dependencies = [ "arc-swap", "async-trait", diff --git a/buildit-utils/Cargo.toml b/buildit-utils/Cargo.toml index 1a13857..da11084 100644 --- a/buildit-utils/Cargo.toml +++ b/buildit-utils/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -octocrab = "0.34" +octocrab = "0.35.0" jsonwebtoken = "9" anyhow = "1" tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "process", "sync", "fs"] } diff --git a/server/Cargo.toml b/server/Cargo.toml index f874f8d..31ecec2 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -13,7 +13,7 @@ common = { path = "../common" } dotenv = "0.15.0" env_logger = "0.11.2" futures = "0.3.30" -octocrab = "0.34.1" +octocrab = "0.35.0" once_cell = "1.19.0" reqwest = "0.11.24" serde = { version = "1.0.196", features = ["derive"] } diff --git a/server/src/api.rs b/server/src/api.rs index 8d5aa56..a058474 100644 --- a/server/src/api.rs +++ b/server/src/api.rs @@ -137,7 +137,7 @@ pub async fn pipeline_new( match crab .checks("AOSC-Dev", "aosc-os-abbs") .create_check_run(format!("buildit {}", arch), &git_sha) - .status(octocrab::params::checks::CheckRunStatus::InProgress) + .status(octocrab::params::checks::CheckRunStatus::Queued) .send() .await { diff --git a/server/src/routes/job.rs b/server/src/routes/job.rs index 261fc4c..c5b76dd 100644 --- a/server/src/routes/job.rs +++ b/server/src/routes/job.rs @@ -213,12 +213,13 @@ pub async fn job_restart( match get_crab_github_installation().await { Ok(Some(crab)) => { let handler = crab.checks("AOSC-Dev", "aosc-os-abbs"); - let mut builder = handler - .update_check_run(CheckRunId(github_check_run_id as u64)) - .status(octocrab::params::checks::CheckRunStatus::InProgress); - - if let Err(e) = builder.send().await { - warn!("Failed to update github check run: {e}"); + // https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#rerequest-a-check-run + if let Err(e) = handler + .rerequest_check_run(CheckRunId(github_check_run_id as u64)) + .send() + .await + { + warn!("Failed to rerequest github check run: {e}"); } } Ok(None) => { @@ -230,7 +231,5 @@ pub async fn job_restart( } } - Ok(Json(JobRestartResponse { - job_id: new_job.id, - })) + Ok(Json(JobRestartResponse { job_id: new_job.id })) }