Repository navigation
[Dr. CI] Prefer a successful run when a workflow ran twice on the PR head - #9616
Conversation
…head When the same workflow ran more than once on a PR's head commit, Dr. CI kept only the run with the highest ID and dropped every job of the others. Re-runs keep their run ID, so re-running the older run could never clear a newer run that was cancelled or failed for a flaky reason. For example, two Lint runs started in the same second on pytorch/pytorch#206339; concurrency cancelled the newer one, the older one passed, and Dr. CI still reported the cancelled jobs. Pick a successful run, else one that wasn't cancelled, else the most recent. This reverses the behavior pinned by "test new failed workflow overrides old succeeding workflow" (#5038): an older successful run of the same workflow on the same commit now wins over a newer failed one, and the test is flipped. This commit was written by Claude Code on behalf of albanD.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
I dig into this a bit more and realize that this is an exclusive behaviour coming from ghstack 0.16.0+ to having the same workflows triggered twice on the same commit. The data so far supports this: I have submitted a PR to restore the old behaviour ezyang/ghstack#370 and will try to see if it fix this issue at the root. |
|
Follow-up: I confirmed the root cause on a test ghstack stack (pytorch/pytorch#206700, pytorch/pytorch#206701). On 4 updates that moved the base branch, ghstack This PR is still worth landing. People will stay on ghstack 0.16–0.18 until they upgrade, and duplicate runs can come from other sources too. |
Author Notes
Making the (rare) case where a single workflow running on a single hash work better. In particular, when you rerun the older run, it doesn't become the "newer" because it's ID doesn't change. And so reruning cannot clear a other workflow being cancelled or failed for flaky reason. Making it so that success > fail > most recent.
Agent Notes
reorganizeWorkflowskeeps one run per workflow file (workflowUniqueId) on the PR head and drops every job of the other runs. It used to keep the run with the highest ID. A re-run keeps its run ID (onlyrun_attemptchanges), so re-running the older run never makes it win, and a newer cancelled or flakily failed run keeps blocking. Example: pytorch/pytorch#206339 got two Lint runs in the same second; concurrency cancelled the newer one (45427672193) while the older one (45427672059) passed every job, yet Dr. CI dropped the passing run and listed 4 cancelled jobs, keeping the PR from being promoted to "ready for review".The run is now picked by rank, then by highest ID within a rank: success > anything else (failure, in progress, ...) > cancelled.
Behavior change vs #5038: the existing test "test new failed workflow overrides old succeeding workflow" asserted that a newer failed run beats an older successful run of the same workflow on the same commit. This PR deliberately reverses that: the successful run wins, and the test is flipped to "test old succeeding workflow overrides new failed workflow" (expects 0 failed jobs). Trade-off: if two events run the same workflow file with different job sets (e.g. label-gated jobs), an older green run can now hide a newer red one.
No SQL change: workflow rows from
recent_pr_workflows_queryalready carryconclusion. Added table-drivenreorganizeWorkflowstests (3 of the 4 fail on the old logic).npx jest --no-watchmanondrci,drciStatus,drciAuthandcrcrCommenttests: 157/157 pass; prettier clean;tscerror count unchanged frommain.This PR was written by Claude Code on behalf of albanD.