set parallel job and test execution to the number of cores
@@ -17,6 +17,7 @@ import argparse
import codecs
import json
import os.path
+import multiprocessing
import re
import shutil
import subprocess
@@ -209,9 +210,11 @@ def platforms_info():
}
}
+
def cleanup_commands(platform):
return platforms_info()[platform]["cleanup-commands"]
+
def downstream_projects_root(platform):
downstream_projects_dir = os.path.expandvars(
"${BUILDKITE_ORGANIZATION_SLUG}-downstream-projects")
@@ -358,17 +361,20 @@ def execute_bazel_build(bazel_binary, flags, targets):
if not targets:
return
print("\n+++ Build")
- fail_if_nonzero(execute_command([bazel_binary, "build", "--color=yes",
- "--keep_going"] + flags + targets))
+ num_jobs = multiprocessing.cpu_count()
+ common_flags = ["--color=yes", "--keep_going", "--jobs=" + num_jobs]
+ fail_if_nonzero(execute_command(
+ [bazel_binary, "build"] + common_flags + flags + targets))
def execute_bazel_test(bazel_binary, flags, targets, bep_file):
if not targets:
return 0
print("\n+++ Test")
- return execute_command([bazel_binary, "test", "--color=yes", "--keep_going",
- "--build_tests_only", "--build_event_json_file=" + bep_file] + flags +
- targets)
+ num_jobs = multiprocessing.cpu_count()
+ common_flags = ["--color=yes", "--keep_going", "--jobs=" + num_jobs,
+ "--local_test_jobs=" + num_jobs, "--build_event_json_file=" + bep_file]
+ return execute_command([bazel_binary, "test"] + common_flags + flags + targets)
def fail_if_nonzero(exitcode):
