Skip to content

Commit b567cf9

Browse files
Peter CollingbourneCommit Bot
Peter Collingbourne
authored and
Commit Bot
committed
Add a "buildbucket" subcommand to mb.
This subcommand prints the trybot configuration in the buildbucket.config format expected by gerrit. This should hopefully make it a little easier to maintain the buildbucket.config file. Bug: Change-Id: I7d956efb6c08128ae0ceaa6b68bcc9001296549c Reviewed-on: https://chromium-review.googlesource.com/568666 Reviewed-by: Dirk Pranke <dpranke@chromium.org> Commit-Queue: Peter Collingbourne <pcc@chromium.org> Cr-Commit-Position: refs/heads/master@{#491647}
1 parent 6a22805 commit b567cf9

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

tools/mb/docs/user_guide.md

+12
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ The `-f/--config-file` and `-q/--quiet` flags work as documented for
167167
This is mostly useful as a presubmit check and for verifying changes to
168168
the config file.
169169

170+
### `mb gerrit-buildbucket-config`
171+
172+
Generates a gerrit buildbucket configuration file and prints it to
173+
stdout. This file contains the list of trybots shown in gerrit's UI.
174+
175+
The master copy of the buildbucket.config file lives
176+
in a separate branch of the chromium repository. Run `mb
177+
gerrit-buildbucket-config > buildbucket.config.new && git fetch origin
178+
refs/meta/config:refs/remotes/origin/meta/config && git checkout
179+
-t -b meta_config origin/meta/config && mv buildbucket.config.new
180+
buildbucket.config` to update the file.
181+
170182
## Isolates and Swarming
171183

172184
`mb gen` is also responsible for generating the `.isolate` and

tools/mb/mb.py

+29
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(self):
5656
self.sep = os.sep
5757
self.args = argparse.Namespace()
5858
self.configs = {}
59+
self.luci_tryservers = {}
5960
self.masters = {}
6061
self.mixins = {}
6162

@@ -235,6 +236,14 @@ def AddCommonOptions(subp):
235236
' do compiles')
236237
subp.set_defaults(func=self.CmdAudit)
237238

239+
subp = subps.add_parser('gerrit-buildbucket-config',
240+
help='Print buildbucket.config for gerrit '
241+
'(see MB user guide)')
242+
subp.add_argument('-f', '--config-file', metavar='PATH',
243+
default=self.default_config,
244+
help='path to config file (default is %(default)s)')
245+
subp.set_defaults(func=self.CmdBuildbucket)
246+
238247
subp = subps.add_parser('help',
239248
help='Get help on a subcommand.')
240249
subp.add_argument(nargs='?', action='store', dest='subcommand',
@@ -368,6 +377,25 @@ def CmdRun(self):
368377

369378
return ret
370379

380+
def CmdBuildbucket(self):
381+
self.ReadConfigFile()
382+
383+
self.Print('# This file was generated using '
384+
'"tools/mb/mb.py gerrit-buildbucket-config".')
385+
386+
for luci_tryserver in sorted(self.luci_tryservers):
387+
self.Print('[bucket "luci.%s"]' % luci_tryserver)
388+
for bot in sorted(self.luci_tryservers[luci_tryserver]):
389+
self.Print('\tbuilder = %s' % bot)
390+
391+
for master in sorted(self.masters):
392+
if master.startswith('tryserver.'):
393+
self.Print('[bucket "master.%s"]' % master)
394+
for bot in sorted(self.masters[master]):
395+
self.Print('\tbuilder = %s' % bot)
396+
397+
return 0
398+
371399
def CmdValidate(self, print_ok=True):
372400
errs = []
373401

@@ -674,6 +702,7 @@ def ReadConfigFile(self):
674702
(self.args.config_file, e))
675703

676704
self.configs = contents['configs']
705+
self.luci_tryservers = contents['luci_tryservers']
677706
self.masters = contents['masters']
678707
self.mixins = contents['mixins']
679708

tools/mb/mb_config.pyl

