Skip to content

Commit 3e61be8

Browse files
authored
begin bazel migration (#10)
1 parent 6387024 commit 3e61be8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1214
-12
lines changed

.aspect/bazelrc/BUILD.bazel

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Aspect bazelrc presets; see https://docs.aspect.build/guides/bazelrc"
2+
3+
load("@aspect_bazel_lib//lib:bazelrc_presets.bzl", "write_aspect_bazelrc_presets")
4+
5+
write_aspect_bazelrc_presets(name = "update_aspect_bazelrc_presets")

.aspect/bazelrc/bazel6.bazelrc

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Speed up all builds by not checking if external repository files have been modified.
2+
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java#L244
3+
build --noexperimental_check_external_repository_files
4+
fetch --noexperimental_check_external_repository_files
5+
query --noexperimental_check_external_repository_files
6+
7+
# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
8+
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
9+
# build.
10+
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
11+
build --reuse_sandbox_directories
12+
13+
# Avoid this flag being enabled by remote_download_minimal or remote_download_toplevel
14+
# See https://meroton.com/blog/bazel-6-errors-build-without-the-bytes/
15+
build --noexperimental_action_cache_store_output_metadata
16+
17+
# Speed up all builds by not checking if output files have been modified. Lets you make changes to
18+
# the output tree without triggering a build for local debugging. For example, you can modify
19+
# [rules_js](https://github.com/aspect-build/rules_js) 3rd party npm packages in the output tree
20+
# when local debugging.
21+
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java#L185
22+
# NB: This flag is in bazel6.bazelrc as when used in Bazel 7 is has been observed to break
23+
# "build without the bytes" --remote_download_outputs=toplevel. See https://github.com/aspect-build/bazel-lib/pull/711
24+
# for more info.
25+
build --noexperimental_check_output_files
26+
fetch --noexperimental_check_output_files
27+
query --noexperimental_check_output_files

.aspect/bazelrc/bazel7.bazelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Speed up all builds by not checking if external repository files have been modified.
2+
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java#L244
3+
build --noexperimental_check_external_repository_files
4+
fetch --noexperimental_check_external_repository_files
5+
query --noexperimental_check_external_repository_files
6+
7+
# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
8+
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
9+
# build.
10+
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
11+
build --reuse_sandbox_directories

.aspect/bazelrc/ci.bazelrc

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Set this flag to enable re-tries of failed tests on CI.
2+
# When any test target fails, try one or more times. This applies regardless of whether the "flaky"
3+
# tag appears on the target definition.
4+
# This is a tradeoff: legitimately failing tests will take longer to report,
5+
# but we can paper over flaky tests that pass most of the time.
6+
# The alternative is to mark every flaky test with the `flaky = True` attribute, but this requires
7+
# the buildcop to make frequent code edits.
8+
# Not recommended for local builds so that the flakiness is observed during development and thus
9+
# is more likely to get fixed.
10+
# Note that when passing after the first attempt, Bazel will give a special "FLAKY" status.
11+
# Docs: https://bazel.build/docs/user-manual#flaky-test-attempts
12+
test --flaky_test_attempts=2
13+
14+
# Announce all announces command options read from the bazelrc file(s) when starting up at the
15+
# beginning of each Bazel invocation. This is very useful on CI to be able to inspect what Bazel rc
16+
# settings are being applied on each run.
17+
# Docs: https://bazel.build/docs/user-manual#announce-rc
18+
build --announce_rc
19+
20+
# Add a timestamp to each message generated by Bazel specifying the time at which the message was
21+
# displayed.
22+
# Docs: https://bazel.build/docs/user-manual#show-timestamps
23+
build --show_timestamps
24+
25+
# Only show progress every 60 seconds on CI.
26+
# We want to find a compromise between printing often enough to show that the build isn't stuck,
27+
# but not so often that we produce a long log file that requires a lot of scrolling.
28+
# https://bazel.build/reference/command-line-reference#flag--show_progress_rate_limit
29+
build --show_progress_rate_limit=60
30+
31+
# Use cursor controls in screen output.
32+
# Docs: https://bazel.build/docs/user-manual#curses
33+
build --curses=yes
34+
35+
# Use colors to highlight output on the screen. Set to `no` if your CI does not display colors.
36+
# Docs: https://bazel.build/docs/user-manual#color
37+
build --color=yes
38+
39+
# The terminal width in columns. Configure this to override the default value based on what your CI system renders.
40+
# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/runtime/UiOptions.java#L151
41+
build --terminal_columns=143
42+
43+
######################################
44+
# Generic remote cache configuration #
45+
######################################
46+
47+
# Only download remote outputs of top level targets to the local machine.
48+
# Docs: https://bazel.build/reference/command-line-reference#flag--remote_download_toplevel
49+
build --remote_download_toplevel
50+
51+
# The maximum amount of time to wait for remote execution and cache calls.
52+
# https://bazel.build/reference/command-line-reference#flag--remote_timeout
53+
build --remote_timeout=3600
54+
55+
# Upload locally executed action results to the remote cache.
56+
# Docs: https://bazel.build/reference/command-line-reference#flag--remote_upload_local_results
57+
build --remote_upload_local_results
58+
59+
# Fall back to standalone local execution strategy if remote execution fails. If the grpc remote
60+
# cache connection fails, it will fail the build, add this so it falls back to the local cache.
61+
# Docs: https://bazel.build/reference/command-line-reference#flag--remote_local_fallback
62+
build --remote_local_fallback
63+
64+
# Fixes builds hanging on CI that get the TCP connection closed without sending RST packets.
65+
# Docs: https://bazel.build/reference/command-line-reference#flag--grpc_keepalive_time
66+
build --grpc_keepalive_time=30s

.aspect/bazelrc/convenience.bazelrc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Attempt to build & test every target whose prerequisites were successfully built.
2+
# Docs: https://bazel.build/docs/user-manual#keep-going
3+
build --keep_going
4+
5+
# Output test errors to stderr so users don't have to `cat` or open test failure log files when test
6+
# fail. This makes the log noiser in exchange for reducing the time-to-feedback on test failures for
7+
# users.
8+
# Docs: https://bazel.build/docs/user-manual#test-output
9+
test --test_output=errors
10+
11+
# Show the output files created by builds that requested more than one target. This helps users
12+
# locate the build outputs in more cases
13+
# Docs: https://bazel.build/docs/user-manual#show-result
14+
build --show_result=20
15+
16+
# Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is
17+
# Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS
18+
# identifiers are `linux`, `macos`, `windows`, `freebsd`, and `openbsd`. Enabling this flag is
19+
# equivalent to using `--config=linux` on Linux, `--config=windows` on Windows, etc.
20+
# Docs: https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
21+
common --enable_platform_specific_config
22+
23+
# Output a heap dump if an OOM is thrown during a Bazel invocation
24+
# (including OOMs due to `--experimental_oom_more_eagerly_threshold`).
25+
# The dump will be written to `<output_base>/<invocation_id>.heapdump.hprof`.
26+
# You may need to configure CI to capture this artifact and upload for later use.
27+
# Docs: https://bazel.build/reference/command-line-reference#flag--heap_dump_on_oom
28+
common --heap_dump_on_oom

.aspect/bazelrc/correctness.bazelrc

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Do not upload locally executed action results to the remote cache.
2+
# This should be the default for local builds so local builds cannot poison the remote cache.
3+
# It should be flipped to `--remote_upload_local_results` on CI
4+
# by using `--bazelrc=.aspect/bazelrc/ci.bazelrc`.
5+
# Docs: https://bazel.build/reference/command-line-reference#flag--remote_upload_local_results
6+
build --noremote_upload_local_results
7+
8+
# Don't allow network access for build actions in the sandbox.
9+
# Ensures that you don't accidentally make non-hermetic actions/tests which depend on remote
10+
# services.
11+
# Developers should tag targets with `tags=["requires-network"]` to opt-out of the enforcement.
12+
# Docs: https://bazel.build/reference/command-line-reference#flag--sandbox_default_allow_network
13+
build --sandbox_default_allow_network=false
14+
15+
# Warn if a test's timeout is significantly longer than the test's actual execution time.
16+
# Bazel's default for test_timeout is medium (5 min), but most tests should instead be short (1 min).
17+
# While a test's timeout should be set such that it is not flaky, a test that has a highly
18+
# over-generous timeout can hide real problems that crop up unexpectedly.
19+
# For instance, a test that normally executes in a minute or two should not have a timeout of
20+
# ETERNAL or LONG as these are much, much too generous.
21+
# Docs: https://bazel.build/docs/user-manual#test-verbose-timeout-warnings
22+
test --test_verbose_timeout_warnings
23+
24+
# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server
25+
# notices when a directory changes, if you have a directory listed in the srcs of some target.
26+
# Recommended when using
27+
# [copy_directory](https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_directory.md) and
28+
# [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories
29+
# inputs to copy_directory actions.
30+
# Docs: https://bazel.build/reference/command-line-reference#flag--host_jvm_args
31+
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1
32+
33+
# Allow exclusive tests to run in the sandbox. Fixes a bug where Bazel doesn't enable sandboxing for
34+
# tests with `tags=["exclusive"]`.
35+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_exclusive_test_sandboxed
36+
test --incompatible_exclusive_test_sandboxed
37+
38+
# Use a static value for `PATH` and does not inherit `LD_LIBRARY_PATH`. Doesn't let environment
39+
# variables like `PATH` sneak into the build, which can cause massive cache misses when they change.
40+
# Use `--action_env=ENV_VARIABLE` if you want to inherit specific environment variables from the
41+
# client, but note that doing so can prevent cross-user caching if a shared cache is used.
42+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env
43+
build --incompatible_strict_action_env
44+
45+
# Propagate tags from a target declaration to the actions' execution requirements.
46+
# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]`
47+
# get propagated to actions created by the rule.
48+
# Without this option, you rely on rules authors to manually check the tags you passed
49+
# and apply relevant ones to the actions they create.
50+
# See https://github.com/bazelbuild/bazel/issues/8830 for details.
51+
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation
52+
build --experimental_allow_tags_propagation
53+
fetch --experimental_allow_tags_propagation
54+
query --experimental_allow_tags_propagation
55+
56+
# Do not automatically create `__init__.py` files in the runfiles of Python targets. Fixes the wrong
57+
# default that comes from Google's internal monorepo by using `__init__.py` to delimit a Python
58+
# package. Precisely, when a `py_binary` or `py_test` target has `legacy_create_init` set to `auto (the
59+
# default), it is treated as false if and only if this flag is set. See
60+
# https://github.com/bazelbuild/bazel/issues/10076.
61+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_default_to_explicit_init_py
62+
build --incompatible_default_to_explicit_init_py
63+
64+
# Set default value of `allow_empty` to `False` in `glob()`. This prevents a common mistake when
65+
# attempting to use `glob()` to match files in a subdirectory that is opaque to the current package
66+
# because it contains a BUILD file. See https://github.com/bazelbuild/bazel/issues/8195.
67+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob
68+
common --incompatible_disallow_empty_glob
69+
70+
# Always download coverage files for tests from the remote cache. By default, coverage files are not
71+
# downloaded on test result cahce hits when --remote_download_minimal is enabled, making it impossible
72+
# to generate a full coverage report.
73+
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
74+
# detching remote cache results
75+
test --experimental_fetch_all_coverage_outputs

.aspect/bazelrc/debug.bazelrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
############################################################
2+
# Use `bazel test --config=debug` to enable these settings #
3+
############################################################
4+
5+
# Stream stdout/stderr output from each test in real-time.
6+
# Docs: https://bazel.build/docs/user-manual#test-output
7+
test:debug --test_output=streamed
8+
9+
# Run one test at a time.
10+
# Docs: https://bazel.build/reference/command-line-reference#flag--test_strategy
11+
test:debug --test_strategy=exclusive
12+
13+
# Prevent long running tests from timing out.
14+
# Docs: https://bazel.build/docs/user-manual#test-timeout
15+
test:debug --test_timeout=9999
16+
17+
# Always run tests even if they have cached results.
18+
# Docs: https://bazel.build/docs/user-manual#cache-test-results
19+
test:debug --nocache_test_results

.aspect/bazelrc/javascript.bazelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Aspect recommended Bazel flags when using Aspect's JavaScript rules: https://github.com/aspect-build/rules_js
2+
# Docs for Node.js flags: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options
3+
4+
# Support for debugging Node.js tests. Use bazel run with `--config=debug` to turn on the NodeJS
5+
# inspector agent. The node process will break before user code starts and wait for the debugger to
6+
# connect. Pass the --inspect-brk option to all tests which enables the node inspector agent. See
7+
# https://nodejs.org/de/docs/guides/debugging-getting-started/#command-line-options for more
8+
# details.
9+
# Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options
10+
run:debug -- --node_options=--inspect-brk
11+
test:debug --test_env=NODE_OPTIONS=--inspect-brk

.aspect/bazelrc/performance.bazelrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache.
2+
# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where
3+
# Bazel doesn't write to the local disk cache as it treats as a remote cache.
4+
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_remote_results_ignore_disk
5+
build --incompatible_remote_results_ignore_disk
6+
7+
# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs.
8+
# Save time on Sandbox creation and deletion when many of the same kind of action run during the
9+
# build.
10+
# No longer experimental in Bazel 6: https://github.com/bazelbuild/bazel/commit/c1a95501a5611878e5cc43a3cc531f2b9e47835b
11+
# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories
12+
build --experimental_reuse_sandbox_directories
13+
14+
# Do not build runfiles symlink forests for external repositories under
15+
# `.runfiles/wsname/external/repo` (in addition to `.runfiles/repo`). This reduces runfiles &
16+
# sandbox creation times & prevents accidentally depending on this feature which may flip to off by
17+
# default in the future. Note, some rules may fail under this flag, please file issues with the rule
18+
# author.
19+
# Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles
20+
build --nolegacy_external_runfiles

.bazelrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://docs.aspect.build/guides/bazelrc/
2+
3+
# Import Aspect bazelrc presets
4+
import %workspace%/.aspect/bazelrc/bazel6.bazelrc
5+
import %workspace%/.aspect/bazelrc/convenience.bazelrc
6+
import %workspace%/.aspect/bazelrc/correctness.bazelrc
7+
import %workspace%/.aspect/bazelrc/debug.bazelrc
8+
import %workspace%/.aspect/bazelrc/javascript.bazelrc
9+
import %workspace%/.aspect/bazelrc/performance.bazelrc
10+
11+
### YOUR PROJECT SPECIFIC OPTIONS GO HERE ###
12+
13+
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
14+
# This file should appear in `.gitignore` so that settings are not shared with team members. This
15+
# should be last statement in this config so the user configuration is able to overwrite flags from
16+
# this file. See https://bazel.build/configure/best-practices#bazelrc-file.
17+
try-import %workspace%/.aspect/bazelrc/user.bazelrc

.bazelversion

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.2.1

.buildifier.json

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"type": "auto",
3+
"mode": "fix",
4+
"lint": "fix",
5+
"warningsList": [
6+
"attr-applicable_licenses",
7+
"attr-cfg",
8+
"attr-license",
9+
"attr-licenses",
10+
"attr-non-empty",
11+
"attr-output-default",
12+
"attr-single-file",
13+
"build-args-kwargs",
14+
"bzl-visibility",
15+
"confusing-name",
16+
"constant-glob",
17+
"ctx-actions",
18+
"ctx-args",
19+
"deprecated-function",
20+
"depset-items",
21+
"depset-iteration",
22+
"depset-union",
23+
"dict-concatenation",
24+
"dict-method-named-arg",
25+
"duplicated-name",
26+
"filetype",
27+
"function-docstring",
28+
"function-docstring-args",
29+
"function-docstring-header",
30+
"function-docstring-return",
31+
"git-repository",
32+
"http-archive",
33+
"integer-division",
34+
"keyword-positional-params",
35+
"list-append",
36+
"load",
37+
"module-docstring",
38+
"name-conventions",
39+
"native-android",
40+
"native-build",
41+
"native-cc",
42+
"native-java",
43+
"native-package",
44+
"native-proto",
45+
"native-py",
46+
"no-effect",
47+
"output-group",
48+
"overly-nested-depset",
49+
"package-name",
50+
"package-on-top",
51+
"positional-args",
52+
"print",
53+
"provider-params",
54+
"redefined-variable",
55+
"repository-name",
56+
"return-value",
57+
"rule-impl-return",
58+
"skylark-comment",
59+
"skylark-docstring",
60+
"string-iteration",
61+
"uninitialized",
62+
"unnamed-macro",
63+
"unreachable",
64+
"unsorted-dict-items",
65+
"unused-variable"
66+
]
67+
}

.envrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
VIRTUAL_ENV=".venv"
2+
3+
PATH_add tools
4+
5+
# create venv
6+
# HACK: use system python3.12, rather than bazel-provided Python
7+
# bazel run --ui_event_filters=-INFO --noshow_progress --show_result=0 python3
8+
layout python python3.12
9+
10+
# install pip-tools if it's not already installed
11+
if ! python -m piptools > /dev/null 2>&1; then
12+
python -m pip install --quiet pip-tools
13+
fi
14+
15+
# pip-sync
16+
python -m piptools sync --quiet py_requirements_lock.txt

.gitignore

100755100644
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
.jekyll-cache/
1+
bazel-*
2+
23
_site/
3-
.vscode/
4+
.venv/
5+
6+
old/

.vscode/settings.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"search.exclude": {
3+
"MODULE.bazel.lock": true,
4+
".aspect/bazelrc": true
5+
},
6+
"cSpell.words": [
7+
"runfile",
8+
"runfiles"
9+
],
10+
"files.associations": {
11+
".envrc*": "shellscript",
12+
".bazelrc": "shellscript"
13+
},
14+
}

0 commit comments

Comments
 (0)