Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions site/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> {
) -> Result<Option<String>, String> {
let mut commit = gh_client
.get_commit(commit_sha)
.await
Expand All @@ -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)
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions site/src/request_handlers/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<RustTimerCommand<'_>, String> {
Expand Down
Loading