Mike Frysinger | f1ba7ad | 2022-09-12 05:42:57 -0400 | [diff] [blame] | 1 | # Copyright 2015 The ChromiumOS Authors |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Show the builder layout for CrOS waterfalls.""" |
| 6 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 7 | from chromite.lib import commandline |
Mike Frysinger | 807d828 | 2022-04-28 22:45:17 -0400 | [diff] [blame] | 8 | from chromite.lib import config_lib |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 9 | |
| 10 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 11 | def _ParseArguments(argv): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 12 | parser = commandline.ArgumentParser(description=__doc__) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 13 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 14 | opts = parser.parse_args(argv) |
| 15 | opts.Freeze() |
| 16 | return opts |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 17 | |
| 18 | |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame] | 19 | def displayConfigs(label, configs): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 20 | print("== %s ==" % label) |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame] | 21 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 22 | for config in sorted(configs, key=lambda c: c.name): |
| 23 | print(" %s" % config.name) |
| 24 | if config.slave_configs: |
| 25 | for sc in sorted(config.slave_configs): |
| 26 | print(" %s" % sc) |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame] | 27 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 28 | print() |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame] | 29 | |
| 30 | |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 31 | def main(argv): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 32 | _ = _ParseArguments(argv) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 33 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 34 | site_config = config_lib.GetConfig() |
Don Garrett | b44956b | 2015-06-05 17:28:06 -0700 | [diff] [blame] | 35 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 36 | # Organize the builds as: |
| 37 | # {Display Label: [build_config]} |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 38 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 39 | labeled_builds = {} |
| 40 | for config in site_config.values(): |
| 41 | if config.schedule: |
| 42 | labeled_builds.setdefault(config.display_label, []).append(config) |
Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 43 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 44 | for label in sorted(labeled_builds.keys()): |
| 45 | displayConfigs(label, labeled_builds[label]) |
Don Garrett | d2a6711 | 2018-12-04 18:26:47 -0800 | [diff] [blame] | 46 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 47 | # Force the tryjob section to be last. |
| 48 | displayConfigs( |
| 49 | "tryjob", |
| 50 | [c for c in site_config.values() if config_lib.isTryjobConfig(c)], |
| 51 | ) |