Skip to content

BUILD/CI: Scope format check to commits unique to the PR - #11667

Open
yuanwu2017 wants to merge 4 commits into
openucx:masterfrom
yuanwu2017:ci/fix-pr-check-range
Open

yuanwu2017 wants to merge 4 commits into
openucx:masterfrom
yuanwu2017:ci/fix-pr-check-range

Conversation

@yuanwu2017

@yuanwu2017 yuanwu2017 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What?

Scope the format (clang-format) PR check to the commits actually authored
on the PR side, instead of deriving its base from git rev-parse HEAD^.

Why?

buildlib/pr/codestyle.yml computed the base of all three PR-only checks
(commit_title, format, author) from $(git rev-parse HEAD^). On a
long-lived PR, that first parent is the target-branch snapshot frozen at
PR-open time, so every Merge branch master commit pulls in newer master
commits that then show up as "PR side" and leak into the check.

#11527 fixed this for the commit_title and author jobs by using the two
parents of the Azure-generated merge commit
($(Build.SourceVersion)^1..$(Build.SourceVersion)^2). It did not touch the
format job, which still uses git rev-parse HEAD^ and can therefore still
flag formatting from target-side commits on long-lived branches.

This PR closes that remaining gap. The originally proposed
azure_pr_base_sha helper and the commit_title / author hunks have been
dropped, since #11527 already covers them.

How?

In the format job, derive the range the same way #11527 does:

base_revision=$(git rev-parse "${BUILD_SOURCEVERSION}^1")
head_revision=$(git rev-parse "${BUILD_SOURCEVERSION}^2")
git-clang-format --diff ${base_revision} ${head_revision} > format.patch

Net diff against master is now a single file, buildlib/pr/codestyle.yml,
and all three PR checks agree on how the range is computed.

The commit-title, code-format and AUTHORS-file PR checks all compute
their diff range from `$(git rev-parse HEAD^)`. Azure Pipelines
builds PRs on top of a merge commit whose first parent is the target
branch snapshot frozen at PR open time. On long-lived PRs, every
`Merge branch <target>` commit merges in newer target-side commits
that are reachable from HEAD but not from the frozen HEAD^, so those
target-side commits (and their authors, titles, and formatting)
leak into the check range and are wrongly attributed to the PR.

Add an `azure_pr_base_sha` helper that fetches the current tip of
the target branch (using SYSTEM_PULLREQUEST_TARGETBRANCH or
defaulting to `master`) and returns the merge-base against HEAD.
Use it as BASE_SOURCEVERSION in the three affected jobs. This
scopes the checks to commits actually authored on the PR side.

Signed-off-by: yuanwu <yuan.wu@intel.com>
@yafshar

yafshar commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@yuanwu2017 Heads-up: #11527 merged to master today and addresses the same root cause as this
PR for the commit_title and author jobs. Those two hunks here are now redundant and will conflict on rebase.

One gap remains: #11527 did not touch the format job, which still derives its base from git rev-parse HEAD^ (buildlib/pr/codestyle.yml:54), so clang-format checks can still pick up target-side commits on long-lived branches.

Could you rebase on master and scope this PR to the format job? Please keep it consistent with how #11527 derives the range so all the PR checks agree.

@yuanwu2017

Copy link
Copy Markdown
Contributor Author

@yuanwu2017 Heads-up: #11527 merged to master today and addresses the same root cause as this PR for the commit_title and author jobs. Those two hunks here are now redundant and will conflict on rebase.

One gap remains: #11527 did not touch the format job, which still derives its base from git rev-parse HEAD^ (buildlib/pr/codestyle.yml:54), so clang-format checks can still pick up target-side commits on long-lived branches.

Could you rebase on master and scope this PR to the format job? Please keep it consistent with how #11527 derives the range so all the PR checks agree.

Ok.

…ange

# Conflicts:
#	buildlib/pr/codestyle.yml
@yuanwu2017 yuanwu2017 changed the title BUILD/CI: Scope PR checks to commits unique to the PR BUILD/CI: Scope format check to commits unique to the PR Aug 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants