Skip to content

Commit 2a12f1f

Browse files
committed
Do not send "commit queued" comments after every try build completes
1 parent 9fc23ba commit 2a12f1f

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
lines changed

database/src/pool.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,17 @@ pub trait Connection: Send + Sync {
219219
) -> anyhow::Result<()>;
220220

221221
/// Update a Try commit to have a `sha` and `parent_sha`. Will update the
222-
/// status of the request too a ready state.
222+
/// status of the request to the "artifacts_ready" state.
223+
///
224+
/// Returns `true` if any benchmark request that was waiting for artifacts was found for the
225+
/// given PR.
223226
async fn attach_shas_to_try_benchmark_request(
224227
&self,
225228
pr: u32,
226229
sha: &str,
227230
parent_sha: &str,
228231
commit_date: DateTime<Utc>,
229-
) -> anyhow::Result<()>;
232+
) -> anyhow::Result<bool>;
230233

231234
/// Add a benchmark job to the job queue and returns its ID, if it was not
232235
/// already in the DB previously.
@@ -658,9 +661,10 @@ mod tests {
658661
let req = BenchmarkRequest::create_try_without_artifacts(42, "", "");
659662

660663
db.insert_benchmark_request(&req).await.unwrap();
661-
db.attach_shas_to_try_benchmark_request(42, "sha1", "sha-parent-1", Utc::now())
664+
assert!(db
665+
.attach_shas_to_try_benchmark_request(42, "sha1", "sha-parent-1", Utc::now())
662666
.await
663-
.unwrap();
667+
.unwrap());
664668

665669
let req_db = db
666670
.load_pending_benchmark_requests()
@@ -690,6 +694,21 @@ mod tests {
690694
.await;
691695
}
692696

697+
#[tokio::test]
698+
async fn attach_shas_missing_try_request() {
699+
run_postgres_test(|ctx| async {
700+
let db = ctx.db();
701+
702+
assert!(!db
703+
.attach_shas_to_try_benchmark_request(42, "sha1", "sha-parent-1", Utc::now())
704+
.await
705+
.unwrap());
706+
707+
Ok(ctx)
708+
})
709+
.await;
710+
}
711+
693712
#[tokio::test]
694713
async fn enqueue_benchmark_job() {
695714
run_postgres_test(|ctx| async {

database/src/pool/postgres.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,21 +1717,21 @@ where
17171717
sha: &str,
17181718
parent_sha: &str,
17191719
commit_date: DateTime<Utc>,
1720-
) -> anyhow::Result<()> {
1721-
self.conn()
1720+
) -> anyhow::Result<bool> {
1721+
let modified_rows = self
1722+
.conn()
17221723
.execute(
1723-
"UPDATE
1724-
benchmark_request
1725-
SET
1726-
tag = $1,
1727-
parent_sha = $2,
1728-
status = $3,
1729-
commit_date = $6
1730-
WHERE
1731-
pr = $4
1732-
AND commit_type = 'try'
1733-
AND tag IS NULL
1734-
AND status = $5;",
1724+
"UPDATE benchmark_request
1725+
SET
1726+
tag = $1,
1727+
parent_sha = $2,
1728+
status = $3,
1729+
commit_date = $6
1730+
WHERE
1731+
pr = $4
1732+
AND commit_type = 'try'
1733+
AND tag IS NULL
1734+
AND status = $5;",
17351735
&[
17361736
&sha,
17371737
&parent_sha,
@@ -1744,7 +1744,7 @@ where
17441744
.await
17451745
.context("failed to attach SHAs to try benchmark request")?;
17461746

1747-
Ok(())
1747+
Ok(modified_rows > 0)
17481748
}
17491749

17501750
async fn load_pending_benchmark_requests(&self) -> anyhow::Result<PendingBenchmarkRequests> {

database/src/pool/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ impl Connection for SqliteConnection {
13441344
_sha: &str,
13451345
_parent_sha: &str,
13461346
_commit_date: DateTime<Utc>,
1347-
) -> anyhow::Result<()> {
1347+
) -> anyhow::Result<bool> {
13481348
no_queue_implementation_abort!()
13491349
}
13501350

site/src/github.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod comparison_summary;
44
use crate::api::github::Commit;
55
use crate::job_queue::should_use_job_queue;
66
use crate::load::{MissingReason, SiteCtxt, TryCommit};
7-
use chrono::{DateTime, Utc};
87
use serde::Deserialize;
98
use std::sync::LazyLock;
109
use std::time::Duration;
@@ -234,25 +233,6 @@ pub async fn rollup_pr_number(
234233
.then_some(issue.number))
235234
}
236235

237-
async fn attach_shas_to_try_benchmark_request(
238-
conn: &dyn database::pool::Connection,
239-
pr_number: u32,
240-
commit: &TryCommit,
241-
commit_date: DateTime<Utc>,
242-
) {
243-
if let Err(e) = conn
244-
.attach_shas_to_try_benchmark_request(
245-
pr_number,
246-
&commit.sha,
247-
&commit.parent_sha,
248-
commit_date,
249-
)
250-
.await
251-
{
252-
log::error!("Failed to add shas to try commit: {e:?}");
253-
}
254-
}
255-
256236
pub async fn enqueue_shas(
257237
ctxt: &SiteCtxt,
258238
gh_client: &client::Client,
@@ -280,14 +260,14 @@ pub async fn enqueue_shas(
280260
let conn = ctxt.conn().await;
281261

282262
let queued = if should_use_job_queue(pr_number) {
283-
attach_shas_to_try_benchmark_request(
284-
&*conn,
263+
conn.attach_shas_to_try_benchmark_request(
285264
pr_number,
286-
&try_commit,
265+
&try_commit.sha,
266+
&try_commit.parent_sha,
287267
commit_response.commit.committer.date,
288268
)
289-
.await;
290-
true
269+
.await
270+
.map_err(|error| format!("Cannot attach SHAs to try benchmark request on PR {pr_number} and SHA {}: {error:?}", try_commit.sha))?
291271
} else {
292272
conn.pr_attach_commit(
293273
pr_number,

0 commit comments

Comments
 (0)