From f7b56b0bd4bd6b7f14c86159d9f40c8d0b024afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 14 Aug 2026 18:25:13 +0200 Subject: [PATCH] Fix handling of try builds that were not enqueued --- site/src/github.rs | 11 +++++------ site/src/request_handlers/github.rs | 13 +++++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/site/src/github.rs b/site/src/github.rs index a1397404c..773d73e1d 100644 --- a/site/src/github.rs +++ b/site/src/github.rs @@ -227,12 +227,13 @@ pub async fn rollup_pr_number( } /// Enqueues the given SHA and returns a message that should be sent as a comment to the corresponding PR. +/// If not benchmark reques was found to which the commit SHA could be attached, returns `Ok(None)`. pub async fn enqueue_sha( ctxt: &SiteCtxt, gh_client: &client::Client, pr_number: u32, commit_sha: &str, -) -> Result { +) -> Result, String> { let mut commit = gh_client .get_commit(commit_sha) .await @@ -259,9 +260,7 @@ pub async fn enqueue_sha( .await .map_err(|error| format!("Cannot attach SHAs to try benchmark request on PR {pr_number} and SHA {}: {error:?}", try_commit.sha))?; if !queued { - return Err( - "Commit was not enqueued, since no previous benchmark request was found".to_string(), - ); + return Ok(None); } let (preceding_artifacts, expected_duration) = estimate_queue_info(conn.as_ref(), &try_commit) @@ -280,12 +279,12 @@ It will probably take at least ~{:.1} hours until the benchmark run finishes."#, expected_duration.as_secs_f64() / 3600.0 ); - Ok(format!( + Ok(Some(format!( "Queued {} with parent {}, future [comparison URL]({}).\n{queue_msg}", try_commit.sha, try_commit.parent_sha, try_commit.comparison_url(), - )) + ))) } /// Counts how many artifacts are in the queue before the specified commit, and what is the expected diff --git a/site/src/request_handlers/github.rs b/site/src/request_handlers/github.rs index f8a00dd4a..1dd4f0c87 100644 --- a/site/src/request_handlers/github.rs +++ b/site/src/request_handlers/github.rs @@ -78,10 +78,13 @@ async fn handle_issue( if comment.body.contains(" homu: ") { if let Some(sha) = parse_homu_comment(&comment.body).await { match enqueue_sha(&ctxt, &gh_client, issue.number, &sha).await { - Ok(mut msg) => { + Ok(Some(mut msg)) => { msg.push_str(&format!("\n{COMMENT_MARK_TEMPORARY}")); gh_client.post_comment(issue.number, msg).await; } + Ok(None) => { + // A try build without @rust-timer queue finished + } Err(err) => { gh_client.post_comment(issue.number, err).await; } @@ -345,7 +348,13 @@ async fn enqueue_sha_build( .await; } - enqueue_sha(ctxt, main_client, issue_number, cmd.sha).await + match enqueue_sha(ctxt, main_client, issue_number, cmd.sha).await { + Ok(Some(msg)) => Ok(msg), + Ok(None) => Err( + "Commit was not enqueued, since no previous benchmark request was found".to_string(), + ), + Err(err) => Err(err), + } } fn parse_command(body: &str) -> Result, String> {