-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.bazelrc
More file actions
185 lines (155 loc) · 8.51 KB
/
.bazelrc
File metadata and controls
185 lines (155 loc) · 8.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
common --enable_bzlmod=false
try-import submodules/dev-tools/.bazelrc
# We cannot build in any of the sandbox environments (including `linux`) that
# restrict access to the network or filesystem. Also, some rules aren't even
# compatible with the `processwrapper-sandbox` strategy, so we fallback to
# `local` when necessary.
#
# TODO: Implement a more restrictive sandboxing strategy.
# TODO: Remove the need to fallback to local.
build --spawn_strategy=processwrapper-sandbox,local
# Run exclusive tests in a sandbox rather than with the bare
# local strategy. Without this, exclusive tests bypass the
# remote cache entirely (the local spawn runner does not
# consult the remote cache in Bazel 6.5). This flag defaults
# to true in Bazel 7, so this line can be removed when we
# upgrade.
test --incompatible_exclusive_test_sandboxed
# When we use C++, we use C++17.
build --cxxopt='-std=c++17'
build --host_cxxopt='-std=c++17'
# Build with clang (rather than the default of gcc) since clang compiles
# templates faster and produces better error messages.
build --action_env=CC=clang
# We need to always use position independent code because when
# compiling in optimized mode we've run into issues where
# `rules_foreign_cc` requires it for linking.
build --force_pic
# By default run both (target) compilation mode and host compilation
# mode in 'fastbuild' so that any "tools" that get build (which are
# built for the host) don't require building things a second time.
build --compilation_mode=fastbuild
build --host_compilation_mode=fastbuild
build --copt=-Wno-error=int-conversion
# Explicitly disable the remote cache. It's not on by default, but this is
# useful either for CI that normally _would_ use a remote cache, or for
# developers who want to be really extra sure they're not using one.
build:no-remote-cache --remote_cache=""
# To debug errors using the remote cache we need the `--verbose_failures` flag to
# get any useful information whatsoever.
build --verbose_failures
# Generate source-level debug information and never strip it from binaries.
#
# NOTE: using '--compilation_mode=dbg' will ensure we're in a separate
# output directory (with a 'dbg' suffix) so that we don't clobber the
# cache.
build:debug --compilation_mode=dbg --copt="-g" --strip="never"
# Add an 'asan' suffix to the output directories that we build with so
# that an '--config=asan' build doesn't clobber the cache.
build:asan --platform_suffix=asan
# Always run tests with 'PYTHONUNBUFFERED=1' so that we don't lose any
# output that might help us debug!
#
# Note that this test-only flag is specified on `build` so that the analysis
# cache is maintained between a `bazel build ...` and a `bazel test ...`. See:
# https://github.com/bazelbuild/bazel/issues/7450.
build --test_env=PYTHONUNBUFFERED=1
# Run mypy whenever we build Python code.
build --aspects @mypy_integration//:mypy.bzl%mypy_aspect
build --output_groups=+mypy
build --@mypy_integration//:mypy_config=//:mypy.ini
# In Python there is the concept of a "namespace package", which is a single
# package that's spread across multiple directories. This is useful for e.g. all
# of the various Google libraries, that come in different PyPI packages like
# `kubernetes` or `google-cloud-storage` as well as from direct Bazel
# dependencies like `com_google_protobuf`, all of which contain a `google`
# module. In order for us to find all the various Google modules (e.g.
# `google.api` and `google.auth` in different `google/` folders) and not only
# those in the first `google` module we find, all Google modules need to be
# namespace packages.
#
# There are two ways to make a package a namespace package:
# 1. Have code in the package's `__init__.py` that makes it so; see
# https://peps.python.org/pep-0420/#namespace-packages-today for details.
# 2. Omit the `__init__.py` from the package entirely. That makes it an
# "implicit" namespace package; details are at
# https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages.
#
# When we import a package via `rules_python` (e.g. `requirement('grpcio')`),
# the `rules_python` code will conveniently set it up for case (1).
#
# When we import a package via direct Bazel dependency (like we do with
# `@com_google_protobuf`), it is very important that it also uses one of these
# cases. However, if (like `@com_google_protobuf`) it uses case (2) meaning it
# does not have an `__init__.py`, then Bazel will automatically create an empty
# `__init__.py` for it (!!) thereby completely ruining everything. See:
# https://github.com/bazelbuild/bazel/issues/7386
#
# Fortunately we can disable this behavior by setting the following flag, which
# will let libraries like `@com_google_protobuf` be implicit namespace packages.
build --incompatible_default_to_explicit_init_py
# Configs to simplify debugging tests. Use via `bazel --config=k8s-debug`.
test:k8s-debug --test_output=streamed
test:k8s-debug --nocache_test_results
test:k8s-debug --test_env=LOCAL_KUBERNETES_TEST_FORCE_COLOR=true
# Use via `bazel --config=k8s-debug-verbose`.
test:k8s-debug-verbose --config=k8s-debug
test:k8s-debug-verbose --test_env=LOCAL_KUBERNETES_TEST_VERBOSE=true
# Config to reuse an existing registry.
test:k8s-reuse-registry --test_env=LOCAL_KUBERNETES_TEST_REUSE_REGISTRY=true
# Config to reuse an existing cluster.
test:k8s-reuse-cluster --test_env=LOCAL_KUBERNETES_TEST_REUSE_CLUSTER=true
# Config to reuse an existing cluster and registry.
test:k8s-reuse --config=k8s-reuse-registry --config=k8s-reuse-cluster
# Defaults for using 'rules_ts'.
build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
build --@aspect_rules_ts//ts:default_to_tsc_transpiler
fetch --@aspect_rules_ts//ts:default_to_tsc_transpiler
# Use a hardcoded action $PATH. Otherwise, every time $PATH changes, Bazel will
# rebuild every target. This is a problem because $PATH changes all the time;
# most notably VSCode makes changes to $PATH every time it starts up; e.g. to
# add lines like:
# /vscode/bin/linux-x64/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d/bin/remote-cli
build --incompatible_strict_action_env
# TODO: By default, Bazel uses the reverse order of this PATH (with `/bin` first),
# but our workaround for https://github.com/reboot-dev/mono/issues/2652 involves
# creating symlinks in `/usr/local/bin`, which we always want to be loaded first.
build --action_env=PATH=/usr/local/bin:/usr/bin:/bin
# Allow `rules_oci` to (attempt to) pull images, even when it first
# calls a credential helper that fails (i.e. one with no credentials
# set up). The images we pull tend to not need any auth, so a lack of
# credentials isn't a problem.
common --repo_env=OCI_GET_TOKEN_ALLOW_FAIL=1
# Normally, on restart, Bazel will check that its `bazel-bin` and
# `bazel-out` directories are untouched. As part of this for every file
# in those directories it will check the modification time, possibly
# compute a checksum, and write metadata to disk. Our directories are so
# large that on a GitHub Codespace (which can have pretty poor I/O
# performance) this "Checking Cached Actions" process can take 15
# minutes or more - almost as much as a full rebuild. :-(
#
# Given that we don't modify our `bazel-bin` and `bazel-out` directories
# manually, we opt out of this costly check with the following flag. The
# drawback is that if we do ever accidentally modify the `bazel-bin` or
# `bazel-out` directories, we must run `bazel clean` to get back into a
# sane state.
common --noexperimental_check_output_files
# Allow users to add local preferences that override the above.
try-import %workspace%/user.bazelrc
# When tests fail, print their error logs to stderr. This is necessary in CI for
# us to debug failed tests, since we don't have `bazel-testlogs/` available when
# debugging.
test --test_output=errors
# When running tests, set the timezone to the local machine's timezone. This is
# useful for potentially catching timezone related bugs during development if we
# run tests on a machine with a non-UTC timezone. This is also useful because one
# of our GitHub Actions is configured to have a non-UTC local timezone which can
# help us catch timezone related bugs before they reach production.
test --test_env=TZ
# When running tests, set the `REBOOT_BAZEL_TEST` environment variable to `true` so
# we will print stack traces when running Reboot from Node.js.
test --test_env=REBOOT_BAZEL_TEST=true
# Bazel doesn't print stdout/stderr for failed tests if the contents exceeds 1MB
# by default; increase this to 10MB for CI purposes.
test --experimental_ui_max_stdouterr_bytes=10485760