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
5 changes: 5 additions & 0 deletions app/src/domain/reruns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ pub async fn unreviewed_carry(
let Some(previous) = previous_on_branch(build, &["completed"]).await? else {
return Ok(unfinished.map(|_| UnreviewedCarry { number: 0, rows: HashMap::new(), unfinished }));
};
// Approved as it was (the default branch's first build, or nothing to review): its snapshots carry no review of
// their own, and none of them is unreviewed.
if previous.review_state == "auto_approved" {
return Ok(unfinished.map(|_| UnreviewedCarry { number: previous.number, rows: HashMap::new(), unfinished }));
}
// Superseded by an approval: a later review covered its changes, and the baseline stands.
let settled = superseder(previous.clone()).await?;
if settled.id != previous.id && matches!(settled.review_state.as_str(), "approved" | "auto_approved") {
Expand Down
22 changes: 22 additions & 0 deletions app/tests/reruns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,28 @@ async fn partial_subset(app: Application) -> laravel::Result<()> {
Ok(())
}

/// The branch's last build was approved as it was (the default branch's first build): its snapshots have no review of
/// their own, and none of them is an unreviewed change, so a partial subset build behind it carries the baseline.
#[laravel::test]
async fn a_partial_subset_build_behind_an_auto_approved_build_carries_nothing_unreviewed(
app: Application,
) -> laravel::Result<()> {
Box::pin(behind_auto_approved(app)).await
}

async fn behind_auto_approved(app: Application) -> laravel::Result<()> {
fixtures::blob_store().await?;
let token = project_token().await?;
let (invoice, receipt) = ("invoices/a/invoice.png", "receipts/a/receipt.png");
let on = |branch, commit, nonce| Run { name: "pdf", commit, branch, nonce };
let first = run(&app, &token, &on("main", "c1", "w1"), &[(invoice, RED), (receipt, RED)]).await;
assert_eq!(first["review_state"], "auto_approved", "{first}");
let partial = subset(&app, &token, &on("main", "c2", "w2"), &[(receipt, RED)]).await;
assert_eq!((&partial["conclusion"], &partial["passed"]), (&json!("unchanged"), &json!(true)), "{partial}");
assert!(!warnings(&partial).iter().any(|w| w.contains("last build of the suite, and not approved")), "{partial}");
Ok(())
}

/// Main's last build was superseded by another branch's review: a skipped main build stands on that review. A
/// rejection keeps it rejected and a superseding build still waiting keeps it waiting; only an approval lets it carry
/// the baseline.
Expand Down
Loading