blob: 7581d6d4b34861dc05979f08a6a77f43ddd40535 [file] [log] [blame]
Mike Frysingere58c0e22017-10-04 15:43:30 -04001# -*- coding: utf-8 -*-
Don Garrettc4114cc2016-11-01 20:04:06 -07002# Copyright 2016 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Bootstrap for cbuildbot.
7
8This script is intended to checkout chromite on the branch specified by -b or
9--branch (as normally accepted by cbuildbot), and then invoke cbuildbot. Most
10arguments are not parsed, only passed along. If a branch is not specified, this
11script will use 'master'.
12
13Among other things, this allows us to invoke build configs that exist on a given
14branch, but not on TOT.
15"""
16
17from __future__ import print_function
18
Don Garrett125d4dc2017-04-25 16:26:03 -070019import functools
Don Garrettc4114cc2016-11-01 20:04:06 -070020import os
21
22from chromite.cbuildbot import repository
Don Garrett597ddff2017-02-17 18:29:37 -080023from chromite.cbuildbot.stages import sync_stages
Don Garrett86881cb2017-02-15 15:41:55 -080024from chromite.lib import config_lib
Don Garretta50bf492017-09-28 18:33:02 -070025from chromite.lib import constants
Don Garrettc4114cc2016-11-01 20:04:06 -070026from chromite.lib import cros_build_lib
27from chromite.lib import cros_logging as logging
Don Garrettacbb2392017-05-11 18:27:41 -070028from chromite.lib import metrics
Don Garrettc4114cc2016-11-01 20:04:06 -070029from chromite.lib import osutils
Don Garrettacbb2392017-05-11 18:27:41 -070030from chromite.lib import ts_mon_config
Don Garrett86881cb2017-02-15 15:41:55 -080031from chromite.scripts import cbuildbot
Don Garrettc4114cc2016-11-01 20:04:06 -070032
Don Garrett597ddff2017-02-17 18:29:37 -080033
Don Garrett60967922017-04-12 18:51:44 -070034# This number should be incremented when we change the layout of the buildroot
35# in a non-backwards compatible way. This wipes all buildroots.
Don Garrettbf90cdf2017-05-19 15:54:02 -070036BUILDROOT_BUILDROOT_LAYOUT = 2
Don Garrett60967922017-04-12 18:51:44 -070037
Don Garrettacbb2392017-05-11 18:27:41 -070038# Metrics reported to Monarch.
Don Garrett45e77412017-06-14 16:57:55 -070039METRIC_ACTIVE = 'chromeos/chromite/cbuildbot_launch/active'
Don Garrettacbb2392017-05-11 18:27:41 -070040METRIC_INVOKED = 'chromeos/chromite/cbuildbot_launch/invoked'
41METRIC_COMPLETED = 'chromeos/chromite/cbuildbot_launch/completed'
42METRIC_PREP = 'chromeos/chromite/cbuildbot_launch/prep_completed'
43METRIC_CLEAN = 'chromeos/chromite/cbuildbot_launch/clean_buildroot_durations'
44METRIC_INITIAL = 'chromeos/chromite/cbuildbot_launch/initial_checkout_durations'
45METRIC_CBUILDBOT = 'chromeos/chromite/cbuildbot_launch/cbuildbot_durations'
46METRIC_CLOBBER = 'chromeos/chromite/cbuildbot_launch/clobber'
47METRIC_BRANCH_CLEANUP = 'chromeos/chromite/cbuildbot_launch/branch_cleanup'
Don Garrett066e6f52017-09-28 19:14:01 -070048METRIC_DEPOT_TOOLS = 'chromeos/chromite/cbuildbot_launch/depot_tools_prep'
Don Garrettacbb2392017-05-11 18:27:41 -070049
Don Garrett60967922017-04-12 18:51:44 -070050
Don Garrett125d4dc2017-04-25 16:26:03 -070051def StageDecorator(functor):
52 """A Decorator that adds buildbot stage tags around a method.
53
Don Garrettacbb2392017-05-11 18:27:41 -070054 It uses the method name as the stage name, and assumes failure on a true
55 return value, or an exception.
Don Garrett125d4dc2017-04-25 16:26:03 -070056 """
57 @functools.wraps(functor)
58 def wrapped_functor(*args, **kwargs):
59 try:
60 logging.PrintBuildbotStepName(functor.__name__)
Don Garrettacbb2392017-05-11 18:27:41 -070061 result = functor(*args, **kwargs)
Don Garrett125d4dc2017-04-25 16:26:03 -070062 except Exception:
63 logging.PrintBuildbotStepFailure()
64 raise
65
Don Garrettacbb2392017-05-11 18:27:41 -070066 if result:
67 logging.PrintBuildbotStepFailure()
68 return result
69
Don Garrett125d4dc2017-04-25 16:26:03 -070070 return wrapped_functor
71
72
Don Garrettacbb2392017-05-11 18:27:41 -070073def field(fields, **kwargs):
74 """Helper for inserting more fields into a metrics fields dictionary.
75
76 Args:
77 fields: Dictionary of metrics fields.
78 kwargs: Each argument is a key/value pair to insert into dict.
79
80 Returns:
81 Copy of original dictionary with kwargs set as fields.
82 """
83 f = fields.copy()
84 f.update(kwargs)
85 return f
86
Don Garretta50bf492017-09-28 18:33:02 -070087
88def PrependPath(prepend):
89 """Generate path with new directory at the beginning.
90
91 Args:
92 prepend: Directory to add at the beginning of the path.
93
94 Returns:
95 Extended path as a string.
96 """
97 return os.pathsep.join([prepend, os.environ.get('PATH', os.defpath)])
98
99
Don Garrett86881cb2017-02-15 15:41:55 -0800100def PreParseArguments(argv):
Don Garrettc4114cc2016-11-01 20:04:06 -0700101 """Extract the branch name from cbuildbot command line arguments.
102
Don Garrettc4114cc2016-11-01 20:04:06 -0700103 Args:
104 argv: The command line arguments to parse.
105
106 Returns:
107 Branch as a string ('master' if nothing is specified).
108 """
Don Garrett86881cb2017-02-15 15:41:55 -0800109 parser = cbuildbot.CreateParser()
Mike Frysinger80bba8a2017-08-18 15:28:36 -0400110 options = cbuildbot.ParseCommandLine(parser, argv)
Don Garrettd1d90dd2017-06-13 17:35:52 -0700111 options.Freeze()
Don Garrett86881cb2017-02-15 15:41:55 -0800112
113 # This option isn't required for cbuildbot, but is for us.
114 if not options.buildroot:
115 cros_build_lib.Die('--buildroot is a required option.')
116
117 return options
Don Garrettc4114cc2016-11-01 20:04:06 -0700118
119
Don Garrettbf90cdf2017-05-19 15:54:02 -0700120def GetState(root):
121 """Fetch the current state of our working directory.
122
123 Will return with a default result if there is no known state.
124
125 Args:
126 root: Root of the working directory tree as a string.
127
128 Returns:
129 Layout version as an integer (0 for unknown).
130 Previous branch as a string ('' for unknown).
131 """
132 state_file = os.path.join(root, '.cbuildbot_launch_state')
Don Garrett60967922017-04-12 18:51:44 -0700133
134 try:
135 state = osutils.ReadFile(state_file)
136 buildroot_layout, branchname = state.split()
137 buildroot_layout = int(buildroot_layout)
138 return buildroot_layout, branchname
139 except (IOError, ValueError):
140 # If we are unable to either read or parse the state file, we get here.
141 return 0, ''
142
143
Don Garrettbf90cdf2017-05-19 15:54:02 -0700144def SetState(branchname, root):
145 """Save the current state of our working directory.
146
147 Args:
148 branchname: Name of branch we prepped for as a string.
149 root: Root of the working directory tree as a string.
150 """
Don Garrett60967922017-04-12 18:51:44 -0700151 assert branchname
Don Garrettbf90cdf2017-05-19 15:54:02 -0700152 state_file = os.path.join(root, '.cbuildbot_launch_state')
Don Garrett60967922017-04-12 18:51:44 -0700153 new_state = '%d %s' % (BUILDROOT_BUILDROOT_LAYOUT, branchname)
154 osutils.WriteFile(state_file, new_state)
155
156
Don Garrett125d4dc2017-04-25 16:26:03 -0700157@StageDecorator
Don Garrettbf90cdf2017-05-19 15:54:02 -0700158def CleanBuildRoot(root, repo, metrics_fields):
Don Garrett7ade05a2017-02-17 13:31:47 -0800159 """Some kinds of branch transitions break builds.
160
Don Garrettbf90cdf2017-05-19 15:54:02 -0700161 This method ensures that cbuildbot's buildroot is a clean checkout on the
162 given branch when it starts. If necessary (a branch transition) it will wipe
163 assorted state that cannot be safely reused from the previous build.
Don Garrett7ade05a2017-02-17 13:31:47 -0800164
Don Garrett7ade05a2017-02-17 13:31:47 -0800165 Args:
Don Garrettbf90cdf2017-05-19 15:54:02 -0700166 root: Root directory owned by cbuildbot_launch.
Don Garrettf324bc32017-05-23 14:00:53 -0700167 repo: repository.RepoRepository instance.
Don Garrettacbb2392017-05-11 18:27:41 -0700168 metrics_fields: Dictionary of fields to include in metrics.
Don Garrett7ade05a2017-02-17 13:31:47 -0800169 """
Don Garrettbf90cdf2017-05-19 15:54:02 -0700170 old_buildroot_layout, old_branch = GetState(root)
Don Garrette17e1d92017-04-12 15:28:19 -0700171
Don Garrett60967922017-04-12 18:51:44 -0700172 if old_buildroot_layout != BUILDROOT_BUILDROOT_LAYOUT:
Don Garrett125d4dc2017-04-25 16:26:03 -0700173 logging.PrintBuildbotStepText('Unknown layout: Wiping buildroot.')
Don Garrettacbb2392017-05-11 18:27:41 -0700174 metrics.Counter(METRIC_CLOBBER).increment(
175 field(metrics_fields, reason='layout_change'))
Benjamin Gordon59ba2f82017-08-28 15:31:06 -0600176 chroot_dir = os.path.join(root, 'chroot')
177 if os.path.exists(chroot_dir) or os.path.exists(chroot_dir + '.img'):
178 cros_build_lib.CleanupChrootMount(chroot_dir, delete_image=True)
Don Garrettbf90cdf2017-05-19 15:54:02 -0700179 osutils.RmDir(root, ignore_missing=True, sudo=True)
Don Garrettf324bc32017-05-23 14:00:53 -0700180 else:
181 if old_branch != repo.branch:
182 logging.PrintBuildbotStepText('Branch change: Cleaning buildroot.')
183 logging.info('Unmatched branch: %s -> %s', old_branch, repo.branch)
Don Garrettacbb2392017-05-11 18:27:41 -0700184 metrics.Counter(METRIC_BRANCH_CLEANUP).increment(
185 field(metrics_fields, old_branch=old_branch))
Don Garrett39963602017-02-27 14:41:58 -0800186
Don Garrettf324bc32017-05-23 14:00:53 -0700187 logging.info('Remove Chroot.')
Benjamin Gordon59ba2f82017-08-28 15:31:06 -0600188 chroot_dir = os.path.join(repo.directory, 'chroot')
189 if os.path.exists(chroot_dir) or os.path.exists(chroot_dir + '.img'):
190 cros_build_lib.CleanupChrootMount(chroot_dir, delete_image=True)
191 osutils.RmDir(chroot_dir, ignore_missing=True, sudo=True)
Don Garrett7ade05a2017-02-17 13:31:47 -0800192
Don Garrettf324bc32017-05-23 14:00:53 -0700193 logging.info('Remove Chrome checkout.')
Don Garrettbf90cdf2017-05-19 15:54:02 -0700194 osutils.RmDir(os.path.join(repo.directory, '.cache', 'distfiles'),
Don Garrettf324bc32017-05-23 14:00:53 -0700195 ignore_missing=True, sudo=True)
196
197 try:
198 # If there is any failure doing the cleanup, wipe everything.
199 repo.BuildRootGitCleanup(prune_all=True)
200 except Exception:
201 logging.info('Checkout cleanup failed, wiping buildroot:', exc_info=True)
Don Garrettacbb2392017-05-11 18:27:41 -0700202 metrics.Counter(METRIC_CLOBBER).increment(
203 field(metrics_fields, reason='repo_cleanup_failure'))
Don Garrettbf90cdf2017-05-19 15:54:02 -0700204 repository.ClearBuildRoot(repo.directory)
Don Garrett39963602017-02-27 14:41:58 -0800205
Don Garrettbf90cdf2017-05-19 15:54:02 -0700206 # Ensure buildroot exists. Save the state we are prepped for.
207 osutils.SafeMakedirs(repo.directory)
208 SetState(repo.branch, root)
Don Garrett7ade05a2017-02-17 13:31:47 -0800209
210
Don Garrett125d4dc2017-04-25 16:26:03 -0700211@StageDecorator
Don Garrettf324bc32017-05-23 14:00:53 -0700212def InitialCheckout(repo):
Don Garrett86881cb2017-02-15 15:41:55 -0800213 """Preliminary ChromeOS checkout.
214
215 Perform a complete checkout of ChromeOS on the specified branch. This does NOT
216 match what the build needs, but ensures the buildroot both has a 'hot'
217 checkout, and is close enough that the branched cbuildbot can successfully get
218 the right checkout.
219
220 This checks out full ChromeOS, even if a ChromiumOS build is going to be
221 performed. This is because we have no knowledge of the build config to be
222 used.
Don Garrettc4114cc2016-11-01 20:04:06 -0700223
224 Args:
Don Garrettf324bc32017-05-23 14:00:53 -0700225 repo: repository.RepoRepository instance.
Don Garrettc4114cc2016-11-01 20:04:06 -0700226 """
Don Garrettf324bc32017-05-23 14:00:53 -0700227 logging.PrintBuildbotStepText('Branch: %s' % repo.branch)
Don Garrett7ade05a2017-02-17 13:31:47 -0800228 logging.info('Bootstrap script starting initial sync on branch: %s',
Don Garrettf324bc32017-05-23 14:00:53 -0700229 repo.branch)
Don Garrett76496912017-05-11 16:59:11 -0700230 repo.Sync(detach=True)
Don Garrettc4114cc2016-11-01 20:04:06 -0700231
232
Don Garrett125d4dc2017-04-25 16:26:03 -0700233@StageDecorator
Don Garrett066e6f52017-09-28 19:14:01 -0700234def DepotToolsEnsureBootstrap(depot_tools_path):
235 """Start cbuildbot in specified directory with all arguments.
236
237 Args:
238 buildroot: Directory to be passed to cbuildbot with --buildroot.
239 depot_tools_path: Directory for depot_tools to be used by cbuildbot.
240 argv: Command line options passed to cbuildbot_launch.
241
242 Returns:
243 Return code of cbuildbot as an integer.
244 """
245 ensure_bootstrap_script = os.path.join(depot_tools_path, 'ensure_bootstrap')
246 if os.path.exists(ensure_bootstrap_script):
247 extra_env = {'PATH': PrependPath(depot_tools_path)}
248 cros_build_lib.RunCommand(
249 [ensure_bootstrap_script], extra_env=extra_env, cwd=depot_tools_path)
250 else:
251 # This is normal when checking out branches older than this script.
252 logging.warn('ensure_bootstrap not found, skipping: %s',
253 ensure_bootstrap_script)
254
255
256@StageDecorator
Don Garretta50bf492017-09-28 18:33:02 -0700257def RunCbuildbot(buildroot, depot_tools_path, argv):
Don Garrettc4114cc2016-11-01 20:04:06 -0700258 """Start cbuildbot in specified directory with all arguments.
259
260 Args:
Don Garrettbf90cdf2017-05-19 15:54:02 -0700261 buildroot: Directory to be passed to cbuildbot with --buildroot.
Don Garretta50bf492017-09-28 18:33:02 -0700262 depot_tools_path: Directory for depot_tools to be used by cbuildbot.
Don Garrettd1d90dd2017-06-13 17:35:52 -0700263 argv: Command line options passed to cbuildbot_launch.
Don Garrettc4114cc2016-11-01 20:04:06 -0700264
265 Returns:
266 Return code of cbuildbot as an integer.
267 """
Don Garrettbf90cdf2017-05-19 15:54:02 -0700268 logging.info('Bootstrap cbuildbot in: %s', buildroot)
Don Garrettbf90cdf2017-05-19 15:54:02 -0700269
Don Garrettd1d90dd2017-06-13 17:35:52 -0700270 # Fixup buildroot parameter.
271 argv = argv[:]
272 for i in xrange(len(argv)):
273 if argv[i] in ('-r', '--buildroot'):
274 argv[i+1] = buildroot
Don Garrett597ddff2017-02-17 18:29:37 -0800275
Don Garrettd1d90dd2017-06-13 17:35:52 -0700276 # This filters out command line arguments not supported by older versions
277 # of cbuildbot.
278 parser = cbuildbot.CreateParser()
Mike Frysinger80bba8a2017-08-18 15:28:36 -0400279 options = cbuildbot.ParseCommandLine(parser, argv)
Don Garrettd1d90dd2017-06-13 17:35:52 -0700280 cbuildbot_path = os.path.join(buildroot, 'chromite', 'bin', 'cbuildbot')
Don Garrett597ddff2017-02-17 18:29:37 -0800281 cmd = sync_stages.BootstrapStage.FilterArgsForTargetCbuildbot(
Don Garrettbf90cdf2017-05-19 15:54:02 -0700282 buildroot, cbuildbot_path, options)
Don Garrett597ddff2017-02-17 18:29:37 -0800283
Don Garretta50bf492017-09-28 18:33:02 -0700284 # We want cbuildbot to use branched depot_tools scripts from our manifest,
285 # so that depot_tools is branched to match cbuildbot.
286 logging.info('Adding depot_tools into PATH: %s', depot_tools_path)
287 extra_env = {'PATH': PrependPath(depot_tools_path)}
288
289 result = cros_build_lib.RunCommand(
290 cmd, extra_env=extra_env, error_code_ok=True, cwd=buildroot)
Don Garrettacbb2392017-05-11 18:27:41 -0700291 return result.returncode
Don Garrettc4114cc2016-11-01 20:04:06 -0700292
Don Garrett60967922017-04-12 18:51:44 -0700293
Don Garrett90c9da22017-09-12 16:45:40 -0700294def _InstallSystemCrcmodIfNeeded():
295 """Install Crcmod binary extension if needed.
296
297 If the build host has python-crcmod installed without the binary extension,
298 that breaks some versions of gsutil. In that case, this function installs
299 a new copy of the module with the extension.
300
301 Newer branches workaround this in gs.py, and hopefully future versions of
302 gsutil will work around this in gsutil, however, older branches will always
303 have this problem.
304
305 So... this method will always be required unless/until we chose to solve this
306 through configuration management of hosts.
307
308 http://crbug.com/763438 covers this in detail.
309 """
310 try:
311 import crcmod
312 # If crcmod exists on the system, but doesn't have the binary extension,
313 # gsutil behaves badly. Override the system module with one that contains
314 # the binary extension. This depends on /usr/local/lib overridding /usr/lib.
315 if not (getattr(crcmod, 'crcmod', None) and
316 getattr(crcmod.crcmod, '_usingExtension', None)):
317 logging.warn('FORCING CRCMOD INSTALL to workaround crbug.com/763438.')
318 cmd = ['pip', 'install', '--ignore-installed', 'crcmod']
319 result = cros_build_lib.SudoRunCommand(
320 cmd, error_code_ok=True, mute_output=True)
321 logging.warn('CRCMOD INSTALL RETURNED :%d', result.returncode)
322 except ImportError:
323 # If crcmod doesn't exist on the system, gs.py will properly use its
324 # version in the cache.
325 pass
326
327
Don Garrettf15d65b2017-04-12 12:39:55 -0700328def ConfigureGlobalEnvironment():
329 """Setup process wide environmental changes."""
Don Garrettf15d65b2017-04-12 12:39:55 -0700330 # Set umask to 022 so files created by buildbot are readable.
331 os.umask(0o22)
332
Don Garrett86fec482017-05-17 18:13:33 -0700333 # These variables can interfere with LANG / locale behavior.
334 unwanted_local_vars = [
335 'LC_ALL', 'LC_CTYPE', 'LC_COLLATE', 'LC_TIME', 'LC_NUMERIC',
336 'LC_MONETARY', 'LC_MESSAGES', 'LC_PAPER', 'LC_NAME', 'LC_ADDRESS',
337 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',
338 ]
339 for v in unwanted_local_vars:
340 os.environ.pop(v, None)
341
342 # This variable is required for repo sync's to work in all cases.
343 os.environ['LANG'] = 'en_US.UTF-8'
344
Don Garrett90c9da22017-09-12 16:45:40 -0700345 _InstallSystemCrcmodIfNeeded()
Don Garrett90f5e7d2017-09-08 17:42:46 -0700346
Don Garrettc4114cc2016-11-01 20:04:06 -0700347
Don Garrettacbb2392017-05-11 18:27:41 -0700348def _main(argv):
Don Garrettc4114cc2016-11-01 20:04:06 -0700349 """main method of script.
350
351 Args:
352 argv: All command line arguments to pass as list of strings.
353
354 Returns:
355 Return code of cbuildbot as an integer.
356 """
Don Garrettd1d90dd2017-06-13 17:35:52 -0700357 options = PreParseArguments(argv)
358
359 branchname = options.branch or 'master'
360 root = options.buildroot
361 buildroot = os.path.join(root, 'repository')
Don Garretta50bf492017-09-28 18:33:02 -0700362 depot_tools_path = os.path.join(buildroot, constants.DEPOT_TOOLS_SUBPATH)
Don Garrettd1d90dd2017-06-13 17:35:52 -0700363
364 metrics_fields = {
365 'branch_name': branchname,
Don Garrettf0761152017-10-19 19:38:27 -0700366 'build_config': options.build_config_name,
Don Garrettd1d90dd2017-06-13 17:35:52 -0700367 'tryjob': options.remote_trybot,
368 }
Don Garrettf15d65b2017-04-12 12:39:55 -0700369
Don Garrettacbb2392017-05-11 18:27:41 -0700370 # Does the entire build pass or fail.
Don Garrett45e77412017-06-14 16:57:55 -0700371 with metrics.Presence(METRIC_ACTIVE, metrics_fields), \
372 metrics.SuccessCounter(METRIC_COMPLETED, metrics_fields) as s_fields:
Don Garrettc4114cc2016-11-01 20:04:06 -0700373
Don Garrettacbb2392017-05-11 18:27:41 -0700374 # Preliminary set, mostly command line parsing.
Don Garrettd1d90dd2017-06-13 17:35:52 -0700375 with metrics.SuccessCounter(METRIC_INVOKED, metrics_fields):
Don Garrettfbbccec2017-09-20 14:04:48 -0700376 if options.enable_buildbot_tags:
377 logging.EnableBuildbotMarkers()
Don Garrettacbb2392017-05-11 18:27:41 -0700378 ConfigureGlobalEnvironment()
Don Garrett86881cb2017-02-15 15:41:55 -0800379
Don Garrettacbb2392017-05-11 18:27:41 -0700380 # Prepare the buildroot with source for the build.
381 with metrics.SuccessCounter(METRIC_PREP, metrics_fields):
382 site_config = config_lib.GetConfig()
383 manifest_url = site_config.params['MANIFEST_INT_URL']
384 repo = repository.RepoRepository(manifest_url, buildroot,
385 branch=branchname,
Don Garrettd1d90dd2017-06-13 17:35:52 -0700386 git_cache_dir=options.git_cache_dir)
Don Garrett86881cb2017-02-15 15:41:55 -0800387
Don Garrettacbb2392017-05-11 18:27:41 -0700388 # Clean up the buildroot to a safe state.
389 with metrics.SecondsTimer(METRIC_CLEAN, fields=metrics_fields):
Don Garrettbf90cdf2017-05-19 15:54:02 -0700390 CleanBuildRoot(root, repo, metrics_fields)
Don Garrettacbb2392017-05-11 18:27:41 -0700391
Don Garretta50bf492017-09-28 18:33:02 -0700392 # Get a checkout close enough to the branch that cbuildbot can handle it.
Don Garrettacbb2392017-05-11 18:27:41 -0700393 with metrics.SecondsTimer(METRIC_INITIAL, fields=metrics_fields):
394 InitialCheckout(repo)
395
Don Garrett066e6f52017-09-28 19:14:01 -0700396 # Get a checkout close enough to the branch that cbuildbot can handle it.
397 with metrics.SecondsTimer(METRIC_DEPOT_TOOLS, fields=metrics_fields):
398 DepotToolsEnsureBootstrap(depot_tools_path)
399
Don Garrettacbb2392017-05-11 18:27:41 -0700400 # Run cbuildbot inside the full ChromeOS checkout, on the specified branch.
401 with metrics.SecondsTimer(METRIC_CBUILDBOT, fields=metrics_fields):
Don Garretta50bf492017-09-28 18:33:02 -0700402 result = RunCbuildbot(buildroot, depot_tools_path, argv)
Don Garrettd1d90dd2017-06-13 17:35:52 -0700403 s_fields['success'] = (result == 0)
Don Garrettacbb2392017-05-11 18:27:41 -0700404 return result
405
406
407def main(argv):
408 # Enable Monarch metrics gathering.
409 with ts_mon_config.SetupTsMonGlobalState('cbuildbot_launch', indirect=True):
410 return _main(argv)