Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Bazelisk's cache writable when using sandboxing. #497

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions buildkite/bazelci.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ def execute_commands(
if test_env_vars:
test_flags += ["--test_env={}".format(v) for v in test_env_vars]

if not is_windows():
test_flags.append(get_sandbox_flag_for_bazelisk_cache(platform))

test_bep_file = os.path.join(tmpdir, "test_bep.json")
try:
execute_bazel_test(
Expand Down Expand Up @@ -683,6 +686,13 @@ def execute_commands(
shutil.rmtree(tmpdir)


def get_sandbox_flag_for_bazelisk_cache(platform):
# Makes Bazelisk's cache directory writable even if sandboxing is enabled.
# This function should not be called on Windows since there is no sandboxing.
# The path relies on the behavior of Go's os.UserCacheDir() and of the Go version of Bazelisk.
dir = "Library/Caches" if platform == "macos" else ".cache"
return "--sandbox_writable_path={}".format(os.path.join(os.environ.get("HOME"), dir, "bazelisk"))

def tests_with_status(bep_file, status):
return set(label for label, _ in test_logs_for_status(bep_file, status=status))

Expand Down