From 25a54205e37548fc5ad3bccacc05250eeb623622 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 8 Nov 2023 16:45:54 +0100 Subject: [PATCH 1/4] Set --lockfile_mode=off for downstream pipelines --- buildkite/bazelci.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py index 2b3bcf3c4c..ec6274f133 100755 --- a/buildkite/bazelci.py +++ b/buildkite/bazelci.py @@ -1170,6 +1170,12 @@ def use_bazelisk_migrate(): """ return is_trueish(os.environ.get("USE_BAZELISK_MIGRATE")) +def is_downstream_pipeline(): + """ + Return true if BAZELCI_DOWNSTREAM_PIPELINE is set + """ + return is_trueish(os.environ.get("BAZELCI_DOWNSTREAM_PIPELINE") + def local_run_only(): """ If BAZELCI_LOCAL_RUN is set, run bazelci in local-only mode, with no attempt @@ -1991,6 +1997,10 @@ def common_build_flags(bep_file, platform): "--disk_cache=", ] + # If we are in a downstream pipeline, turn off the lockfile update since changing Bazel version could affect the lockfile. + if is_downstream_pipeline(): + flags.append("--lockfile_mode=off") + if is_windows(): pass elif is_mac(): @@ -2789,12 +2799,9 @@ def print_project_pipeline( task_configs = filter_tasks_that_should_be_skipped(task_configs, pipeline_steps) - # In Bazel Downstream Project pipelines, git_repository and project_name must be specified. - is_downstream_project = use_but and git_repository and project_name - buildifier_config = configs.get("buildifier") # Skip Buildifier when we test downstream projects. - if buildifier_config and not is_downstream_project: + if buildifier_config and not is_downstream_pipeline(): buildifier_env_vars = {} if isinstance(buildifier_config, str): # Simple format: @@ -2827,7 +2834,7 @@ def print_project_pipeline( # In Bazel Downstream Project pipelines, we should test the project at the last green commit. git_commit = None - if is_downstream_project: + if is_downstream_pipeline(): last_green_commit_url = bazelci_last_green_commit_url( git_repository, DOWNSTREAM_PROJECTS[project_name]["pipeline_slug"] ) @@ -2844,7 +2851,7 @@ def print_project_pipeline( # only differ in the value of their explicit "bazel" field will be identical in the # downstream pipeline, thus leading to duplicate work. # Consequently, we filter those duplicate tasks here. - if is_downstream_project: + if is_downstream_pipeline(): h = hash_task_config(task, task_config) if h in config_hashes: skipped_downstream_tasks.append( @@ -2945,14 +2952,14 @@ def print_project_pipeline( if "validate_config" in configs: pipeline_steps += create_config_validation_steps() - if use_bazelisk_migrate() and not is_downstream_project: + if use_bazelisk_migrate() and not is_downstream_pipeline(): # Print results of bazelisk --migrate in project pipelines that explicitly set # the USE_BAZELISK_MIGRATE env var, but that are not being run as part of a # downstream pipeline. number = os.getenv("BUILDKITE_BUILD_NUMBER") pipeline_steps += get_steps_for_aggregating_migration_results(number, notify) - print_pipeline_steps(pipeline_steps, handle_emergencies=not is_downstream_project) + print_pipeline_steps(pipeline_steps, handle_emergencies=not is_downstream_pipeline()) def show_gerrit_review_link(git_repository, pipeline_steps): From 90243478ac603fa067b91f99509c64150d63cac0 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 8 Nov 2023 16:54:37 +0100 Subject: [PATCH 2/4] Minor fix --- buildkite/bazelci.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py index ec6274f133..b878a318f2 100755 --- a/buildkite/bazelci.py +++ b/buildkite/bazelci.py @@ -1170,11 +1170,13 @@ def use_bazelisk_migrate(): """ return is_trueish(os.environ.get("USE_BAZELISK_MIGRATE")) + def is_downstream_pipeline(): """ Return true if BAZELCI_DOWNSTREAM_PIPELINE is set """ - return is_trueish(os.environ.get("BAZELCI_DOWNSTREAM_PIPELINE") + return is_trueish(os.environ.get("BAZELCI_DOWNSTREAM_PIPELINE")) + def local_run_only(): """ From c1921062bb7ce50d0a41c6439c62d7c8c15f133f Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 8 Nov 2023 17:55:50 +0100 Subject: [PATCH 3/4] Support tag filter for downstream pipeline --- buildkite/bazelci.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py index b878a318f2..12e569f06b 100755 --- a/buildkite/bazelci.py +++ b/buildkite/bazelci.py @@ -1999,9 +1999,11 @@ def common_build_flags(bep_file, platform): "--disk_cache=", ] - # If we are in a downstream pipeline, turn off the lockfile update since changing Bazel version could affect the lockfile. if is_downstream_pipeline(): + # If we are in a downstream pipeline, turn off the lockfile update since changing Bazel version could affect the lockfile. flags.append("--lockfile_mode=off") + # Filter out targets that should not be built in downstream pipelines. + flags.append("--build_tag_filters=-no_bazel_downstream") if is_windows(): pass @@ -2559,6 +2561,10 @@ def execute_bazel_test( "--build_tests_only", "--local_test_jobs=" + concurrent_test_jobs(platform), ] + if is_downstream_pipeline(): + # Filter out targets that should not be built in downstream pipelines. + aggregated_flags.append("--test_tag_filters=-no_bazel_downstream") + # Don't enable remote caching if the user enabled remote execution / caching themselves # or flaky test monitoring is enabled, as remote caching makes tests look less flaky than # they are. From eda5a0900c2f5b6434d043d508b29a23b39798cc Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 8 Nov 2023 18:00:22 +0100 Subject: [PATCH 4/4] update doc --- docs/downstream-testing.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/downstream-testing.md b/docs/downstream-testing.md index 896909ad85..4666a070f5 100644 --- a/docs/downstream-testing.md +++ b/docs/downstream-testing.md @@ -30,6 +30,8 @@ The Bazel team monitors the downstream pipeline status and report issues for bre - The downstream project is expected to respond to the issue within 5 working days. Otherwise, the project is eligible to be temporarily disabled in the downstream pipeline. Note that, even if a pipeline is disabled from the [Bazel@HEAD + downstream](https://buildkite.com/bazel/bazel-at-head-plus-downstream) pipeline, the nightly result can still be checked from the [Bazel@HEAD+ Disabled](https://buildkite.com/bazel/bazel-at-head-plus-disabled) pipeline. - If a project remains disabled in the downstream pipeline for more than 6 months without any indication of a fix, we will remove the pipeline configuration from Bazel's downstream pipeline. +Note that: if you want to skip some builds in the downstream pipeline, you can specify `skip_in_bazel_downstream_pipeline: ` for a given job in your [Bazel CI configuration file](../buildkite/README.md#configuring-a-pipeline) or add `no_bazel_downstream` tag for certain build and test targets. + As of May 2023, some projects' pipeline config files live under [the "pipeline" directory](https://github.com/bazelbuild/continuous-integration/tree/master/pipelines) of this repository, which means the Bazel team is responsible for their setup for now, ideally they should be moved to their corresponding repository or the project should be removed. ## Testing Local Changes With All Downstream Projects