Mike Frysinger | e58c0e2 | 2017-10-04 15:43:30 -0400 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 2 | # Copyright 2015 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 | """Show the builder layout for CrOS waterfalls.""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
Aviv Keshet | b7519e1 | 2016-10-04 00:50:00 -0700 | [diff] [blame] | 10 | from chromite.lib import config_lib |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 11 | from chromite.lib import commandline |
| 12 | |
| 13 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 14 | def _ParseArguments(argv): |
| 15 | parser = commandline.ArgumentParser(description=__doc__) |
| 16 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 17 | opts = parser.parse_args(argv) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 18 | opts.Freeze() |
| 19 | return opts |
| 20 | |
| 21 | |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame^] | 22 | def displayConfigs(label, configs): |
| 23 | print('== %s ==' % label) |
| 24 | |
| 25 | for config in sorted(configs, key=lambda c: c.name): |
| 26 | print(' %s' % config.name) |
| 27 | if config.slave_configs: |
| 28 | for sc in sorted(config.slave_configs): |
| 29 | print(' %s' % sc) |
| 30 | |
| 31 | print() |
| 32 | |
| 33 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 34 | def main(argv): |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame^] | 35 | _ = _ParseArguments(argv) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 36 | |
Don Garrett | 737cadd | 2015-10-22 17:43:47 -0700 | [diff] [blame] | 37 | site_config = config_lib.GetConfig() |
Don Garrett | b44956b | 2015-06-05 17:28:06 -0700 | [diff] [blame] | 38 | |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame^] | 39 | # Organize the builds as: |
| 40 | # {Display Label: [build_config]} |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 41 | |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame^] | 42 | labeled_builds = {} |
| 43 | for config in site_config.itervalues(): |
| 44 | if config.schedule: |
| 45 | labeled_builds.setdefault(config.display_label, []).append(config) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 46 | |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame^] | 47 | for label in sorted(labeled_builds.iterkeys()): |
| 48 | displayConfigs(label, labeled_builds[label]) |
| 49 | |
| 50 | # Force the tryjob section to be last. |
| 51 | displayConfigs('tryjob', |
| 52 | [c for c in site_config.itervalues() |
| 53 | if config_lib.isTryjobConfig(c)]) |