diff --git a/.aspect/bazelrc/.gitignore b/.aspect/bazelrc/.gitignore deleted file mode 100644 index f25e3eb..0000000 --- a/.aspect/bazelrc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -user.bazelrc \ No newline at end of file diff --git a/.aspect/bazelrc/BUILD.bazel b/.aspect/bazelrc/BUILD.bazel deleted file mode 100644 index a3e6c28..0000000 --- a/.aspect/bazelrc/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -"Aspect bazelrc presets; see https://docs.aspect.build/guides/bazelrc" - -load("@aspect_bazel_lib//lib:bazelrc_presets.bzl", "write_aspect_bazelrc_presets") - -write_aspect_bazelrc_presets( - name = "update_aspect_bazelrc_presets", - presets = [ - "ci", - "convenience", - "correctness", - "debug", - "javascript", - "performance", - ], -) diff --git a/.aspect/bazelrc/bazel7.bazelrc b/.aspect/bazelrc/bazel7.bazelrc deleted file mode 120000 index d358281..0000000 --- a/.aspect/bazelrc/bazel7.bazelrc +++ /dev/null @@ -1 +0,0 @@ -../../.github/workflows/bazel7.bazelrc \ No newline at end of file diff --git a/.aspect/bazelrc/ci.bazelrc b/.aspect/bazelrc/ci.bazelrc deleted file mode 100644 index 11aae33..0000000 --- a/.aspect/bazelrc/ci.bazelrc +++ /dev/null @@ -1,66 +0,0 @@ -# Set this flag to enable re-tries of failed tests on CI. -# When any test target fails, try one or more times. This applies regardless of whether the "flaky" -# tag appears on the target definition. -# This is a tradeoff: legitimately failing tests will take longer to report, -# but we can paper over flaky tests that pass most of the time. -# The alternative is to mark every flaky test with the `flaky = True` attribute, but this requires -# the buildcop to make frequent code edits. -# Not recommended for local builds so that the flakiness is observed during development and thus -# is more likely to get fixed. -# Note that when passing after the first attempt, Bazel will give a special "FLAKY" status. -# Docs: https://bazel.build/docs/user-manual#flaky-test-attempts -test --flaky_test_attempts=2 - -# Announce all announces command options read from the bazelrc file(s) when starting up at the -# beginning of each Bazel invocation. This is very useful on CI to be able to inspect what Bazel rc -# settings are being applied on each run. -# Docs: https://bazel.build/docs/user-manual#announce-rc -build --announce_rc - -# Add a timestamp to each message generated by Bazel specifying the time at which the message was -# displayed. -# Docs: https://bazel.build/docs/user-manual#show-timestamps -build --show_timestamps - -# Only show progress every 60 seconds on CI. -# We want to find a compromise between printing often enough to show that the build isn't stuck, -# but not so often that we produce a long log file that requires a lot of scrolling. -# https://bazel.build/reference/command-line-reference#flag--show_progress_rate_limit -build --show_progress_rate_limit=60 - -# Use cursor controls in screen output. -# Docs: https://bazel.build/docs/user-manual#curses -build --curses=yes - -# Use colors to highlight output on the screen. Set to `no` if your CI does not display colors. -# Docs: https://bazel.build/docs/user-manual#color -build --color=yes - -# The terminal width in columns. Configure this to override the default value based on what your CI system renders. -# Docs: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/runtime/UiOptions.java#L151 -build --terminal_columns=143 - -###################################### -# Generic remote cache configuration # -###################################### - -# Only download remote outputs of top level targets to the local machine. -# Docs: https://bazel.build/reference/command-line-reference#flag--remote_download_toplevel -build --remote_download_toplevel - -# The maximum amount of time to wait for remote execution and cache calls. -# https://bazel.build/reference/command-line-reference#flag--remote_timeout -build --remote_timeout=3600 - -# Upload locally executed action results to the remote cache. -# Docs: https://bazel.build/reference/command-line-reference#flag--remote_upload_local_results -build --remote_upload_local_results - -# Fall back to standalone local execution strategy if remote execution fails. If the grpc remote -# cache connection fails, it will fail the build, add this so it falls back to the local cache. -# Docs: https://bazel.build/reference/command-line-reference#flag--remote_local_fallback -build --remote_local_fallback - -# Fixes builds hanging on CI that get the TCP connection closed without sending RST packets. -# Docs: https://bazel.build/reference/command-line-reference#flag--grpc_keepalive_time -build --grpc_keepalive_time=30s diff --git a/.aspect/bazelrc/convenience.bazelrc b/.aspect/bazelrc/convenience.bazelrc deleted file mode 100644 index c674569..0000000 --- a/.aspect/bazelrc/convenience.bazelrc +++ /dev/null @@ -1,28 +0,0 @@ -# Attempt to build & test every target whose prerequisites were successfully built. -# Docs: https://bazel.build/docs/user-manual#keep-going -build --keep_going - -# Output test errors to stderr so users don't have to `cat` or open test failure log files when test -# fail. This makes the log noiser in exchange for reducing the time-to-feedback on test failures for -# users. -# Docs: https://bazel.build/docs/user-manual#test-output -test --test_output=errors - -# Show the output files created by builds that requested more than one target. This helps users -# locate the build outputs in more cases -# Docs: https://bazel.build/docs/user-manual#show-result -build --show_result=20 - -# Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is -# Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS -# identifiers are `linux`, `macos`, `windows`, `freebsd`, and `openbsd`. Enabling this flag is -# equivalent to using `--config=linux` on Linux, `--config=windows` on Windows, etc. -# Docs: https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config -common --enable_platform_specific_config - -# Output a heap dump if an OOM is thrown during a Bazel invocation -# (including OOMs due to `--experimental_oom_more_eagerly_threshold`). -# The dump will be written to `/.heapdump.hprof`. -# You may need to configure CI to capture this artifact and upload for later use. -# Docs: https://bazel.build/reference/command-line-reference#flag--heap_dump_on_oom -common --heap_dump_on_oom diff --git a/.aspect/bazelrc/correctness.bazelrc b/.aspect/bazelrc/correctness.bazelrc deleted file mode 100644 index a599f6d..0000000 --- a/.aspect/bazelrc/correctness.bazelrc +++ /dev/null @@ -1,75 +0,0 @@ -# Do not upload locally executed action results to the remote cache. -# This should be the default for local builds so local builds cannot poison the remote cache. -# It should be flipped to `--remote_upload_local_results` on CI -# by using `--bazelrc=.aspect/bazelrc/ci.bazelrc`. -# Docs: https://bazel.build/reference/command-line-reference#flag--remote_upload_local_results -build --noremote_upload_local_results - -# Don't allow network access for build actions in the sandbox. -# Ensures that you don't accidentally make non-hermetic actions/tests which depend on remote -# services. -# Developers should tag targets with `tags=["requires-network"]` to opt-out of the enforcement. -# Docs: https://bazel.build/reference/command-line-reference#flag--sandbox_default_allow_network -build --sandbox_default_allow_network=false - -# Warn if a test's timeout is significantly longer than the test's actual execution time. -# Bazel's default for test_timeout is medium (5 min), but most tests should instead be short (1 min). -# While a test's timeout should be set such that it is not flaky, a test that has a highly -# over-generous timeout can hide real problems that crop up unexpectedly. -# For instance, a test that normally executes in a minute or two should not have a timeout of -# ETERNAL or LONG as these are much, much too generous. -# Docs: https://bazel.build/docs/user-manual#test-verbose-timeout-warnings -test --test_verbose_timeout_warnings - -# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server -# notices when a directory changes, if you have a directory listed in the srcs of some target. -# Recommended when using -# [copy_directory](https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_directory.md) and -# [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories -# inputs to copy_directory actions. -# Docs: https://bazel.build/reference/command-line-reference#flag--host_jvm_args -startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1 - -# Allow exclusive tests to run in the sandbox. Fixes a bug where Bazel doesn't enable sandboxing for -# tests with `tags=["exclusive"]`. -# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_exclusive_test_sandboxed -test --incompatible_exclusive_test_sandboxed - -# Use a static value for `PATH` and does not inherit `LD_LIBRARY_PATH`. Doesn't let environment -# variables like `PATH` sneak into the build, which can cause massive cache misses when they change. -# Use `--action_env=ENV_VARIABLE` if you want to inherit specific environment variables from the -# client, but note that doing so can prevent cross-user caching if a shared cache is used. -# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env -build --incompatible_strict_action_env - -# Propagate tags from a target declaration to the actions' execution requirements. -# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]` -# get propagated to actions created by the rule. -# Without this option, you rely on rules authors to manually check the tags you passed -# and apply relevant ones to the actions they create. -# See https://github.com/bazelbuild/bazel/issues/8830 for details. -# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation -build --experimental_allow_tags_propagation -fetch --experimental_allow_tags_propagation -query --experimental_allow_tags_propagation - -# Do not automatically create `__init__.py` files in the runfiles of Python targets. Fixes the wrong -# default that comes from Google's internal monorepo by using `__init__.py` to delimit a Python -# package. Precisely, when a `py_binary` or `py_test` target has `legacy_create_init` set to `auto (the -# default), it is treated as false if and only if this flag is set. See -# https://github.com/bazelbuild/bazel/issues/10076. -# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_default_to_explicit_init_py -build --incompatible_default_to_explicit_init_py - -# Set default value of `allow_empty` to `False` in `glob()`. This prevents a common mistake when -# attempting to use `glob()` to match files in a subdirectory that is opaque to the current package -# because it contains a BUILD file. See https://github.com/bazelbuild/bazel/issues/8195. -# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob -common --incompatible_disallow_empty_glob - -# Always download coverage files for tests from the remote cache. By default, coverage files are not -# downloaded on test result cahce hits when --remote_download_minimal is enabled, making it impossible -# to generate a full coverage report. -# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs -# detching remote cache results -test --experimental_fetch_all_coverage_outputs diff --git a/.aspect/bazelrc/debug.bazelrc b/.aspect/bazelrc/debug.bazelrc deleted file mode 100644 index bfb0bdd..0000000 --- a/.aspect/bazelrc/debug.bazelrc +++ /dev/null @@ -1,19 +0,0 @@ -############################################################ -# Use `bazel test --config=debug` to enable these settings # -############################################################ - -# Stream stdout/stderr output from each test in real-time. -# Docs: https://bazel.build/docs/user-manual#test-output -test:debug --test_output=streamed - -# Run one test at a time. -# Docs: https://bazel.build/reference/command-line-reference#flag--test_strategy -test:debug --test_strategy=exclusive - -# Prevent long running tests from timing out. -# Docs: https://bazel.build/docs/user-manual#test-timeout -test:debug --test_timeout=9999 - -# Always run tests even if they have cached results. -# Docs: https://bazel.build/docs/user-manual#cache-test-results -test:debug --nocache_test_results diff --git a/.aspect/bazelrc/javascript.bazelrc b/.aspect/bazelrc/javascript.bazelrc deleted file mode 100644 index ace9d60..0000000 --- a/.aspect/bazelrc/javascript.bazelrc +++ /dev/null @@ -1,11 +0,0 @@ -# Aspect recommended Bazel flags when using Aspect's JavaScript rules: https://github.com/aspect-build/rules_js -# Docs for Node.js flags: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options - -# Support for debugging Node.js tests. Use bazel run with `--config=debug` to turn on the NodeJS -# inspector agent. The node process will break before user code starts and wait for the debugger to -# connect. Pass the --inspect-brk option to all tests which enables the node inspector agent. See -# https://nodejs.org/de/docs/guides/debugging-getting-started/#command-line-options for more -# details. -# Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options -run:debug -- --node_options=--inspect-brk -test:debug --test_env=NODE_OPTIONS=--inspect-brk diff --git a/.aspect/bazelrc/performance.bazelrc b/.aspect/bazelrc/performance.bazelrc deleted file mode 100644 index acc48c5..0000000 --- a/.aspect/bazelrc/performance.bazelrc +++ /dev/null @@ -1,20 +0,0 @@ -# Don't apply `--noremote_upload_local_results` and `--noremote_accept_cached` to the disk cache. -# If you have both `--noremote_upload_local_results` and `--disk_cache`, then this fixes a bug where -# Bazel doesn't write to the local disk cache as it treats as a remote cache. -# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_remote_results_ignore_disk -build --incompatible_remote_results_ignore_disk - -# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs. -# Save time on Sandbox creation and deletion when many of the same kind of action run during the -# build. -# No longer experimental in Bazel 6: https://github.com/bazelbuild/bazel/commit/c1a95501a5611878e5cc43a3cc531f2b9e47835b -# Docs: https://bazel.build/reference/command-line-reference#flag--reuse_sandbox_directories -build --experimental_reuse_sandbox_directories - -# Do not build runfiles symlink forests for external repositories under -# `.runfiles/wsname/external/repo` (in addition to `.runfiles/repo`). This reduces runfiles & -# sandbox creation times & prevents accidentally depending on this feature which may flip to off by -# default in the future. Note, some rules may fail under this flag, please file issues with the rule -# author. -# Docs: https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles -build --nolegacy_external_runfiles diff --git a/.bazelrc b/.bazelrc index 2c3f5c0..6718ccc 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,20 +1,16 @@ -# Import Aspect bazelrc presets -try-import %workspace%/.aspect/bazelrc/bazel7.bazelrc -import %workspace%/.aspect/bazelrc/convenience.bazelrc -import %workspace%/.aspect/bazelrc/correctness.bazelrc -import %workspace%/.aspect/bazelrc/debug.bazelrc -import %workspace%/.aspect/bazelrc/javascript.bazelrc -import %workspace%/.aspect/bazelrc/performance.bazelrc +import %workspace%/tools/preset.bazelrc ### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### +common --config=ruleset + # Don’t want to push a rules author to update their deps if not needed. # https://bazel.build/reference/command-line-reference#flag--check_direct_dependencies # https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0 common --check_direct_dependencies=off -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# Load any settings & overrides specific to the current user. # This file should appear in `.gitignore` so that settings are not shared with team members. This # should be last statement in this config so the user configuration is able to overwrite flags from # this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/.aspect/bazelrc/user.bazelrc \ No newline at end of file +try-import %workspace%/user.bazelrc diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 43befc4..75d76aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -119,11 +119,6 @@ jobs: # still bootstraps Aspect CLI from configuration in .bazeliskrc. Aspect CLI will # then use .bazelversion to determine which Bazel version to use. echo "${{ matrix.bazel-version.version }}" > .bazelversion - # Delete all the version specific bazelrc files that are used for local development - # since the version we're testing against is dynamic. These are just symlinks and the - # root .bazelrc brings these in with try-imports. In this CI workflows, we explicitly - # bring in the version specific bazelrc file with --bazelrc when we invoke bazel. - rm ${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/bazel*.bazelrc - name: bazel test //... working-directory: ${{ matrix.folder }} @@ -131,7 +126,7 @@ jobs: run: | bazel \ --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.github/workflows/bazel${{ matrix.bazel-version.major }}.bazelrc \ - --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/ci.bazelrc \ + --bazelrc=${GITHUB_WORKSPACE//\\/\/}/tools/preset.bazelrc \ --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.github/workflows/ci.bazelrc \ test \ --test_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \ diff --git a/.gitignore b/.gitignore index c9f5308..5c0db44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ bazel-* .bazelrc.user +user.bazelrc node_modules/ .pnpm-* diff --git a/MODULE.bazel b/MODULE.bazel index d2adfc9..413406d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -18,10 +18,11 @@ use_repo(tel, "aspect_tools_telemetry_report") ####### Dev dependencies ######## bazel_dep(name = "bazel_features", version = "0.1.0", dev_dependency = True) -bazel_dep(name = "platforms", version = "0.0.8", dev_dependency = True) +bazel_dep(name = "bazelrc-preset.bzl", version = "1.5.1", dev_dependency = True) bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") +bazel_dep(name = "platforms", version = "0.0.8", dev_dependency = True) buildifier_prebuilt = use_extension( "@buildifier_prebuilt//:defs.bzl", diff --git a/e2e/loaders/.bazelrc b/e2e/loaders/.bazelrc index 413c995..b09f80b 100644 --- a/e2e/loaders/.bazelrc +++ b/e2e/loaders/.bazelrc @@ -1,15 +1 @@ -# Import Aspect bazelrc presets -try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc -import %workspace%/../../.aspect/bazelrc/convenience.bazelrc -import %workspace%/../../.aspect/bazelrc/correctness.bazelrc -import %workspace%/../../.aspect/bazelrc/debug.bazelrc -import %workspace%/../../.aspect/bazelrc/javascript.bazelrc -import %workspace%/../../.aspect/bazelrc/performance.bazelrc - -### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### - -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. -# This file should appear in `.gitignore` so that settings are not shared with team members. This -# should be last statement in this config so the user configuration is able to overwrite flags from -# this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/../../.aspect/bazelrc/user.bazelrc +import %workspace%/../../tools/preset.bazelrc diff --git a/e2e/loaders_jslib/.bazelrc b/e2e/loaders_jslib/.bazelrc index 413c995..b09f80b 100644 --- a/e2e/loaders_jslib/.bazelrc +++ b/e2e/loaders_jslib/.bazelrc @@ -1,15 +1 @@ -# Import Aspect bazelrc presets -try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc -import %workspace%/../../.aspect/bazelrc/convenience.bazelrc -import %workspace%/../../.aspect/bazelrc/correctness.bazelrc -import %workspace%/../../.aspect/bazelrc/debug.bazelrc -import %workspace%/../../.aspect/bazelrc/javascript.bazelrc -import %workspace%/../../.aspect/bazelrc/performance.bazelrc - -### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### - -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. -# This file should appear in `.gitignore` so that settings are not shared with team members. This -# should be last statement in this config so the user configuration is able to overwrite flags from -# this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/../../.aspect/bazelrc/user.bazelrc +import %workspace%/../../tools/preset.bazelrc diff --git a/e2e/smoke/.bazelrc b/e2e/smoke/.bazelrc index 413c995..b09f80b 100644 --- a/e2e/smoke/.bazelrc +++ b/e2e/smoke/.bazelrc @@ -1,15 +1 @@ -# Import Aspect bazelrc presets -try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc -import %workspace%/../../.aspect/bazelrc/convenience.bazelrc -import %workspace%/../../.aspect/bazelrc/correctness.bazelrc -import %workspace%/../../.aspect/bazelrc/debug.bazelrc -import %workspace%/../../.aspect/bazelrc/javascript.bazelrc -import %workspace%/../../.aspect/bazelrc/performance.bazelrc - -### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### - -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. -# This file should appear in `.gitignore` so that settings are not shared with team members. This -# should be last statement in this config so the user configuration is able to overwrite flags from -# this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/../../.aspect/bazelrc/user.bazelrc +import %workspace%/../../tools/preset.bazelrc diff --git a/e2e/smoke_rjs3/.bazelrc b/e2e/smoke_rjs3/.bazelrc index 413c995..b09f80b 100644 --- a/e2e/smoke_rjs3/.bazelrc +++ b/e2e/smoke_rjs3/.bazelrc @@ -1,15 +1 @@ -# Import Aspect bazelrc presets -try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc -import %workspace%/../../.aspect/bazelrc/convenience.bazelrc -import %workspace%/../../.aspect/bazelrc/correctness.bazelrc -import %workspace%/../../.aspect/bazelrc/debug.bazelrc -import %workspace%/../../.aspect/bazelrc/javascript.bazelrc -import %workspace%/../../.aspect/bazelrc/performance.bazelrc - -### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### - -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. -# This file should appear in `.gitignore` so that settings are not shared with team members. This -# should be last statement in this config so the user configuration is able to overwrite flags from -# this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/../../.aspect/bazelrc/user.bazelrc +import %workspace%/../../tools/preset.bazelrc diff --git a/e2e/worker/.bazelrc b/e2e/worker/.bazelrc index 413c995..b09f80b 100644 --- a/e2e/worker/.bazelrc +++ b/e2e/worker/.bazelrc @@ -1,15 +1 @@ -# Import Aspect bazelrc presets -try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc -import %workspace%/../../.aspect/bazelrc/convenience.bazelrc -import %workspace%/../../.aspect/bazelrc/correctness.bazelrc -import %workspace%/../../.aspect/bazelrc/debug.bazelrc -import %workspace%/../../.aspect/bazelrc/javascript.bazelrc -import %workspace%/../../.aspect/bazelrc/performance.bazelrc - -### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### - -# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. -# This file should appear in `.gitignore` so that settings are not shared with team members. This -# should be last statement in this config so the user configuration is able to overwrite flags from -# this file. See https://bazel.build/configure/best-practices#bazelrc-file. -try-import %workspace%/../../.aspect/bazelrc/user.bazelrc +import %workspace%/../../tools/preset.bazelrc diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel new file mode 100644 index 0000000..28f6b98 --- /dev/null +++ b/tools/BUILD.bazel @@ -0,0 +1,10 @@ +load("@bazelrc-preset.bzl", "bazelrc_preset") + +bazelrc_preset( + name = "preset", + # The output is specific to the version in .bazelversion + tags = [ + "skip-on-bazel6", + "skip-on-bazel8", + ], +) diff --git a/tools/preset.bazelrc b/tools/preset.bazelrc new file mode 100644 index 0000000..d817b7d --- /dev/null +++ b/tools/preset.bazelrc @@ -0,0 +1,237 @@ +# Generated by bazelrc-preset.bzl +# To update this file, run: +# bazel run @@//tools:preset.update + +# On CI, announce all announces command options read from the bazelrc file(s) when starting up at the +# beginning of each Bazel invocation. This is very useful on CI to be able to inspect which flags +# are being applied on each run based on the order of overrides. +common:ci --announce_rc +# Docs: https://registry.build/flag/bazel@7.1.1?filter=announce_rc + +# Avoid creating a runfiles tree for binaries or tests until it is needed. +# See https://github.com/bazelbuild/bazel/issues/6627 +# This may break local workflows that `build` a binary target, then run the resulting program outside of `bazel run`. +# In those cases, the script will need to call `bazel build --build_runfile_links //my/binary:target` and then execute the resulting program. +common --nobuild_runfile_links +# Docs: https://registry.build/flag/bazel@7.1.1?filter=build_runfile_links + +# See https://github.com/bazelbuild/bazel/issues/20577 +coverage --build_runfile_links +# Docs: https://registry.build/flag/bazel@7.1.1?filter=build_runfile_links + +# Always run tests even if they have cached results. +# This ensures tests are executed fresh each time, useful for debugging and ensuring test reliability. +common:debug --nocache_test_results +# Docs: https://registry.build/flag/bazel@7.1.1?filter=cache_test_results + +# Don’t encourage a rules author to update their deps if not needed. +# These bazel_dep calls should indicate the minimum version constraint of the ruleset. +# If the author instead updates to the newest of any of their transitives, as this flag would suggest, +# then they'll also force their dependents to a newer version. +# Context: +# https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0 +common:ruleset --check_direct_dependencies="off" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=check_direct_dependencies + +# On CI, use colors to highlight output on the screen. Set to `no` if your CI does not display colors. +common:ci --color="yes" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=color + +# On CI, use cursor controls in screen output. +common:ci --curses="yes" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=curses + +# Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is +# Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS +# identifiers are `linux`, `macos`, `windows`, `freebsd`, and `openbsd`. Enabling this flag is +# equivalent to using `--config=linux` on Linux, `--config=windows` on Windows, etc. +common --enable_platform_specific_config +# Docs: https://registry.build/flag/bazel@7.1.1?filter=enable_platform_specific_config + +# Speed up all builds by not checking if external repository files have been modified. +# For reference: https://github.com/bazelbuild/bazel/blob/1af61b21df99edc2fc66939cdf14449c2661f873/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java#L244 +common --noexperimental_check_external_repository_files +# Docs: https://registry.build/flag/bazel@7.1.1?filter=experimental_check_external_repository_files + +# Always download coverage files for tests from the remote cache. By default, coverage files are not +# downloaded on test result cache hits when --remote_download_minimal is enabled, making it impossible +# to generate a full coverage report. +common --experimental_fetch_all_coverage_outputs +# Docs: https://registry.build/flag/bazel@7.1.1?filter=experimental_fetch_all_coverage_outputs + +# This flag was added in Bazel 6.2.0 with a default of zero: +# https://github.com/bazelbuild/bazel/commit/24b45890c431de98d586fdfe5777031612049135 +# For Bazel 8.0.0rc1 the default was changed to 5: +# https://github.com/bazelbuild/bazel/commit/739e37de66f4913bec1a55b2f2a162e7db6f2d0f +# Back-port the updated flag default value to older Bazel versions. +common --experimental_remote_cache_eviction_retries=5 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=experimental_remote_cache_eviction_retries + +# This flag was added in Bazel 5.0.0 with a default of zero: +# https://github.com/bazelbuild/bazel/commit/a1137ec1338d9549fd34a9a74502ffa58c286a8e +# For Bazel 8.0.0 the default was changed to 5: +# https://github.com/bazelbuild/bazel/commit/9335cf989ee6a678ca10bc4da72214634cef0a57 +# Back-port the updated flag default value to older Bazel versions. +common --experimental_repository_downloader_retries=5 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=experimental_repository_downloader_retries + +# Set this flag to enable re-tries of failed tests on CI. +# When any test target fails, try one or more times. This applies regardless of whether the "flaky" +# tag appears on the target definition. +# This is a tradeoff: legitimately failing tests will take longer to report, +# but we can "paper over" flaky tests that pass most of the time. +# +# An alternative is to mark every flaky test with the `flaky = True` attribute, but this requires +# the buildcop to make frequent code edits. +# This flag is not recommended for local builds: flakiness is more likely to get fixed if it is +# observed during development. +# +# Note that when passing after the first attempt, Bazel will give a special "FLAKY" status rather than "PASSED". +test:ci --flaky_test_attempts=2 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=flaky_test_attempts + +# Fixes builds hanging on CI that get the TCP connection closed without sending RST packets. +common:ci --grpc_keepalive_time="30s" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=grpc_keepalive_time + +# Output a heap dump if an OOM is thrown during a Bazel invocation +# (including OOMs due to `--experimental_oom_more_eagerly_threshold`). +# The dump will be written to `/.heapdump.hprof`. +# You should configure CI to upload this artifact for later inspection. +common --heap_dump_on_oom +# Docs: https://registry.build/flag/bazel@7.1.1?filter=heap_dump_on_oom + +# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server +# notices when a directory changes, if you have a directory listed in the srcs of some target. +# Recommended when using [copy_directory](https://github.com/bazel-contrib/bazel-lib/blob/main/docs/copy_directory.md) +# and [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories inputs to copy_directory actions. +startup --host_jvm_args="-DBAZEL_TRACK_SOURCE_DIRECTORIES=1" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=host_jvm_args + +# By default, Bazel automatically creates __init__.py files for py_binary and py_test targets. +# From https://github.com/bazelbuild/bazel/issues/10076: +# > It is magic at a distance. +# > Python programmers are already used to creating __init__.py files in their source trees, +# > so doing it behind their backs introduces confusion and changes the semantics of imports +common --incompatible_default_to_explicit_init_py +# Docs: https://registry.build/flag/bazel@7.1.1?filter=incompatible_default_to_explicit_init_py + +# Disallow empty glob patterns. +# The glob() function tends to be error-prone, because any typo in a path will silently return an empty list. +# This flag was added in Bazel 0.27 and flipped in Bazel 8: https://github.com/bazelbuild/bazel/issues/8195 +common --incompatible_disallow_empty_glob +# Docs: https://registry.build/flag/bazel@7.1.1?filter=incompatible_disallow_empty_glob + +# Make builds more reproducible by using a static value for PATH and not inheriting LD_LIBRARY_PATH. +# Use `--action_env=ENV_VARIABLE` if you want to inherit specific variables from the environment where Bazel runs. +# Note that doing so can prevent cross-user caching if a shared cache is used. +# See https://github.com/bazelbuild/bazel/issues/2574 for more details. +common --incompatible_strict_action_env +# Docs: https://registry.build/flag/bazel@7.1.1?filter=incompatible_strict_action_env + +# Performance improvement: avoid laying out a second copy of the runfiles tree. +# See https://github.com/bazelbuild/bazel/issues/23574. +# This flag was flipped for Bazel 8. +common --nolegacy_external_runfiles +# Docs: https://registry.build/flag/bazel@7.1.1?filter=legacy_external_runfiles + +# On CI, don't download remote outputs to the local machine. +# Most CI pipelines don't need to access the files and they can remain at rest on the remote cache. +# Significant time can be spent on needless downloads, which is especially noticeable on fully-cached builds. +# +# If you do need to download files, the fastest options are: +# - (preferred) Use `remote_download_regex` to specify the files to download. +# - Use the Remote Output Service (https://blog.bazel.build/2024/07/23/remote-output-service.html) +# to lazy-materialize specific files after the build completes. +# - Perform a second bazel command with specific targets and override this flag with the `toplevel` value. +# - To copy executable targets, you can use `bazel run --run_under=cp //some:binary_target `. +common:ci --remote_download_outputs="minimal" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=remote_download_outputs + +# On CI, fall back to standalone local execution strategy if remote execution fails. +# Otherwise, when a grpc remote cache connection fails, it would fail the build. +common:ci --remote_local_fallback +# Docs: https://registry.build/flag/bazel@7.1.1?filter=remote_local_fallback + +# On CI, extend the maximum amount of time to wait for remote execution and cache calls. +common:ci --remote_timeout=3600 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=remote_timeout + +# Do not upload locally executed action results to the remote cache. +# This should be the default for local builds so local builds cannot poison the remote cache. +# +# Note that this flag is flipped to True under --config=ci, see below. +common --noremote_upload_local_results +# Docs: https://registry.build/flag/bazel@7.1.1?filter=remote_upload_local_results + +# On CI, upload locally executed action results to the remote cache. +common:ci --remote_upload_local_results +# Docs: https://registry.build/flag/bazel@7.1.1?filter=remote_upload_local_results + +# Repository rules, such as rules_jvm_external: put Bazel's JDK on the path. +# Avoids non-hermeticity from dependency on a JAVA_HOME pointing at a system JDK +# see https://github.com/bazelbuild/rules_jvm_external/issues/445 +common --repo_env="JAVA_HOME=../bazel_tools/jdk" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=repo_env + +# Reuse sandbox directories between invocations. +# Directories used by sandboxed non-worker execution may be reused to avoid unnecessary setup costs. +# Saves time on sandbox creation and deletion when many of the same kind of action is spawned during the build. +common --reuse_sandbox_directories +# Docs: https://registry.build/flag/bazel@7.1.1?filter=reuse_sandbox_directories + +# Don't allow network access for build actions in the sandbox by default. +# Avoids accidental non-hermeticity in actions/tests which depend on remote services. +# Developers should tag targets with `tags=["requires-network"]` to be explicit that they need network access. +# Note that the sandbox cannot print a message to the console if it denies network access, +# so failures under this flag appear as application errors in the networking layer. +common --nosandbox_default_allow_network +# Docs: https://registry.build/flag/bazel@7.1.1?filter=sandbox_default_allow_network + +# Only show progress every 60 seconds on CI. +# We want to find a compromise between printing often enough to show that the build isn't stuck, +# but not so often that we produce a long log file that requires a lot of scrolling. +common:ci --show_progress_rate_limit=60 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=show_progress_rate_limit + +# The printed files are convenient strings for copy+pasting to the shell, to execute them. +# This option requires an integer argument, which is the threshold number of targets above which result information is not printed. +# Show the output files created by builds that requested more than one target. +# This helps users locate the build outputs in more cases. +common --show_result=20 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=show_result + +# On CI, add a timestamp to each message generated by Bazel specifying the time at which the message was displayed. +# This makes it easier to reason about what were the slowest steps on CI. +common:ci --show_timestamps +# Docs: https://registry.build/flag/bazel@7.1.1?filter=show_timestamps + +# The terminal width in columns. Configure this to override the default value based on what your CI system renders. +common:ci --terminal_columns=143 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=terminal_columns + +# Output test errors to stderr so users don't have to `cat` or open test failure log files when test fail. +# This makes the log noisier in exchange for reducing the time-to-feedback on test failures for users. +common --test_output="errors" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=test_output + +# Stream stdout/stderr output from each test in real-time. +# This provides immediate feedback during test execution, useful for debugging test failures. +common:debug --test_output="streamed" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=test_output + +# Run one test at a time in exclusive mode. +# This prevents test interference and provides clearer output when debugging test issues. +common:debug --test_strategy="exclusive" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=test_strategy + +# The default test_summary ("short") prints a result for every test target that was executed. +# In a large repo this amounts to hundreds of lines of additional log output when testing a broad wildcard pattern like //... +# This value means to print information only about unsuccessful tests that were run. +test:ci --test_summary="terse" +# Docs: https://registry.build/flag/bazel@7.1.1?filter=test_summary + +# Prevent long running tests from timing out. +# Set to a high value to allow tests to complete even if they take longer than expected. +common:debug --test_timeout=9999 +# Docs: https://registry.build/flag/bazel@7.1.1?filter=test_timeout