Skip to content

Commit

Permalink
Improve detection of test steps (#2045)
Browse files Browse the repository at this point in the history
Previously we hard-coded the names of 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
#2044
  • Loading branch information
fweikert authored Oct 1, 2024
1 parent 312ab25 commit 42fbf79
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions buildkite/bazelci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 42fbf79

Please sign in to comment.