Commit b567cf95 authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Commit Bot

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/568666Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491647}
parent 6a22805c
...@@ -167,6 +167,18 @@ The `-f/--config-file` and `-q/--quiet` flags work as documented for ...@@ -167,6 +167,18 @@ The `-f/--config-file` and `-q/--quiet` flags work as documented for
This is mostly useful as a presubmit check and for verifying changes to This is mostly useful as a presubmit check and for verifying changes to
the config file. the config file.
### `mb gerrit-buildbucket-config`
Generates a gerrit buildbucket configuration file and prints it to
stdout. This file contains the list of trybots shown in gerrit's UI.
The master copy of the buildbucket.config file lives
in a separate branch of the chromium repository. Run `mb
gerrit-buildbucket-config > buildbucket.config.new && git fetch origin
refs/meta/config:refs/remotes/origin/meta/config && git checkout
-t -b meta_config origin/meta/config && mv buildbucket.config.new
buildbucket.config` to update the file.
## Isolates and Swarming ## Isolates and Swarming
`mb gen` is also responsible for generating the `.isolate` and `mb gen` is also responsible for generating the `.isolate` and
......
...@@ -56,6 +56,7 @@ class MetaBuildWrapper(object): ...@@ -56,6 +56,7 @@ class MetaBuildWrapper(object):
self.sep = os.sep self.sep = os.sep
self.args = argparse.Namespace() self.args = argparse.Namespace()
self.configs = {} self.configs = {}
self.luci_tryservers = {}
self.masters = {} self.masters = {}
self.mixins = {} self.mixins = {}
...@@ -235,6 +236,14 @@ class MetaBuildWrapper(object): ...@@ -235,6 +236,14 @@ class MetaBuildWrapper(object):
' do compiles') ' do compiles')
subp.set_defaults(func=self.CmdAudit) subp.set_defaults(func=self.CmdAudit)
subp = subps.add_parser('gerrit-buildbucket-config',
help='Print buildbucket.config for gerrit '
'(see MB user guide)')
subp.add_argument('-f', '--config-file', metavar='PATH',
default=self.default_config,
help='path to config file (default is %(default)s)')
subp.set_defaults(func=self.CmdBuildbucket)
subp = subps.add_parser('help', subp = subps.add_parser('help',
help='Get help on a subcommand.') help='Get help on a subcommand.')
subp.add_argument(nargs='?', action='store', dest='subcommand', subp.add_argument(nargs='?', action='store', dest='subcommand',
...@@ -368,6 +377,25 @@ class MetaBuildWrapper(object): ...@@ -368,6 +377,25 @@ class MetaBuildWrapper(object):
return ret return ret
def CmdBuildbucket(self):
self.ReadConfigFile()
self.Print('# This file was generated using '
'"tools/mb/mb.py gerrit-buildbucket-config".')
for luci_tryserver in sorted(self.luci_tryservers):
self.Print('[bucket "luci.%s"]' % luci_tryserver)
for bot in sorted(self.luci_tryservers[luci_tryserver]):
self.Print('\tbuilder = %s' % bot)
for master in sorted(self.masters):
if master.startswith('tryserver.'):
self.Print('[bucket "master.%s"]' % master)
for bot in sorted(self.masters[master]):
self.Print('\tbuilder = %s' % bot)
return 0
def CmdValidate(self, print_ok=True): def CmdValidate(self, print_ok=True):
errs = [] errs = []
...@@ -674,6 +702,7 @@ class MetaBuildWrapper(object): ...@@ -674,6 +702,7 @@ class MetaBuildWrapper(object):
(self.args.config_file, e)) (self.args.config_file, e))
self.configs = contents['configs'] self.configs = contents['configs']
self.luci_tryservers = contents['luci_tryservers']
self.masters = contents['masters'] self.masters = contents['masters']
self.mixins = contents['mixins'] self.mixins = contents['mixins']
......
...@@ -520,6 +520,7 @@ ...@@ -520,6 +520,7 @@
'cast_shell_audio_linux': 'cast_audio_release_trybot', 'cast_shell_audio_linux': 'cast_audio_release_trybot',
'chromeos_amd64-generic_chromium_compile_only_ng': 'cros_chrome_sdk', 'chromeos_amd64-generic_chromium_compile_only_ng': 'cros_chrome_sdk',
'chromeos_daisy_chromium_compile_only_ng': 'cros_chrome_sdk', 'chromeos_daisy_chromium_compile_only_ng': 'cros_chrome_sdk',
'chromium_presubmit': 'presubmit',
'closure_compilation': 'closure_compilation', 'closure_compilation': 'closure_compilation',
'fuchsia': 'release_trybot_fuchsia', 'fuchsia': 'release_trybot_fuchsia',
'fuchsia_compile': 'release_trybot_fuchsia', 'fuchsia_compile': 'release_trybot_fuchsia',
...@@ -1409,6 +1410,11 @@ ...@@ -1409,6 +1410,11 @@
'ozone_linux', 'release_trybot', 'ozone_linux', 'release_trybot',
], ],
'presubmit': [
# The chromium_presubmit bot does not use mb.
'error',
],
'release_afl_asan': [ 'release_afl_asan': [
'release', 'afl', 'asan', 'chromeos_codecs', 'pdf_xfa', 'disable_nacl', 'release', 'afl', 'asan', 'chromeos_codecs', 'pdf_xfa', 'disable_nacl',
], ],
...@@ -1981,4 +1987,8 @@ ...@@ -1981,4 +1987,8 @@
'gn_args': 'target_cpu="x86"', 'gn_args': 'target_cpu="x86"',
}, },
}, },
'luci_tryservers': {
'chromium.try': [ 'LUCI linux_chromium_rel_ng' ],
},
} }
...@@ -122,6 +122,7 @@ TEST_CONFIG = """\ ...@@ -122,6 +122,7 @@ TEST_CONFIG = """\
'fake_args_file_twice': 'args_file_twice', 'fake_args_file_twice': 'args_file_twice',
}, },
}, },
'luci_tryservers': {},
'configs': { 'configs': {
'args_file_goma': ['args_file', 'goma'], 'args_file_goma': ['args_file', 'goma'],
'args_file_twice': ['args_file', 'args_file'], 'args_file_twice': ['args_file', 'args_file'],
...@@ -181,6 +182,7 @@ TEST_BAD_CONFIG = """\ ...@@ -181,6 +182,7 @@ TEST_BAD_CONFIG = """\
'b': 'gn_rel_bot_2', 'b': 'gn_rel_bot_2',
}, },
}, },
'luci_tryservers': {},
'mixins': { 'mixins': {
'gn': {'type': 'gn'}, 'gn': {'type': 'gn'},
'chrome_with_codecs': { 'chrome_with_codecs': {
...@@ -205,6 +207,7 @@ GYP_HACKS_CONFIG = """\ ...@@ -205,6 +207,7 @@ GYP_HACKS_CONFIG = """\
'fake_builder': 'fake_config', 'fake_builder': 'fake_config',
}, },
}, },
'luci_tryservers': {},
'configs': { 'configs': {
'fake_config': ['fake_mixin'], 'fake_config': ['fake_mixin'],
}, },
...@@ -220,6 +223,28 @@ GYP_HACKS_CONFIG = """\ ...@@ -220,6 +223,28 @@ GYP_HACKS_CONFIG = """\
} }
""" """
TRYSERVER_CONFIG = """\
{
'masters': {
'not_a_tryserver': {
'fake_builder': 'fake_config',
},
'tryserver.chromium.linux': {
'try_builder': 'fake_config',
},
'tryserver.chromium.mac': {
'try_builder2': 'fake_config',
},
},
'luci_tryservers': {
'luci_tryserver1': ['luci_builder1'],
'luci_tryserver2': ['luci_builder2'],
},
'configs': {},
'mixins': {},
}
"""
class UnitTest(unittest.TestCase): class UnitTest(unittest.TestCase):
def fake_mbw(self, files=None, win32=False): def fake_mbw(self, files=None, win32=False):
...@@ -555,6 +580,22 @@ class UnitTest(unittest.TestCase): ...@@ -555,6 +580,22 @@ class UnitTest(unittest.TestCase):
"LLVM_FORCE_HEAD_REVISION=1\n" "LLVM_FORCE_HEAD_REVISION=1\n"
"python build/gyp_chromium -G output_dir=_path_\n")) "python build/gyp_chromium -G output_dir=_path_\n"))
def test_buildbucket(self):
mbw = self.fake_mbw()
mbw.files[mbw.default_config] = TRYSERVER_CONFIG
self.check(['gerrit-buildbucket-config'], mbw=mbw,
ret=0,
out=('# This file was generated using '
'"tools/mb/mb.py gerrit-buildbucket-config".\n'
'[bucket "luci.luci_tryserver1"]\n'
'\tbuilder = luci_builder1\n'
'[bucket "luci.luci_tryserver2"]\n'
'\tbuilder = luci_builder2\n'
'[bucket "master.tryserver.chromium.linux"]\n'
'\tbuilder = try_builder\n'
'[bucket "master.tryserver.chromium.mac"]\n'
'\tbuilder = try_builder2\n'))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment