Short-circuit duplicate PR validations on draft → ready transitions#72
Short-circuit duplicate PR validations on draft → ready transitions#72Copilot wants to merge 19 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a duplicate-run guard to the Azure DevOps validation template so PR validations can skip expensive stages when the PR head commit has already been validated successfully (e.g., draft → ready transitions), reducing redundant CI compute/queue time.
Changes:
- Introduces a new
EvaluateDuplicatestage that queries the ADO Build REST API for prior successful PR runs with the same source commit SHA. - Gates PR-heavy stages (
Build,Kerberos_Test_PR,Build_mssql_python) on the guard output (skipDuplicate) and wires stage dependencies to consume the output. - Adds guard “safe fallback” behavior (intended) by setting
skipDuplicate=falsewhen token/API lookup is unavailable.
|
@copilot Address these problems:
|
Addressed in 2944c06. I updated
|
|
@copilot The duplicate evaluation still isn't working. There was a successful run on a commit, the PR was changed to ready-to-review, and the validation pipeline didn't detect the previous run on the same commit: Pipelines - Runs for mssql-rs Pull request validation |
Implemented in 0f8580a. I added detailed diagnostics to Also, PR-id mismatch is now only enforced when the query is not branch-scoped; when branch-scoped, we log the mismatch and still compare commit SHA so draft → ready transitions on the same head commit can be detected correctly. |
@copilot The duplicate skip isn’t working. It looks like the duplicate evaluation is working but stages aren’t being skipped. |
PR validations currently re-run end-to-end when a draft PR is marked ready for review, even if the PR head commit is unchanged and already validated. This adds avoidable queue time and compute usage on identical trees.
Duplicate-run guard stage
EvaluateDuplicatestage at the top of.pipeline/templates/validation-stages.yml.Build.Reason == PullRequest) in the normal validation path (non-fuzz, non-longhaul).System.DefinitionId) and checks for a prior successful run with matchingSystem.PullRequest.SourceCommitId.BUILD_SOURCEBRANCHfor the branch-scoped query and supports provider/API trigger fields for matching (pr.sourceSha,pr.sourceCommitId,pr.headSha; plus PR id fieldspr.number/pr.pullRequestId).System.PullRequest.PullRequestIdandSystem.PullRequest.PullRequestNumber) when evaluating candidate runs.skipDuplicate=true|false.Stage gating for expensive PR work
skipDuplicate == true:BuildKerberos_Test_PRBuild_mssql_pythondependencies.EvaluateDuplicate.outputs['Evaluate.SetDuplicateState.skipDuplicate']reliably in stage-level conditions.not(canceled())so guard failures/skips fall back to full validation instead of suppressing downstream PR stages.Guard behavior and safety
skipDuplicate=false(full validation continues).skipDuplicate=false.Example of the gating pattern now used: