Skip to content

Commit 55e65fa

Browse files
committed
crossbow command
1 parent 92568eb commit 55e65fa

File tree

4 files changed

+73
-77
lines changed

4 files changed

+73
-77
lines changed

dev/archery/archery/bot.py

Lines changed: 36 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
import shlex
219
from functools import partial
320

421
import click
522
import github
623

24+
from .utils.crossbow import Crossbow
25+
from .utils.git import Git
26+
727

828
class EventError(Exception):
929
pass
@@ -132,96 +152,39 @@ def bot(ctx):
132152
ctx.ensure_object(dict)
133153

134154

135-
# @ursabot.command()
136-
# @click.argument('baseline', type=str, metavar='[<baseline>]', default=None,
137-
# required=False)
138-
# @click.option('--suite-filter', metavar='<regex>', show_default=True,
139-
# type=str, default=None, help='Regex filtering benchmark suites.')
140-
# @click.option('--benchmark-filter', metavar='<regex>', show_default=True,
141-
# type=str, default=None,
142-
# help='Regex filtering benchmarks.')
143-
# def benchmark(baseline, suite_filter, benchmark_filter):
144-
# """Run the benchmark suite in comparison mode.
145-
146-
# This command will run the benchmark suite for tip of the branch commit
147-
# against `<baseline>` (or master if not provided).
148-
149-
# Examples:
150-
151-
# \b
152-
# # Run the all the benchmarks
153-
# @ursabot benchmark
154-
155-
# \b
156-
# # Compare only benchmarks where the name matches the /^Sum/ regex
157-
# @ursabot benchmark --benchmark-filter=^Sum
158-
159-
# \b
160-
# # Compare only benchmarks where the suite matches the /compute-/ regex.
161-
# # A suite is the C++ binary.
162-
# @ursabot benchmark --suite-filter=compute-
163-
164-
# \b
165-
# # Sometimes a new optimization requires the addition of new benchmarks to
166-
# # quantify the performance increase. When doing this be sure to add the
167-
# # benchmark in a separate commit before introducing the optimization.
168-
# #
169-
# # Note that specifying the baseline is the only way to compare using a new
170-
# # benchmark, since master does not contain the new benchmark and no
171-
# # comparison is possible.
172-
# #
173-
# # The following command compares the results of matching benchmarks,
174-
# # compiling against HEAD and the provided baseline commit, e.g. eaf8302.
175-
# # You can use this to quantify the performance improvement of new
176-
# # optimizations or to check for regressions.
177-
# @ursabot benchmark --benchmark-filter=MyBenchmark eaf8302
178-
# """
179-
# # each command must return a dictionary which are set as build properties
180-
# props = {'command': 'benchmark'}
181-
182-
# if baseline:
183-
# props['benchmark_baseline'] = baseline
184-
185-
# opts = []
186-
# if suite_filter:
187-
# suite_filter = shlex.quote(suite_filter)
188-
# opts.append(f'--suite-filter={suite_filter}')
189-
# if benchmark_filter:
190-
# benchmark_filter = shlex.quote(benchmark_filter)
191-
# opts.append(f'--benchmark-filter={benchmark_filter}')
192-
193-
# if opts:
194-
# props['benchmark_options'] = opts
195-
196-
# return props
197-
198-
199155
@bot.group()
200-
@click.option('--repo', '-r', default='ursa-labs/crossbow',
156+
@click.option('--arrow', '-a', default='apache/arrow',
157+
help='Arrow repository on github to use')
158+
@click.option('--crossbow', '-c', default='ursa-labs/crossbow',
201159
help='Crossbow repository on github to use')
202160
@click.pass_obj
203-
def crossbow(props, repo):
161+
def crossbow(obj, arrow, crossbow):
204162
"""Trigger crossbow builds for this pull request"""
205-
# TODO(kszucs): validate the repo format
206-
props['command'] = 'crossbow'
207-
props['crossbow_repo'] = repo # github user/repo
208-
props['crossbow_repository'] = f'https://github.com/{repo}' # git url
163+
obj['arrow_repo'] = 'https://github.com/{}'.format(arrow)
164+
obj['crossbow_repo'] = 'https://github.com/{}'.format(crossbow)
209165

210166

211167
@crossbow.command()
212168
@click.argument('task', nargs=-1, required=False)
213169
@click.option('--group', '-g', multiple=True,
214170
help='Submit task groups as defined in tests.yml')
171+
@click.option('--dry-run/--push', default=False,
172+
help='Just display the new changelog, don\'t write it')
215173
@click.pass_obj
216-
def submit(props, task, group):
174+
def submit(obj, task, group, dry_run):
217175
"""Submit crossbow testing tasks.
218176
219177
See groups defined in arrow/dev/tasks/tests.yml
220178
"""
221-
args = ['-c', 'tasks.yml']
179+
args = []
222180
for g in group:
223181
args.extend(['-g', g])
224182
for t in task:
225183
args.append(t)
226184

227-
return {'crossbow_args': args, **props}
185+
git = Git()
186+
xbow = Crossbow('arrow/dev/tasks/crossbow.py')
187+
188+
# git.clone(obj['arrow_repo'], 'arrow')
189+
# git.clone(obj['crossbow_repo'], 'crossbow')
190+
xbow.run('submit', *args)

dev/archery/archery/lang/python.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def _convert_typehint(tokens):
6363
# are not supported by _signature_fromstr
6464
yield (names[1].type, names[1].string)
6565
elif len(names) > 2:
66-
print(names)
6766
raise ValueError('More than two NAME tokens follow each other')
6867
names = []
6968
yield (token.type, token.string)

dev/archery/archery/tests/test_bot.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
from pathlib import Path
33
from unittest.mock import Mock
44

5-
import click
65
import pytest
76
import responses as rsps
8-
from archery.bot import CommentBot, CommandError, group
7+
import click
8+
from click.testing import CliRunner
9+
10+
from archery.bot import CommentBot, CommandError, group, bot
911

1012

1113
@pytest.fixture
@@ -186,4 +188,13 @@ def handler(command, **kwargs):
186188
bot.handle('issue_comment', payload)
187189

188190
post = responses.calls[3]
189-
assert json.loads(post.request.body) == {'content': reaction}
191+
assert json.loads(post.request.body) == {'content': reaction}
192+
193+
194+
# TODO(kszucs): properly mock it
195+
# def test_crossbow_submit():
196+
# runner = CliRunner()
197+
# result = runner.invoke(
198+
# bot, ['crossbow', 'submit', '-g', 'wheel', '--dry-run']
199+
# )
200+
# assert result.exit_code == 0
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from .command import Command, default_bin
19+
20+
21+
class Crossbow(Command):
22+
def __init__(self, crossbow_bin=None):
23+
self.bin = default_bin(crossbow_bin, "arrow/dev/tasks/crossbow.py")

0 commit comments

Comments
 (0)