Skip to content

Commit dcbbdf3

Browse files
authored
Only expand test targets when needed (#1615)
This change is a partial workaround for #1614.
1 parent 051f978 commit dcbbdf3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

buildkite/bazelci.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,9 +2098,18 @@ def calculate_targets(task_config, bazel_binary, build_only, test_only, workspac
20982098
coverage_targets = [x.strip() for x in coverage_targets if x.strip() != "--"]
20992099
index_targets = [x.strip() for x in index_targets if x.strip() != "--"]
21002100

2101+
diffbase = os.getenv(USE_BAZEL_DIFF_ENV_VAR, "").lower()
2102+
shard_id = int(os.getenv("BUILDKITE_PARALLEL_JOB", "-1"))
2103+
shard_count = int(os.getenv("BUILDKITE_PARALLEL_JOB_COUNT", "-1"))
2104+
sharding_enabled = shard_id > -1 and shard_count > -1
2105+
2106+
# Skip target expansion if we don't need to calculate test targets
2107+
if not diffbase and not sharding_enabled:
2108+
return build_targets, test_targets, coverage_targets, index_targets
2109+
2110+
# TODO(#1614): Fix target expansion
21012111
expanded_test_targets = expand_test_target_patterns(bazel_binary, test_targets)
21022112

2103-
diffbase = os.getenv(USE_BAZEL_DIFF_ENV_VAR, "").lower()
21042113
actual_test_targets = (
21052114
filter_unchanged_targets(
21062115
expanded_test_targets, workspace_dir, bazel_binary, diffbase, git_commit
@@ -2109,9 +2118,7 @@ def calculate_targets(task_config, bazel_binary, build_only, test_only, workspac
21092118
else expanded_test_targets
21102119
)
21112120

2112-
shard_id = int(os.getenv("BUILDKITE_PARALLEL_JOB", "-1"))
2113-
shard_count = int(os.getenv("BUILDKITE_PARALLEL_JOB_COUNT", "-1"))
2114-
if shard_id > -1 and shard_count > -1:
2121+
if sharding_enabled:
21152122
print_collapsed_group(
21162123
":female-detective: Calculating targets for shard {}/{}".format(
21172124
shard_id + 1, shard_count

0 commit comments

Comments
 (0)