diff --git a/.bazelrc b/.bazelrc index 76f81ade40..b6701ba265 100644 --- a/.bazelrc +++ b/.bazelrc @@ -153,6 +153,18 @@ common:ci-macos --config=remote common:ci-macos --strategy=remote common:ci-macos --strategy=TestRunner=darwin-sandbox,local +# On Windows, use Linux remote execution for build actions but keep test actions +# on the Windows runner so Bazel's normal test sharding and flaky-test retries +# still run against Windows binaries. +common:ci-windows-cross --config=ci-windows +common:ci-windows-cross --build_metadata=TAG_windows_cross_compile=true +common:ci-windows-cross --config=remote +common:ci-windows-cross --strategy=remote +common:ci-windows-cross --strategy=TestRunner=local +common:ci-windows-cross --local_test_jobs=8 +common:ci-windows-cross --platforms=//:windows_x86_64_gnullvm +common:ci-windows-cross --extra_execution_platforms=//:rbe,//:windows_x86_64_gnullvm + # Linux-only V8 CI config. common:ci-v8 --config=ci common:ci-v8 --build_metadata=TAG_workflow=v8 diff --git a/.github/scripts/run-bazel-ci.sh b/.github/scripts/run-bazel-ci.sh index b81e0a4d57..f665781f28 100755 --- a/.github/scripts/run-bazel-ci.sh +++ b/.github/scripts/run-bazel-ci.sh @@ -6,6 +6,7 @@ print_failed_bazel_test_logs=0 print_failed_bazel_action_summary=0 remote_download_toplevel=0 windows_msvc_host_platform=0 +windows_cross_compile=0 while [[ $# -gt 0 ]]; do case "$1" in @@ -25,6 +26,10 @@ while [[ $# -gt 0 ]]; do windows_msvc_host_platform=1 shift ;; + --windows-cross-compile) + windows_cross_compile=1 + shift + ;; --) shift break @@ -37,7 +42,7 @@ while [[ $# -gt 0 ]]; do done if [[ $# -eq 0 ]]; then - echo "Usage: $0 [--print-failed-test-logs] [--print-failed-action-summary] [--remote-download-toplevel] [--windows-msvc-host-platform] -- -- " >&2 + echo "Usage: $0 [--print-failed-test-logs] [--print-failed-action-summary] [--remote-download-toplevel] [--windows-msvc-host-platform] [--windows-cross-compile] -- -- " >&2 exit 1 fi @@ -61,7 +66,11 @@ case "${RUNNER_OS:-}" in ci_config=ci-macos ;; Windows) - ci_config=ci-windows + if [[ $windows_cross_compile -eq 1 ]]; then + ci_config=ci-windows-cross + else + ci_config=ci-windows + fi ;; esac @@ -269,6 +278,13 @@ if [[ $remote_download_toplevel -eq 1 ]]; then post_config_bazel_args+=(--remote_download_toplevel) fi +if [[ "${RUNNER_OS:-}" == "Windows" && $windows_cross_compile -eq 1 && -z "${BUILDBUDDY_API_KEY:-}" ]]; then + # The Windows cross-compile config depends on remote execution. Fork PRs do + # not receive the BuildBuddy secret, so fall back to the existing local build + # shape and keep its lower concurrency cap. + post_config_bazel_args+=(--jobs=8) +fi + if [[ -n "${BAZEL_REPO_CONTENTS_CACHE:-}" ]]; then # Windows self-hosted runners can run multiple Bazel jobs concurrently. Give # each job its own repo contents cache so they do not fight over the shared diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index ef41330c46..384e8427fc 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -22,8 +22,6 @@ jobs: # true test failure in a rust_test() marked "flaky" that gets run 3x. # In that case, extra time generally does not give us more signal. # - # Ultimately we need true distributed builds (e.g., - # https://www.buildbuddy.io/docs/rbe-setup/) to speed things up. timeout-minutes: 30 strategy: fail-fast: false @@ -53,7 +51,7 @@ jobs: runs-on: ${{ matrix.os }} # Configure a human readable name for each job - name: Local Bazel build on ${{ matrix.os }} for ${{ matrix.target }} + name: Bazel test on ${{ matrix.os }} for ${{ matrix.target }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -100,8 +98,7 @@ jobs: --build_metadata=COMMIT_SHA=${GITHUB_SHA} ) if [[ "${RUNNER_OS}" == "Windows" ]]; then - bazel_wrapper_args+=(--windows-msvc-host-platform) - bazel_test_args+=(--jobs=8) + bazel_wrapper_args+=(--windows-msvc-host-platform --windows-cross-compile) fi ./.github/scripts/run-bazel-ci.sh \ diff --git a/BUILD.bazel b/BUILD.bazel index 3f59ff1160..1148033bb9 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -30,6 +30,24 @@ platform( parents = ["@platforms//host"], ) +platform( + name = "windows_x86_64_gnullvm", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:windows", + "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm", + ], +) + +platform( + name = "windows_x86_64_msvc", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:windows", + "@rules_rs//rs/experimental/platforms/constraints:windows_msvc", + ], +) + alias( name = "rbe", actual = "@rbe_platform",