Diff against merge-base in changed-files action#105
Open
Matt711 wants to merge 1 commit intorapidsai:mainfrom
Open
Diff against merge-base in changed-files action#105Matt711 wants to merge 1 commit intorapidsai:mainfrom
Matt711 wants to merge 1 commit intorapidsai:mainfrom
Conversation
The action passed `pr-info.base.sha` (the current tip of the base branch) as `base_sha` to step-security/changed-files, which performs a two-dot diff `base..head`. When the base branch advances after the PR branches, that diff includes upstream-only commits and falsely reports their files as changed in the PR — causing path-filtered jobs in consuming repos to fire even when no relevant files were touched. Compute `git merge-base` of base and head and pass that as `base_sha`, giving three-dot semantics. Fetch progressively deeper history (50 → 6400) until the merge-base is reachable, since the calling workflow's checkout is shallow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
changed-filesaction passedpr-info.base.sha(current tip of the base branch) asbase_shatostep-security/changed-files, which produces a two-dot diffbase..head. When the base branch advances after a PR branches, this diff falsely reports upstream-only commits' files as changed in the PR, defeating path-based job filtering in consuming repos.This switches the comparison to three-dot semantics by computing
git merge-base base headfirst and passing that asbase_sha. The calling workflow's checkout is shallow, so we fetch progressively deeper (50 → 6400 commits) until the merge-base is reachable, with a graceful fallback to the originalbase.shaif it isn't.Concrete example of the bug
cudf PR #22191 only touches 12 files under
python/cudf_polars/**, but the Apr 28 run firedconda-python-cudf-tests,wheel-tests-cudf,wheel-tests-dask-cudf,narwhals-tests,pandas-tests,unit-tests-cudf-pandas,third-party-integration-tests-cudf-pandas, etc. — all of which haveif:filters that should have skipped them.The
changed-filesjob'stransformed-outputshowed every grouptrue:Reproduced locally on the same SHAs:
d24f7703fa..bc584d76(two-dot, current behavior)d24f7703fa...bc584d76(three-dot, this PR)python/cudf_polars/**The merge-base resolves to
e0769e0don the first iteration at depth=50.Test plan
🤖 Generated with Claude Code