From a8d21f668b77a35f6a4a99c36de56a1122e484cc Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Mon, 30 Sep 2024 20:56:51 +0200 Subject: [PATCH] Improve detection of test steps Previously we hard-coded non-test steps such as Buildifier, which can cause problem when adding new steps. With this commit we detect test steps by looking at their command, which has to contain `bazelci.py runner`. Progress towards https://github.com/bazelbuild/continuous-integration/issues/2044 --- buildkite/bazelci.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py index 233221519d..62d73a5ba9 100755 --- a/buildkite/bazelci.py +++ b/buildkite/bazelci.py @@ -569,11 +569,10 @@ BUILD_LABEL_PATTERN = re.compile(r"^Build label: (\S+)$", re.MULTILINE) -BUILDIFIER_STEP_NAME = "Buildifier" -SHARD_SUMMARY_STEP_NAME = "Print Test Summary for Shards" - SKIP_TASKS_ENV_VAR = "CI_SKIP_TASKS" +RUNNER_CMD = "bazelci.py runner" + # TODO: change to USE_BAZEL_DIFF once the feature has been tested in QA USE_BAZEL_DIFF_ENV_VAR = "USE_BAZEL_DIFF" @@ -2891,7 +2890,7 @@ def print_project_pipeline( pipeline_steps.append( create_docker_step( - BUILDIFIER_STEP_NAME, + "Buildifier", image=BUILDIFIER_DOCKER_IMAGE, additional_env_vars=buildifier_env_vars, ) @@ -3035,7 +3034,7 @@ def print_project_pipeline( if actually_print_shard_summary: pipeline_steps.append( create_step( - label=SHARD_SUMMARY_STEP_NAME, + label="Print Test Summary for Shards", commands=[ fetch_bazelcipy_command(), PLATFORMS[DEFAULT_PLATFORM]["python"] + " bazelci.py print_shard_summary", @@ -3197,7 +3196,8 @@ def runner_step( shards=1, soft_fail=None, ): - command = PLATFORMS[platform]["python"] + " bazelci.py runner --task=" + task + py = PLATFORMS[platform]["python"] + command = f"{py} {RUNNER_CMD} --task={task}" if http_config: command += " --http_config=" + http_config if file_config: @@ -3285,7 +3285,8 @@ def bazel_build_step( build_only=False, test_only=False, ): - pipeline_command = PLATFORMS[platform]["python"] + " bazelci.py runner" + py = PLATFORMS[platform]["python"] + pipeline_command = f"{py} {RUNNER_CMD}" if build_only: pipeline_command += " --build_only --save_but" if test_only: @@ -3723,7 +3724,7 @@ def has_failed(job): and state != "passed" and not job.get("soft_failed") and job["id"] != current_job_id - and job["name"] not in (BUILDIFIER_STEP_NAME, SHARD_SUMMARY_STEP_NAME) + and RUNNER_CMD in job.get("command", "") # Only look at test steps ) failing_jobs = [j["name"] for j in build_info["jobs"] if has_failed(j)]