Skip to content

Commit 2be1858

Browse files
committed
Re-run fix on an existing PR: one push, partial work kept off the PR
A run that finds its ticket's PR open with failing checks or review comments fixed them by writing straight to the PR branch, one push per edit. It now works like the other fix rounds: checkpoints on coderhelm-wip/<branch>, one commit landed on the PR at the end in the team's commit style, and a fix that runs out of time or can't land keeps its work on the WIP branch and never reaches the PR. It also gets the run's implement deadline instead of none. Also updates the run_of tests for the trigger lookups argument main added.
1 parent 7c58c00 commit 2be1858

2 files changed

Lines changed: 53 additions & 6 deletions

File tree

‎services/gateway/src/routes/api.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6070,7 +6070,7 @@ mod tests {
60706070
cache_write: 0,
60716071
cost_usd: 0.0,
60726072
};
6073-
let run = serde_json::to_value(run_of(&item, "r1", usage)).unwrap();
6073+
let run = serde_json::to_value(run_of(&item, "r1", usage, &Default::default())).unwrap();
60746074
let r = &run["round_incomplete"];
60756075
assert_eq!(run["status"], "completed");
60766076
assert_eq!(r["kind"], "review_fix");
@@ -6092,7 +6092,8 @@ mod tests {
60926092
cost_usd: 0.0,
60936093
};
60946094
assert!(
6095-
serde_json::to_value(run_of(&plain, "r2", usage)).unwrap()["round_incomplete"]
6095+
serde_json::to_value(run_of(&plain, "r2", usage, &Default::default())).unwrap()
6096+
["round_incomplete"]
60966097
.is_null()
60976098
);
60986099
}
@@ -6174,7 +6175,7 @@ mod tests {
61746175
cache_write: 0,
61756176
cost_usd: 0.0,
61766177
};
6177-
let run = serde_json::to_value(run_of(&item, "r", usage)).unwrap();
6178+
let run = serde_json::to_value(run_of(&item, "r", usage, &Default::default())).unwrap();
61786179
assert_eq!(
61796180
run["codegen_env_missing"]["vars"][0],
61806181
"SANITY_STUDIO_PROJECT_ID"

‎services/worker/src/passes/mod.rs‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,12 +2628,21 @@ async fn run_passes(
26282628
let pass_start = std::time::Instant::now();
26292629
let usage_before = usage.clone();
26302630

2631+
// A fix round on an open PR: checkpoints go to its own WIP
2632+
// branch, and the PR gets one commit (one push) at the end.
2633+
let fix_base =
2634+
round::branch_head(&github, &msg.repo_owner, &msg.repo_name, &branch_name)
2635+
.await;
2636+
let fix_wip =
2637+
round::open_wip(&github, &msg.repo_owner, &msg.repo_name, &branch_name, "")
2638+
.await?;
2639+
26312640
match implement::run(
26322641
state,
26332642
msg,
26342643
&github,
26352644
&plan_result,
2636-
&branch_name,
2645+
&fix_wip,
26372646
&[],
26382647
"",
26392648
Some(&feedback),
@@ -2642,14 +2651,51 @@ async fn run_passes(
26422651
usage,
26432652
&file_cache,
26442653
Some(run_id),
2645-
None,
2654+
implement_deadline,
26462655
// Scoped only when purely CI-driven; human review comments
26472656
// in the feedback mean the human's ask wins (unscoped).
26482657
!has_review_feedback,
26492658
)
26502659
.await
2651-
{
2660+
.and_then(|r| {
2661+
// Partial work never reaches the PR: it stays on the WIP
2662+
// branch, and the run starts over below.
2663+
if r.timed_out {
2664+
Err(format!("ran out of time; its work is kept on `{fix_wip}`").into())
2665+
} else {
2666+
Ok(r)
2667+
}
2668+
}) {
26522669
Ok(result) => {
2670+
let landed = round::land(
2671+
&round::Pr {
2672+
github: &github,
2673+
owner: &msg.repo_owner,
2674+
repo: &msg.repo_name,
2675+
branch: &branch_name,
2676+
},
2677+
&fix_wip,
2678+
&fix_base,
2679+
&conventions.commit_message(
2680+
&tokens,
2681+
"Fix the pull request's checks and review comments",
2682+
),
2683+
)
2684+
.await;
2685+
if let round::Landed::Refused(why) = &landed {
2686+
warn!(
2687+
run_id,
2688+
why,
2689+
"Fix on re-run didn't land; its work is kept on the WIP branch"
2690+
);
2691+
add_progress_note(
2692+
state,
2693+
&msg.team_id,
2694+
run_id,
2695+
&format!("The fix for PR #{pr_number} didn't land ({why}); its work is kept on `{fix_wip}`"),
2696+
)
2697+
.await;
2698+
}
26532699
write_pass_trace(
26542700
state,
26552701
&msg.team_id,

0 commit comments

Comments
 (0)