+10
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@
520520
'cast_shell_audio_linux': 'cast_audio_release_trybot',
521521
'chromeos_amd64-generic_chromium_compile_only_ng': 'cros_chrome_sdk',
522522
'chromeos_daisy_chromium_compile_only_ng': 'cros_chrome_sdk',
523+
'chromium_presubmit': 'presubmit',
523524
'closure_compilation': 'closure_compilation',
524525
'fuchsia': 'release_trybot_fuchsia',
525526
'fuchsia_compile': 'release_trybot_fuchsia',
@@ -1409,6 +1410,11 @@
14091410
'ozone_linux', 'release_trybot',
14101411
],
14111412

1413+
'presubmit': [
1414+
# The chromium_presubmit bot does not use mb.
1415+
'error',
1416+
],
1417+
14121418
'release_afl_asan': [
14131419
'release', 'afl', 'asan', 'chromeos_codecs', 'pdf_xfa', 'disable_nacl',
14141420
],
@@ -1981,4 +1987,8 @@
19811987
'gn_args': 'target_cpu="x86"',
19821988
},
19831989
},
1990+
1991+
'luci_tryservers': {
1992+
'chromium.try': [ 'LUCI linux_chromium_rel_ng' ],
1993+
},
19841994
}

tools/mb/mb_unittest.py

+41
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def close(self):
122122
'fake_args_file_twice': 'args_file_twice',
123123
},
124124
},
125+
'luci_tryservers': {},
125126
'configs': {
126127
'args_file_goma': ['args_file', 'goma'],
127128
'args_file_twice': ['args_file', 'args_file'],
@@ -181,6 +182,7 @@ def close(self):
181182
'b': 'gn_rel_bot_2',
182183
},
183184
},
185+
'luci_tryservers': {},
184186
'mixins': {
185187
'gn': {'type': 'gn'},
186188
'chrome_with_codecs': {
@@ -205,6 +207,7 @@ def close(self):
205207
'fake_builder': 'fake_config',
206208
},
207209
},
210+
'luci_tryservers': {},
208211
'configs': {
209212
'fake_config': ['fake_mixin'],
210213
},
@@ -220,6 +223,28 @@ def close(self):
220223
}
221224
"""
222225

226+
TRYSERVER_CONFIG = """\
227+
{
228+
'masters': {
229+
'not_a_tryserver': {
230+
'fake_builder': 'fake_config',
231+
},
232+
'tryserver.chromium.linux': {
233+
'try_builder': 'fake_config',
234+
},
235+
'tryserver.chromium.mac': {
236+
'try_builder2': 'fake_config',
237+
},
238+
},
239+
'luci_tryservers': {
240+
'luci_tryserver1': ['luci_builder1'],
241+
'luci_tryserver2': ['luci_builder2'],
242+
},
243+
'configs': {},
244+
'mixins': {},
245+
}
246+
"""
247+
223248

224249
class UnitTest(unittest.TestCase):
225250
def fake_mbw(self, files=None, win32=False):
@@ -555,6 +580,22 @@ def test_gyp_env_hacks(self):
555580
"LLVM_FORCE_HEAD_REVISION=1\n"
556581
"python build/gyp_chromium -G output_dir=_path_\n"))
557582

583+
def test_buildbucket(self):
584+
mbw = self.fake_mbw()
585+
mbw.files[mbw.default_config] = TRYSERVER_CONFIG
586+
self.check(['gerrit-buildbucket-config'], mbw=mbw,
587+
ret=0,
588+
out=('# This file was generated using '
589+
'"tools/mb/mb.py gerrit-buildbucket-config".\n'
590+
'[bucket "luci.luci_tryserver1"]\n'
591+
'\tbuilder = luci_builder1\n'
592+
'[bucket "luci.luci_tryserver2"]\n'
593+
'\tbuilder = luci_builder2\n'
594+
'[bucket "master.tryserver.chromium.linux"]\n'
595+
'\tbuilder = try_builder\n'
596+
'[bucket "master.tryserver.chromium.mac"]\n'
597+
'\tbuilder = try_builder2\n'))
598+
558599

559600
if __name__ == '__main__':
560601
unittest.main()

0 commit comments

Comments
 (0)