Skip to content

Commit d6d661d

Browse files
committed
apacheGH-39996: [Archery] Fix Crossbow build on a PR from a fork's main branch
Instead of doing an intermediate bare clone, just fix the locally created branch name when fetching. Amended from PR apache#39997, which wasn't sufficient (the `git fetch` that works for me doesn't seem to work on GHA).
1 parent 66351e3 commit d6d661d

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

.github/workflows/comment_bot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
ARROW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5252
CROSSBOW_GITHUB_TOKEN: ${{ secrets.CROSSBOW_GITHUB_TOKEN }}
5353
run: |
54-
archery trigger-bot \
54+
archery --debug trigger-bot \
5555
--event-name ${{ github.event_name }} \
5656
--event-payload ${{ github.event_path }}
5757

dev/archery/archery/bot.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ def crossbow(obj, crossbow):
324324
obj['crossbow_repo'] = crossbow
325325

326326

327-
def _clone_arrow_and_crossbow(dest, crossbow_repo, arrow_repo_url,
328-
pr_number, pr_branch):
327+
def _clone_arrow_and_crossbow(dest, crossbow_repo, arrow_repo_url, pr_number):
329328
"""
330329
Clone the repositories and initialize crossbow objects.
331330
@@ -335,23 +334,25 @@ def _clone_arrow_and_crossbow(dest, crossbow_repo, arrow_repo_url,
335334
Filesystem path to clone the repositories to.
336335
crossbow_repo : str
337336
GitHub repository name, like kszucs/crossbow.
338-
pull_request : pygithub.PullRequest
339-
Object containing information about the pull request the comment bot
340-
was triggered from.
337+
arrow_repo_url : str
338+
Target Apache Arrow repository's clone URL, such as
339+
"https://github.com/apache/arrow.git".
340+
pr_number : int
341+
Target PR number.
341342
"""
342-
bare_arrow_path = dest / 'arrow_bare'
343343
arrow_path = dest / 'arrow'
344344
queue_path = dest / 'crossbow'
345345

346+
# we use unique branch name instead of fork's branch name to avoid
347+
# branch name conflict such as 'main' (GH-39996)
348+
local_branch = f'archery/pr-{pr_number}'
346349
# 1. clone arrow and checkout the PR's branch
347-
pr_ref = f'pull/{pr_number}/head:{pr_branch}'
348-
# we do a bare clone of upstream arrow to avoid issues when the PR is
349-
# submitted from a fork's main branch (GH-39996)
350-
git.clone('--bare', arrow_repo_url, str(bare_arrow_path))
351-
# fetch the PR's branch into the bare clone
352-
git.fetch('origin', pr_ref, git_dir=bare_arrow_path)
353-
# clone and checkout the PR's branch into a full local repo
354-
git.clone(f'--branch={pr_branch}', bare_arrow_path, arrow_path)
350+
pr_ref = f'pull/{pr_number}/head:{local_branch}'
351+
git.clone('--no-checkout', arrow_repo_url, str(arrow_path))
352+
# fetch the PR's branch into the clone
353+
git.fetch('origin', pr_ref, git_dir=arrow_path)
354+
# checkout the PR's branch into the clone
355+
git.checkout(local_branch, git_dir=arrow_path)
355356

356357
# 2. clone crossbow repository
357358
crossbow_url = 'https://github.com/{}'.format(crossbow_repo)
@@ -391,7 +392,6 @@ def submit(obj, tasks, groups, params, arrow_version, wait):
391392
crossbow_repo=crossbow_repo,
392393
arrow_repo_url=pull_request.base.repo.clone_url,
393394
pr_number=pull_request.number,
394-
pr_branch=pull_request.head.ref,
395395
)
396396
# load available tasks configuration and groups from yaml
397397
config = Config.load_yaml(arrow.path / "dev" / "tasks" / "tasks.yml")

0 commit comments

Comments
 (0)