ci: stabilize Windows Bazel PATH inputs

This commit is contained in:
Michael Bolin
2026-04-23 09:01:49 -07:00
parent 2b2de3f38b
commit 48948ea9e8
2 changed files with 39 additions and 1 deletions

View File

@@ -29,6 +29,9 @@ common:linux --test_env=PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
common:macos --test_env=PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# Pass through some env vars Windows needs to use powershell?
# CI overrides PATH in `.github/scripts/run-bazel-ci.sh` with a cache-stable
# allow-list so unrelated GitHub Windows image tool updates do not invalidate
# BuildBuddy action/test cache entries.
common:windows --test_env=PATH
common:windows --test_env=SYSTEMROOT
common:windows --test_env=COMSPEC

View File

@@ -306,7 +306,6 @@ if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
INCLUDE
LIB
LIBPATH
PATH
UCRTVersion
UniversalCRTSdkDir
VCINSTALLDIR
@@ -323,6 +322,42 @@ if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
post_config_bazel_args+=("--action_env=${env_var}" "--host_action_env=${env_var}")
fi
done
# The GitHub Windows image puts many unrelated versioned tools on PATH. Those
# entries are still part of Bazel action/test keys when PATH is forwarded, so
# image churn such as Maven minor-version updates can invalidate otherwise
# reusable cache entries. Keep only the PATH segments Bazel actions/tests need.
windows_cache_stable_path_entries=()
if [[ -n "${PATH:-}" ]]; then
IFS=';' read -r -a windows_path_entries <<< "${PATH}"
for path_entry in "${windows_path_entries[@]}"; do
case "${path_entry}" in
*'Microsoft Visual Studio'* | \
*'Windows Kits'* | \
*'Microsoft SDKs'* | \
'C:\Program Files\Git\'* | \
'C:\Program Files\PowerShell\'* | \
'C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps' | \
'C:\hostedtoolcache\windows\node\'* | \
'C:\Windows' | \
'C:\Windows\'* | \
'D:\a\_temp\install-dotslash\bin')
windows_cache_stable_path_entries+=("${path_entry}")
;;
esac
done
fi
if (( ${#windows_cache_stable_path_entries[@]} > 0 )); then
stable_windows_path="$(IFS=';'; printf '%s' "${windows_cache_stable_path_entries[*]}")"
post_config_bazel_args+=(
"--action_env=PATH=${stable_windows_path}"
"--host_action_env=PATH=${stable_windows_path}"
"--test_env=PATH=${stable_windows_path}"
)
elif [[ -n "${PATH:-}" ]]; then
post_config_bazel_args+=("--action_env=PATH" "--host_action_env=PATH" "--test_env=PATH")
fi
fi
bazel_console_log="$(mktemp)"