Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ jobs:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then
echo "IS_FORK_PR=true" >> "${GITHUB_ENV}"
# Fork PRs need full history to find the merge base
echo "GIT_FETCH_DEPTH=0" >> "${GITHUB_ENV}"
else
echo "IS_FORK_PR=false" >> "${GITHUB_ENV}"
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
fi
else
echo "IS_FORK_PR=false" >> "${GITHUB_ENV}"
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Check out the revision with minimal required history
Expand Down Expand Up @@ -75,7 +83,12 @@ jobs:
- name: Calculate base ref
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
git fetch --depth=1 origin "${{ github.event.pull_request.base.sha }}"
if [ "$IS_FORK_PR" == "true" ]; then
# Fork PR: full history already fetched, just ensure the base SHA is available
git fetch origin "${{ github.event.pull_request.base.sha }}"
else
git fetch --depth=1 origin "${{ github.event.pull_request.base.sha }}"
fi
BASE_REF="${{ github.event.pull_request.base.sha }}"
else
BASE_REF="HEAD~1"
Expand Down Expand Up @@ -282,8 +295,16 @@ jobs:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then
echo "IS_FORK_PR=true" >> "${GITHUB_ENV}"
# Fork PRs need full history to find the merge base
echo "GIT_FETCH_DEPTH=0" >> "${GITHUB_ENV}"
else
echo "IS_FORK_PR=false" >> "${GITHUB_ENV}"
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
fi
else
echo "IS_FORK_PR=false" >> "${GITHUB_ENV}"
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Check out the revision with minimal required history
Expand Down Expand Up @@ -327,7 +348,12 @@ jobs:
tests/component/:: -- -v
else
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
git fetch --depth=1 origin "${{ github.event.pull_request.base.sha }}"
if [ "$IS_FORK_PR" == "true" ]; then
# Fork PR: full history already fetched, just ensure the base SHA is available
git fetch origin "${{ github.event.pull_request.base.sha }}"
else
git fetch --depth=1 origin "${{ github.event.pull_request.base.sha }}"
fi
BASE_REF="${{ github.event.pull_request.base.sha }}"
else
BASE_REF="HEAD~1"
Expand Down
1 change: 1 addition & 0 deletions changes/9617.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use full git clone for fork PRs to fix merge-base computation failure in CI.
Loading