Skip to content

Commit 1601ba3

Browse files
authored
ci: use base repository branch for breaking change detector (#22006)
this is fixing the issue where forks have stale target branch (stale main) ## Which issue does this PR close? - Closes #22005 ## Rationale for this change Making breaking change detector work for stale repositories ## What changes are included in this PR? dont use `origin` as the remote but use the base repository as the origin ## Are these changes tested? manually ## Are there any user-facing changes? Nope
1 parent 9a29e33 commit 1601ba3

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

.github/workflows/breaking_changes_detector.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,22 @@ jobs:
5959
with:
6060
fetch-depth: 0
6161

62-
# For fork PRs, `origin` points to the fork, not the upstream repo.
63-
# Explicitly fetch the base branch from the upstream repo so we have
64-
# a valid baseline ref for both diff and semver-checks.
62+
# `origin` may point at a fork (when a contributor runs this locally) or
63+
# at a stale ref. Fetch the base branch from the PR's upstream repo into
64+
# a dedicated `apache/<base>` ref so the baseline is unambiguous and the
65+
# same ref name works locally (`git remote add apache ...`) and in CI.
6566
- name: Fetch base branch
6667
env:
6768
BASE_REF: ${{ github.base_ref }}
6869
REPO: ${{ github.repository }}
69-
run: git fetch "https://github.com/${REPO}.git" "${BASE_REF}:refs/remotes/origin/${BASE_REF}"
70+
run: git fetch "https://github.com/${REPO}.git" "${BASE_REF}:refs/remotes/apache/${BASE_REF}"
7071

7172
- name: Determine changed crates
7273
id: changed_crates
7374
env:
7475
BASE_REF: ${{ github.base_ref }}
7576
run: |
76-
PACKAGES=$(ci/scripts/changed_crates.sh changed-crates "origin/${BASE_REF}")
77+
PACKAGES=$(ci/scripts/changed_crates.sh changed-crates "apache/${BASE_REF}")
7778
echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT"
7879
echo "Changed crates: $PACKAGES"
7980
@@ -102,7 +103,8 @@ jobs:
102103
set +e
103104
# `tee` lets cargo's output stream live into the Actions log
104105
# while we also keep a copy for the PR comment.
105-
ci/scripts/changed_crates.sh semver-check "origin/${BASE_REF}" $PACKAGES \
106+
# Using `apache` remote here to point to the repository the pull request is against
107+
ci/scripts/changed_crates.sh semver-check "apache/${BASE_REF}" $PACKAGES \
106108
2>&1 | tee /tmp/semver-output.txt
107109
EXIT_CODE=${PIPESTATUS[0]}
108110
# Pass the result through an output instead of failing the job:

0 commit comments

Comments
 (0)