ci: align just bazel helpers with workflow behavior

This commit is contained in:
Michael Bolin
2026-03-28 15:11:08 -07:00
parent 4e27a87ec6
commit 5323bbab8a
2 changed files with 50 additions and 28 deletions

View File

@@ -41,8 +41,23 @@ if [[ -n "${BAZEL_OUTPUT_USER_ROOT:-}" ]]; then
bazel_startup_args+=("--output_user_root=${BAZEL_OUTPUT_USER_ROOT}")
fi
runner_os="${RUNNER_OS:-}"
if [[ -z "${runner_os}" ]]; then
case "$(uname -s)" in
Darwin)
runner_os=macOS
;;
Linux)
runner_os=Linux
;;
MINGW*|MSYS*|CYGWIN*)
runner_os=Windows
;;
esac
fi
ci_config=ci-linux
case "${RUNNER_OS:-}" in
case "${runner_os}" in
macOS)
ci_config=ci-macos
;;
@@ -112,7 +127,7 @@ if [[ ${#bazel_args[@]} -eq 0 || ${#bazel_targets[@]} -eq 0 ]]; then
exit 1
fi
if [[ $use_node_test_env -eq 1 && "${RUNNER_OS:-}" != "Windows" ]]; then
if [[ $use_node_test_env -eq 1 && "${runner_os}" != "Windows" ]]; then
# Bazel test sandboxes on macOS may resolve an older Homebrew `node`
# before the `actions/setup-node` runtime on PATH.
node_bin="$(which node)"
@@ -158,28 +173,34 @@ if [[ -n "${BUILDBUDDY_API_KEY:-}" ]]; then
bazel_status=${PIPESTATUS[0]}
set -e
else
echo "BuildBuddy API key is not available; using local Bazel configuration."
# Keep fork/community PRs on Bazel but disable remote services that are
# configured in .bazelrc and require auth.
#
# Flag docs:
# - Command-line reference: https://bazel.build/reference/command-line-reference
# - Remote caching overview: https://bazel.build/remote/caching
# - Remote execution overview: https://bazel.build/remote/rbe
# - Build Event Protocol overview: https://bazel.build/remote/bep
#
# --noexperimental_remote_repo_contents_cache:
# disable remote repo contents cache enabled in .bazelrc startup options.
# https://bazel.build/reference/command-line-reference#startup_options-flag--experimental_remote_repo_contents_cache
# --remote_cache= and --remote_executor=:
# clear remote cache/execution endpoints configured in .bazelrc.
# https://bazel.build/reference/command-line-reference#common_options-flag--remote_cache
# https://bazel.build/reference/command-line-reference#common_options-flag--remote_executor
bazel_run_args=(
"${bazel_args[@]}"
--remote_cache=
--remote_executor=
)
bazel_run_args=("${bazel_args[@]}")
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
echo "BuildBuddy API key is not available in GitHub Actions; disabling remote Bazel services."
# Keep fork/community PRs on Bazel but disable remote services that are
# configured in .bazelrc and require auth.
#
# Flag docs:
# - Command-line reference: https://bazel.build/reference/command-line-reference
# - Remote caching overview: https://bazel.build/remote/caching
# - Remote execution overview: https://bazel.build/remote/rbe
# - Build Event Protocol overview: https://bazel.build/remote/bep
#
# --noexperimental_remote_repo_contents_cache:
# disable remote repo contents cache enabled in .bazelrc startup options.
# https://bazel.build/reference/command-line-reference#startup_options-flag--experimental_remote_repo_contents_cache
# --remote_cache= and --remote_executor=:
# clear remote cache/execution endpoints configured in .bazelrc.
# https://bazel.build/reference/command-line-reference#common_options-flag--remote_cache
# https://bazel.build/reference/command-line-reference#common_options-flag--remote_executor
bazel_run_args+=(
--remote_cache=
--remote_executor=
)
else
echo "BuildBuddy API key env var is not available; preserving Bazel remote settings from local Bazel config."
fi
if (( ${#post_config_bazel_args[@]} > 0 )); then
bazel_run_args+=("${post_config_bazel_args[@]}")
fi