@@ -2098,9 +2098,18 @@ def calculate_targets(task_config, bazel_binary, build_only, test_only, workspac
2098
2098
coverage_targets = [x .strip () for x in coverage_targets if x .strip () != "--" ]
2099
2099
index_targets = [x .strip () for x in index_targets if x .strip () != "--" ]
2100
2100
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
2101
2111
expanded_test_targets = expand_test_target_patterns (bazel_binary , test_targets )
2102
2112
2103
- diffbase = os .getenv (USE_BAZEL_DIFF_ENV_VAR , "" ).lower ()
2104
2113
actual_test_targets = (
2105
2114
filter_unchanged_targets (
2106
2115
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
2109
2118
else expanded_test_targets
2110
2119
)
2111
2120
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 :
2115
2122
print_collapsed_group (
2116
2123
":female-detective: Calculating targets for shard {}/{}" .format (
2117
2124
shard_id + 1 , shard_count
0 commit comments