Skip to content

Commit

Permalink
Duplicate task configs to test all supported Bazel LTS releases (#1858)
Browse files Browse the repository at this point in the history
For each task, if bazel version is not specified, duplicate the task for
each supported Bazel LTS releases.

Users can override the bazel version in the presubmit.yml file
explicitly to bypass this duplication.

Relevant discussion and changes:
- bazelbuild/bazel-central-registry#1332
- bazelbuild/bazel-central-registry#1373
- bazel-contrib/rules-template#105
  • Loading branch information
meteorcloudy authored Jan 25, 2024
1 parent 83e4a7f commit b4d5bc4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions buildkite/bazel-central-registry/bcr_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,22 @@ def upload_jobs_to_pipeline(pipeline_steps):
)


def duplicate_configs_for_supported_bazel_lts_releases(task_configs):
# For each task, if bazel version is not specified, duplicate the task for each supported Bazel LTS releases.
BAZEL_LTS = [("7.x", ":seven:"), ("6.x", ":six:")] # the second element is the emoji name
new_task_configs = {}
for task_name, task_config in task_configs.items():
if "bazel" in task_config:
new_task_configs[task_name] = task_config
else:
for bazel_version, emoji in BAZEL_LTS:
new_task_config = task_config.copy()
new_task_config["bazel"] = bazel_version
new_task_config["name"] = task_config["name"] + " (:bazel: " + emoji + ")"
new_task_configs[task_name + "_" + bazel_version] = new_task_config
return new_task_configs


def main(argv=None):
if argv is None:
argv = sys.argv[1:]
Expand Down Expand Up @@ -473,9 +489,11 @@ def main(argv=None):
pipeline_steps = []
for module_name, module_version in modules:
configs = get_task_config(module_name, module_version)
add_presubmit_jobs(module_name, module_version, configs.get("tasks", {}), pipeline_steps)
task_configs = duplicate_configs_for_supported_bazel_lts_releases(configs.get("tasks", {}))
add_presubmit_jobs(module_name, module_version, task_configs, pipeline_steps)
configs = get_test_module_task_config(module_name, module_version)
add_presubmit_jobs(module_name, module_version, configs.get("tasks", {}), pipeline_steps, is_test_module=True)
task_configs = duplicate_configs_for_supported_bazel_lts_releases(configs.get("tasks", {}))
add_presubmit_jobs(module_name, module_version, task_configs, pipeline_steps, is_test_module=True)
if should_wait_bcr_maintainer_review(modules) and pipeline_steps:
pipeline_steps = [{"block": "Wait on BCR maintainer review", "blocked_state": "running"}] + pipeline_steps
upload_jobs_to_pipeline(pipeline_steps)
Expand Down

0 comments on commit b4d5bc4

Please sign in to comment.