Skip to content

Commit c36f136

Browse files
committed
Add initial implementation
1 parent 87ea519 commit c36f136

30 files changed

+891
-0
lines changed

.aspect/bazelrc/BUILD.bazel

Lines changed: 5 additions & 0 deletions
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")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Automatic updates
2+
3+
A convenient way to automatically keep your vendored copy up-to-date is to use the `write_aspect_bazelrc_presets` rule in `.aspect/bazelrc/BUILD.bazel`:
4+
5+
```python title=".aspect/bazelrc/BUILD.bazel"
6+
"Aspect bazelrc presets; see https://docs.aspect.build/guides/bazelrc"
7+
8+
load("@aspect_bazel_lib//lib:bazelrc_presets.bzl", "write_aspect_bazelrc_presets")
9+
10+
write_aspect_bazelrc_presets(name = "update_aspect_bazelrc_presets")
11+
```
12+
13+
When `@aspect_bazel_lib` is upgraded in your `WORKSPACE.bazel` or your `MODULE.bazel` file, a `diff_test`
14+
stamped out by `write_aspect_bazelrc_presets` will fail if your vendored copy is out-of-date and print the Bazel command
15+
to run to update it. For example, `bazel run //.aspect/bazelrc:update_aspect_bazelrc_presets`.
16+
17+
See the [bazelrc](https://github.com/aspect-build/bazel-examples/blob/main/bazelrc/.aspect/bazelrc/BUILD.bazel) example
18+
in our [bazel-examples](https://github.com/aspect-build/bazel-examples) repository for a working example.

.aspect/bazelrc/bazel5.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Performance improvement for WORKSPACE evaluation
2+
# of slow rulesets, for example rules_k8s has been
3+
# observed to take 10 seconds without this flag.
4+
# See https://github.com/bazelbuild/bazel/issues/13907
5+
common --incompatible_existing_rules_immutable_view

.aspect/bazelrc/bazel6.bazelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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

.aspect/bazelrc/ci.bazelrc

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

.aspect/bazelrc/debug.bazelrc

Lines changed: 19 additions & 0 deletions
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/intro.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Aspect bazelrc presets
2+
3+
The `.bazelrc` files found here are the source-of-truth for our recommended Bazel presets.
4+
5+
They are mirrored on our docsite at https://docs.aspect.build/guides/bazelrc.

.aspect/bazelrc/javascript.bazelrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
12+
# Enable runfiles on all platforms. Runfiles are on by default on Linux and MacOS but off on
13+
# Windows.
14+
#
15+
# In general, rules_js and derivate rule sets assume that runfiles are enabled and do not support no
16+
# runfiles case because it does not scale to teach all Node.js tools to use the runfiles manifest.
17+
#
18+
# If you are developing on Windows, you must either run bazel with administrator privileges or
19+
# enable developer mode. If you do not you may hit this error on Windows:
20+
#
21+
# Bazel needs to create symlinks to build the runfiles tree.
22+
# Creating symlinks on Windows requires one of the following:
23+
# 1. Bazel is run with administrator privileges.
24+
# 2. The system version is Windows 10 Creators Update (1703) or later
25+
# and developer mode is enabled.
26+
#
27+
# Docs: https://bazel.build/reference/command-line-reference#flag--enable_runfiles
28+
build --enable_runfiles

0 commit comments

Comments
 (0)