Does bazel support remote execution on different platforms?

隐身守侯 提交于 2020-07-08 20:33:08

问题


Specifically, I want to run tests on Windows workers from a Mac host.

Comments on running bazel remote executor test on separate machines indicate that it is something that Bazel team is working on, but want to confirm.


回答1:


Just give it a try!

Build and run local remote execution worker on your Windows 10 machine:

git clone https://github.com/bazelbuild/bazel.git
cd bazel
bazel build src/tools/remote:worker
bazel-bin/src/tools/remote/worker --work_path=/tmp/test --listen_port=8080
bazel-out/x64_windows-fastbuild/bin/src/tools/remote/worker.exe --listen_port=8080 --work_path=C:\tmp\lre --debug

Note: If it complains that some commands are missing such as zip open an MSYS shell and run for instance pacman -Syu zip unzip

Setup your .bazelrc to work with remote execution:

# Remote Build Execution requires a strong hash function, such as SHA256.
startup --host_jvm_args=-Dbazel.DigestFunction=SHA256

# Depending on how many machines are in the remote execution instance, setting
# this higher can make builds faster by allowing more jobs to run in parallel.
# Setting it too high can result in jobs that timeout, however, while waiting
# for a remote machine to execute them.
build:remote --jobs=8


# Set various strategies so that all actions execute remotely. Mixing remote
# and local execution will lead to errors unless the toolchain and remote
# machine exactly match the host machine.
build:remote --spawn_strategy=remote
build:remote --strategy=Javac=remote
build:remote --strategy=Closure=remote
build:remote --genrule_strategy=remote
build:remote --define=EXECUTOR=remote

# Enable the remote cache so action results can be shared across machines,
# developers, and workspaces.
build:remote --remote_cache=localhost:8080

# Enable remote execution so actions are performed on the remote systems.
build:remote --remote_executor=localhost:8080

# Enable encryption.
#build:remote --tls_enabled=true

# Enforce stricter environment rules, which eliminates some non-hermetic
# behavior and therefore improves both the remote cache hit rate and the
# correctness and repeatability of the build.
build:remote --experimental_strict_action_env=true

# Set a higher timeout value, just in case.
build:remote --remote_timeout=3600

build:remote --auth_enabled=false

# Since we're testing remote execution, let's make sure it always actually
# happens.
build:remote --remote_accept_cached=false
test --cache_test_results=false

test --test_output=errors

# TODO(b/77217487): Needed for C++ builds until fix to
# https://github.com/bazelbuild/bazel/issues/4883 is available.
build --nocheck_visibility

build:debug --verbose_failures
build:debug --explain=explain.txt
build:debug --verbose_explanations
build:debug --toolchain_resolution_debug
build:debug --subcommands

Now do a remote build from your Mac (of course localhost:8080 should be changed to the IP of your Windows 10 machine):

bazel build --config=remote //:HelloWorld

Now do a remote execution

bazel run --config=remote //:HelloWorld

Note: Shamelessly stolen from https://github.com/bazelbuild/bazel/issues/4962



来源:https://stackoverflow.com/questions/57487061/does-bazel-support-remote-execution-on-different-platforms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!