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+
118import shlex
219from functools import partial
320
421import click
522import github
623
24+ from .utils .crossbow import Crossbow
25+ from .utils .git import Git
26+
727
828class 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 )
0 commit comments