Watch
0
0
Fork
You've already forked hyperhive
0

review-classifier: a requested review runs even on a draft pr

This commit is contained in:
atlas 2026-11-02 18:45:36 +01:00
commit 4d8d43d677
2 changed files with 11 additions and 57 deletions

View file

@ -32,8 +32,6 @@ pub(super) enum Request {
Started,
/// Taken for a head already reviewed; its verdict was posted again.
Reposted,
/// Taken for a PR the forge calls a draft; nothing ran or posted.
Draft,
}
impl Request {
@ -45,7 +43,6 @@ impl Request {
Self::Deferred => "deferred",
Self::Started => "started",
Self::Reposted => "reposted",
Self::Draft => "draft",
}
}
}

View file

@ -678,16 +678,6 @@ async fn review(
slot: Slot,
) {
let pull = read_pull(forge, req).await;
if matches!(&pull, Ok(pull) if pull.draft) {
drop(slot);
metrics.request(Request::Draft);
tracing::info!(
repo = %format!("{}/{}", req.owner, req.name), pr = req.pr,
head_sha = req.head.as_str(),
"review requested on a draft PR; skipping it"
);
return;
}
let moved = matches!(&pull, Ok(pull) if !req.head.is_empty() && pull.head_sha != req.head);
if moved {
tracing::info!(
@ -1661,7 +1651,6 @@ mod tests {
struct Heads {
fake: Fake,
head_of: Mutex<std::collections::HashMap<i64, String>>,
drafts: Mutex<std::collections::HashSet<i64>>,
}
impl Heads {
@ -1674,14 +1663,9 @@ mod tests {
vec![rules_json()],
),
head_of: Mutex::default(),
drafts: Mutex::default(),
}
}
fn make_draft(&self, pr: i64) {
self.drafts.lock().expect("unpoisoned").insert(pr);
}
fn move_to(&self, pr: i64, head: &str) {
self.head_of
.lock()
@ -1709,7 +1693,6 @@ mod tests {
commits: Vec::new(),
diff: String::new(),
narrowed: None,
draft: self.drafts.lock().expect("unpoisoned").contains(&number),
})
}
}
@ -2041,26 +2024,6 @@ mod tests {
assert_eq!(q.rig.gate.reached(), 2, "no run after the ack");
}
/// A request taken from the queue for a PR that is a draft by then runs
/// nothing and posts nothing; the other PR in the queue is reviewed.
#[tokio::test]
async fn a_queued_request_for_a_draft_pr_is_skipped() {
let q = Queued::new().await;
q.rig.forge.make_draft(7);
q.request(7, "abc123").await;
q.request(8, "abc123").await;
let _consumer = q.consume(&q.rig.reviews);
q.rig.gate.open(2);
until("the other PR is reviewed", || q.rig.posted().len() == 1).await;
tokio::time::sleep(TEST_TIMING.ack_wait * 2).await;
let posted = q.rig.posted();
assert_eq!(posted.len(), 1, "the draft posts nothing");
assert_eq!(posted[0].0, "o/r#8");
assert_eq!(q.rig.gate.reached(), 1, "the draft starts no run");
assert_eq!(q.waiting().await, 0, "the draft request is acked, not kept");
}
#[tokio::test]
async fn a_newer_request_for_a_pr_replaces_the_waiting_one() {
let q = Queued::new().await;