Skip to content

Commit 7ad3f28

Browse files
Prevent premature completion comment posting
1 parent 64f6eaa commit 7ad3f28

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

site/src/github.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::Context as _;
44
use hashbrown::HashSet;
55
use serde::Deserialize;
66

7+
use database::ArtifactId;
78
use regex::Regex;
89
use reqwest::header::USER_AGENT;
910
use std::{sync::Arc, time::Duration};
@@ -583,13 +584,33 @@ where
583584
pub async fn post_finished(data: &InputData) {
584585
let conn = data.conn().await;
585586
let index = data.index.load();
586-
let commits = index
587+
let mut commits = index
587588
.commits()
588589
.into_iter()
589590
.map(|c| c.sha.to_string())
590591
.collect::<HashSet<_>>();
591592
let queued = conn.queued_commits().await;
592593

594+
// In theory this is insufficient -- there could be multiple commits in
595+
// progress -- but in practice that really shouldn't happen.
596+
//
597+
// The failure case here is also just prematurely posting a single comment,
598+
// which should be fine. mark_complete below will ensure that only happens
599+
// once.
600+
//
601+
// If this becomes more of a problem, it should be fairly easy to instead
602+
// query that there are no in progress benchmarks for commit X.
603+
match conn.in_progress_artifact().await {
604+
None => {}
605+
Some(ArtifactId::Commit(c)) => {
606+
commits.insert(c.sha);
607+
}
608+
Some(ArtifactId::Artifact(_)) => {
609+
// do nothing, for now, though eventually we'll want an artifact
610+
// queue
611+
}
612+
}
613+
593614
for commit in queued {
594615
if !commits.contains(&commit.sha) {
595616
continue;

0 commit comments

Comments
 (0)