Skip to content

Commit

Permalink
ARROW-8097: [Dev] Comment bot's crossbow command acts on the master b…
Browse files Browse the repository at this point in the history
…ranch

It changes the previous behavior to clone the repository and branch referenced by the pull request as arrow and execute its crossbow command with its configuration files.

Closes #6599 from kszucs/ARROW-8097 and squashes the following commits:

1947547 <Krisztián Szűcs> use the crossbow.py from the PR
7868d39 <Krisztián Szűcs> move into the context mngr
7cbb683 <Krisztián Szűcs> use clone_url instead of the url referencing the api endpoint
b08caee <Krisztián Szűcs> clone arrow again with the PR's reference

Authored-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
Signed-off-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
  • Loading branch information
kszucs committed Mar 12, 2020
1 parent 6a6414e commit 8d967d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/comment_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ on:

jobs:

debug:
name: Debug
listen:
name: Listen!
runs-on: ubuntu-latest
steps:
- name: Checkout Arrow
uses: actions/checkout@v2
with:
path: arrow
# in order to generate version number based on git we need the tags
# fetched but checkout@v2 doesn't do that by default
- name: Featch Arrow tags
working-directory: arrow
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
# because libgit2 is a dependency of crossbow so prefer conda
- name: Setup Conda
uses: s-weigand/setup-conda@v1
Expand Down
31 changes: 23 additions & 8 deletions dev/archery/archery/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import shlex
from pathlib import Path
from functools import partial
import tempfile

import click
import github
Expand Down Expand Up @@ -258,20 +259,34 @@ def submit(obj, task, group, dry_run):
See groups defined in arrow/dev/tasks/tests.yml
"""
git = Git()

# construct crossbow arguments
args = []
for g in group:
args.extend(['-g', g])
for t in task:
args.append(t)

# clone crossbow
git = Git()
git.clone('https://github.com/{}'.format(obj['crossbow_repo']), 'crossbow')
# pygithub pull request object
pr = obj['pull']
crossbow_url = 'https://github.com/{}'.format(obj['crossbow_repo'])

with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
arrow = tmpdir / 'arrow'
queue = tmpdir / 'crossbow'

# clone arrow, crossbow and checkout the pull request's branch
git.clone('--branch', pr.head.ref, pr.head.repo.clone_url, str(arrow))
git.clone(crossbow_url, str(queue))

# submit the crossbow tasks
result = Path('result.yml').resolve()
xbow = Crossbow('arrow/dev/tasks/crossbow.py')
xbow.run('--output-file', str(result), 'submit', *args)
# submit the crossbow tasks
result = Path('result.yml').resolve()
xbow = Crossbow(str(arrow / 'dev' / 'tasks' / 'crossbow.py'))
xbow.run('--queue-path', str(queue),
'--output-file', str(result),
'submit', *args)

# parse the result yml describing the submitted job
yaml = YAML()
Expand All @@ -283,4 +298,4 @@ def submit(obj, task, group, dry_run):
response = formatter.render(job)

# send the response
obj['pull'].create_issue_comment(response)
pr.create_issue_comment(response)

0 comments on commit 8d967d0

Please sign in to comment.