Using branch policies I have enabled Build validation on pull requests. Now whenever I create a pull request, I can see a build getting triggered and based on the status of the build, I am allowed to complete/hold the pull request. All fine up-to here.
Now consider a 2 parallel pull requests scenario PR1: is in progress and got a green build through Build Validation. Reviewer is allowed to complete this PR.
PR2 is also in progress, which has some changes which can fail few test cases in PR1 changes. PR2 build validation build is green and this PR2 is Approved and Completed and merged into master.
Now, PR1 is Approved (as it got a green build earlier) and completed and merged into master. Once PR1 changes are merged to master, master is now a broken branch.
How to avoid this? How can we trigger a gated check-in / pre-commit build when PR changes are actually merging in master?