Allow flags and targets to be specified as maps or sets (#1730)
This is a second attempt at #1727, now with tests (until now, bazelci.py
had no tests!)
Motivation: https://github.com/bazelbuild/stardoc/pull/184
We often want to specify a base list of flags/targets which can be
augmented on "weird" platforms (Windows, perhaps Mac). But to use the
YAML `<<:` merge key, the entities merged must be maps or sets, not
lists.
To do this, we can allow *_flags and *_targets to be maps or sets - but
we must take care to transform them to lists when processing, so that
list concatenation etc. operators still work.
diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py
index 0e4fa2d..874e086 100755
--- a/buildkite/bazelci.py
+++ b/buildkite/bazelci.py
@@ -1209,7 +1209,7 @@
)
]
- flags = task_config.get(task_config_key) or []
+ flags = list(task_config.get(task_config_key, []))
flags += json_profile_flags
flags += capture_corrupted_outputs_flags
# We have to add --test_env flags to `build`, too, otherwise Bazel
@@ -2191,10 +2191,10 @@
):
print_collapsed_group(":dart: Calculating targets")
- build_targets = [] if test_only else task_config.get("build_targets", [])
- test_targets = [] if build_only else task_config.get("test_targets", [])
- coverage_targets = [] if (build_only or test_only) else task_config.get("coverage_targets", [])
- index_targets = [] if (build_only or test_only) else task_config.get("index_targets", [])
+ build_targets = [] if test_only else list(task_config.get("build_targets", []))
+ test_targets = [] if build_only else list(task_config.get("test_targets", []))
+ coverage_targets = [] if (build_only or test_only) else list(task_config.get("coverage_targets", []))
+ index_targets = [] if (build_only or test_only) else list(task_config.get("index_targets", []))
index_targets_query = (
None if (build_only or test_only) else task_config.get("index_targets_query", None)