README.md
1# Running Remote Builds with bazel
2
3This allows you to spawn gRPC C/C++ remote build and tests from your workstation with
4configuration that's very similar to what's used by our CI Kokoro.
5
6Note that this will only work for gRPC team members (it requires access to the
7remote build and execution cluster), others will need to rely on local test runs
8and tests run by Kokoro CI.
9
10
11## Prerequisites
12
13- See [Installing Bazel](https://docs.bazel.build/versions/master/install.html) for instructions how to install bazel on your system.
14
15- Setup application default credentials for running remote builds by following the ["Set credentials" section](https://cloud.google.com/remote-build-execution/docs/results-ui/getting-started-results-ui). (Note: for the ResultStore UI upload to work, you'll need a special kind of application default credentials, so if the build event upload doesn't work, doublecheck the instructions)
16
17
18## Running remote build manually from dev workstation
19
20IMPORTANT: The OS from which you run the bazel command needs to always match your desired build & execution platform. If you want to run tests on linux, you need to run bazel from a linux machine, to execute tests on windows you need to be on windows etc. If you don't follow this guideline, the build might still appear like it's working, but you'll get nonsensical results (e.g. will be test configured as if on mac, but actually running on linux).
21
22### Linux
23
24For `opt` or `dbg` run this command:
25```
26# manual run of bazel tests remotely on Foundry
27bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=opt //test/...
28```
29
30This also works for sanitizer runs (`asan`, `msan`, `tsan`, `ubsan`):
31```
32# manual run of bazel tests remotely on Foundry with given sanitizer
33bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/...
34```
35
36### Windows
37
38```
39# manual run of bazel tests remotely on RBE Windows (must be run from Windows machine)
40bazel --bazelrc=tools/remote_build/windows.bazelrc test --config=windows_opt //test/...
41```
42
43NOTE: Unlike on Linux and Mac, the bazel version won't get autoselected for you,
44so check that you're using the [right bazel version](https://github.com/grpc/grpc/blob/master/tools/bazel).
45
46### MacOS
47
48There is no such thing as Mac RBE cluster, so a real remote build on Macs is currently impossible.
49The following setup will build and run test on you local mac machine, but will give
50you the RBE-like look & feel (e.g. a results link will be generated and some extra configuration will
51be used).
52
53```
54# manual run of bazel tests on Mac (must be run from Mac machine)
55# NOTE: it's not really a "remote execution", but uploads results to ResultStore
56bazel --bazelrc=tools/remote_build/mac.bazelrc test --config=opt //test/...
57```
58
59NOTE: Because this is essentially a local run, you'll need to run start port server first (`tools/run_tests/start_port_server.py`)
60
61## Running local builds with bazel
62
63On all platforms, you can generally still use bazel builds & tests locally without any extra settings, but you might need to
64start port server first (`tools/run_tests/start_port_server.py`) to be able to run the tests locally.
65
66E.g.: `bazel test --config=opt //test/...`
67
68## Bazel command line options
69
70Available command line options can be found in
71[Bazel command line reference](https://docs.bazel.build/versions/master/command-line-reference.html)
72