Skip to content

Commit dc389f6

Browse files
authored
Enable Bazel runfiles on Windows with widened test surface (#48206)
Prior art: 1. #48082 2. #48087 3. #48188 (1st attempt) 4. #48207 5. #48281 6. #48209 ### What does this PR do? This is a redo of #48188 (preemptively reverted by #48207) and therefore merely consists in re-adding `common:windows --enable_runfiles` to `.bazelrc`. ... with lessons learned, thanks to earlier: - #48209 covers the present change to `.bazelrc`, - #48281 prevents `find_python.bat` from falling back to `NuGet` or other non hermetic sources. .... and now a widened `bazel:test:windows-amd64`, evolving from just `//bazel/tests/... //rtloader/...` to `//...` **- except currently failing targets** (for the time being, of course). ### Motivation Summary of #48188: - `rules_python` 1.9.0 (#48082) transitions every `py_binary` and `py_test` on Windows from `enable_runfiles=auto` to `enable_runfiles=true`, - with Bazel's default (`enable_runfiles=false` on Windows), this creates a second Bazel configuration, causing `python_win` to be built twice concurrently, - `build_python.bat` writes `MSBuild` intermediates to the shared execroot source tree rather than the action's output directory, so both builds race on those files, causing [intermittent failures](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1533753039) (`pyconfig.h` not found, etc.). **Pre-setting `--enable_runfiles` makes the transition a no-op, so Bazel sees a single configuration and builds `python_win` once.** ### Describe how you validated your changes Local VM and, of course, CI. ### Additional Notes For instance, `//pkg/template/...` is excluded on Windows because `gopatch` errors on `@@\r` in hunk markers when patch files have CRLF line endings, which deserves a distinct PR (likely adjusting `.gitattributes`). Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
1 parent f33471b commit dc389f6

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ common:macos --remote_local_fallback_strategy=sandboxed
4141

4242
# Windows config -------------------------------------------------------------------------------------------------------
4343
common:windows --strategy=standalone # Valid values are: [dynamic_worker, standalone, dynamic, remote, worker, local]
44+
# rules_python 1.9.0 transitions enable_runfiles to `true` for every py_ target on Windows. Pre-setting it here makes
45+
# that transition a no-op, so Bazel deduplicates python_win and avoids 2 concurrent MSBuild racing on shared resources.
46+
common:windows --enable_runfiles
4447
# Neither repo_env nor shell_executable affect action keys. It can be both an advantage and a disadvantage.
4548
# For instance, if we need to have some special behavior in bash we can add it, however, in some cases
4649
# it may lead to cache poisoning.

.gitlab/build/bazel/test.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,19 @@ bazel:test:macos-arm64:
2626
bazel:test:windows-amd64:
2727
extends: [ .bazel:test, .bazel:runner:windows-amd64 ]
2828
variables:
29-
POWERSHELL_SCRIPT: |-
30-
bazel test //bazel/tests/... //rtloader/...
29+
POWERSHELL_SCRIPT: >-
30+
bazel test //... --
31+
-//bazel/rules/dd_packaging/...
32+
-//internal/tools/modparser:modparser_test
33+
-//internal/tools/worksynchronizer:worksynchronizer_test
34+
-//packages/agent/linux/...
35+
-//pkg/collector/corechecks/ebpf/probe/...
36+
-//pkg/dyninst/loader/...
37+
-//pkg/dyninst/output/...
38+
-//pkg/ebpf/...
39+
-//pkg/gpu/ebpf/...
40+
-//pkg/network/...
41+
-//pkg/networkdevice/profile/profiledefinition/schema:schema_test
42+
-//pkg/template/...
43+
44+
# //pkg/template:generate_N_test: TODO(regis) .gopatch files seem to be altered by .gitattributes

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ register_toolchains(
224224
visual_studio(
225225
name = "visual_studio",
226226
path_variable = "VSTUDIO_ROOT",
227-
version = "17.14.36717.8",
227+
version = "17.14.36717.8", # 18.4.11612.150
228228
)
229229

230230
# =========================================

0 commit comments

Comments
 (0)