From 71184c0099054a47ff296a928fe8574fff912058 Mon Sep 17 00:00:00 2001 From: "tandrii@chromium.org" Date: Wed, 13 Jan 2016 15:18:44 +0000 Subject: [PATCH] git cl try: load trybot list from cq.cfg by default. This allows "git cl try" to just work for projects without any PRESUBMIT but with cq.cfg in default location (infra/config/cq.cfg). This also ships all presubmit bots, since these usually fail LGTM checks anyway. BUG=522909 Review URL: https://codereview.chromium.org/1579423004 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298251 0039d316-1c4b-4281-b951-d872f2087c98 --- commit_queue.py | 33 +++++++++++++++++++-------------- git_cl.py | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/commit_queue.py b/commit_queue.py index 61e4d2fd6..c950db68c 100755 --- a/commit_queue.py +++ b/commit_queue.py @@ -104,6 +104,24 @@ def set_commit(obj, issue, flag): return 0 _apply_on_issue(_set_commit, obj, issue) + +def get_master_builder_map(config_path): + """Returns a map of master -> [builders] from cq config.""" + with open(config_path) as config_file: + cq_config = config_file.read() + + config = cq_pb2.Config() + text_format.Merge(cq_config, config) + masters = {} + if config.HasField('verifiers') and config.verifiers.HasField('try_job'): + for bucket in config.verifiers.try_job.buckets: + masters.setdefault(bucket.name, []) + for builder in bucket.builders: + if not builder.HasField('experiment_percentage'): + masters[bucket.name].append(builder.name) + return masters + + @need_issue def CMDset(parser, args): """Sets the commit bit.""" @@ -147,20 +165,7 @@ def CMDbuilders(parser, args): if len(args) != 1: parser.error('Expected a single path to CQ config. Got: %s' % ' '.join(args)) - - with open(args[0]) as config_file: - cq_config = config_file.read() - - config = cq_pb2.Config() - text_format.Merge(cq_config, config) - masters = {} - if config.HasField('verifiers') and config.verifiers.HasField('try_job'): - for bucket in config.verifiers.try_job.buckets: - masters.setdefault(bucket.name, []) - for builder in bucket.builders: - if not builder.HasField('experiment_percentage'): - masters[bucket.name].append(builder.name) - print json.dumps(masters) + print json.dumps(get_master_builder_map(args[0])) CMDbuilders.func_usage_more = '' diff --git a/git_cl.py b/git_cl.py index 49bed386b..e99509f19 100755 --- a/git_cl.py +++ b/git_cl.py @@ -42,6 +42,7 @@ import auth from luci_hacks import trigger_luci_job as luci_trigger import breakpad # pylint: disable=W0611 import clang_format +import commit_queue import dart_format import fix_encoding import gclient_utils @@ -3205,6 +3206,24 @@ def CMDtry(parser, args): None, options.verbose, sys.stdout) + + if not options.bot: + # Get try masters from cq.cfg if any. + # TODO(tandrii): some (but very few) projects store cq.cfg in different + # location. + cq_cfg = os.path.join(change.RepositoryRoot(), + 'infra', 'config', 'cq.cfg') + if os.path.exists(cq_cfg): + masters = {} + cq_masters = commit_queue.get_master_builder_map(cq_cfg) + for master, builders in cq_masters.iteritems(): + for builder in builders: + # Skip presubmit builders, because these will fail without LGTM. + if 'presubmit' not in builder.lower(): + masters.setdefault(master, {})[builder] = ['defaulttests'] + if masters: + return masters + if not options.bot: parser.error('No default try builder to try, use --bot')