Skip to content

Commit 1d7fd51

Browse files
authored
fix(ci): use --enable_workspace for bazel-in-bazel tests (bazel-contrib#2237)
The CI on `main` started failing and is affecting all PRs. Most likely a fixup to bazel-contrib#2184.
1 parent ade0b2b commit 1d7fd51

File tree

6 files changed

+90
-48
lines changed

6 files changed

+90
-48
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.0.0
1+
7.1.0

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ A brief description of the categories of changes:
3535
* (toolchains) {obj}`py_cc_toolchain.libs` and {obj}`PyCcToolchainInfo.libs` is
3636
optional. This is to support situations where only the Python headers are
3737
available.
38+
* (bazel) Minimum bazel 7 version that we test against has been bumped to `7.1`.
3839

3940
### Fixed
4041
* (whl_library): Remove `--no-index` and add `--no-build-isolation` to the

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ bazel_binaries.local(
116116
path = "tests/integration/bazel_from_env",
117117
)
118118
bazel_binaries.download(version = "6.4.0")
119+
bazel_binaries.download(version = "7.3.1")
119120
bazel_binaries.download(version = "rolling")
120121
use_repo(
121122
bazel_binaries,
@@ -124,6 +125,7 @@ use_repo(
124125
# that should be use_repo()'d, so we add them as requested
125126
"bazel_binaries_bazelisk",
126127
"build_bazel_bazel_6_4_0",
128+
"build_bazel_bazel_7_3_1",
127129
"build_bazel_bazel_rolling",
128130
"build_bazel_bazel_self",
129131
)

tests/integration/BUILD.bazel

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ load(":integration_test.bzl", "rules_python_integration_test")
1919

2020
licenses(["notice"])
2121

22-
_WORKSPACE_FLAGS = [
22+
_LEGACY_WORKSPACE_FLAGS = [
2323
"--noenable_bzlmod",
2424
]
2525

26+
_WORKSPACE_FLAGS = _LEGACY_WORKSPACE_FLAGS + [
27+
"--enable_workspace",
28+
]
29+
2630
_WORKSPACE_GAZELLE_PLUGIN_FLAGS = [
2731
"--override_repository=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin",
2832
]
@@ -31,6 +35,24 @@ _GAZELLE_PLUGIN_FLAGS = [
3135
"--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin",
3236
]
3337

38+
default_test_runner(
39+
name = "bazel_6_4_workspace_test_runner",
40+
bazel_cmds = [
41+
"info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS)),
42+
"test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS)),
43+
],
44+
visibility = ["//visibility:public"],
45+
)
46+
47+
default_test_runner(
48+
name = "bazel_6_4_workspace_test_runner_gazelle_plugin",
49+
bazel_cmds = [
50+
"info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
51+
"test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
52+
],
53+
visibility = ["//visibility:public"],
54+
)
55+
3456
default_test_runner(
3557
name = "workspace_test_runner",
3658
bazel_cmds = [

tests/integration/integration_test.bzl

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,40 @@
1616
load("@bazel_binaries//:defs.bzl", "bazel_binaries")
1717
load(
1818
"@rules_bazel_integration_test//bazel_integration_test:defs.bzl",
19-
"bazel_integration_tests",
19+
"bazel_integration_test",
2020
"integration_test_utils",
2121
)
2222
load("//python:py_test.bzl", "py_test")
2323

24+
def _test_runner(*, name, bazel_version, py_main, bzlmod, gazelle_plugin):
25+
if py_main:
26+
test_runner = "{}_bazel_{}_py_runner".format(name, bazel_version)
27+
py_test(
28+
name = test_runner,
29+
srcs = [py_main],
30+
main = py_main,
31+
deps = [":runner_lib"],
32+
# Hide from ... patterns; should only be run as part
33+
# of the bazel integration test
34+
tags = ["manual"],
35+
)
36+
return test_runner
37+
38+
if bazel_version.startswith("6") and not bzlmod:
39+
if gazelle_plugin:
40+
return "//tests/integration:bazel_6_4_workspace_test_runner_gazelle_plugin"
41+
else:
42+
return "//tests/integration:bazel_6_4_workspace_test_runner"
43+
44+
if bzlmod and gazelle_plugin:
45+
return "//tests/integration:test_runner_gazelle_plugin"
46+
elif bzlmod:
47+
return "//tests/integration:test_runner"
48+
elif gazelle_plugin:
49+
return "//tests/integration:workspace_test_runner_gazelle_plugin"
50+
else:
51+
return "//tests/integration:workspace_test_runner"
52+
2453
def rules_python_integration_test(
2554
name,
2655
workspace_path = None,
@@ -48,26 +77,6 @@ def rules_python_integration_test(
4877
**kwargs: Passed to the upstream `bazel_integration_tests` rule.
4978
"""
5079
workspace_path = workspace_path or name.removesuffix("_test")
51-
if py_main:
52-
test_runner = name + "_py_runner"
53-
py_test(
54-
name = test_runner,
55-
srcs = [py_main],
56-
main = py_main,
57-
deps = [":runner_lib"],
58-
# Hide from ... patterns; should only be run as part
59-
# of the bazel integration test
60-
tags = ["manual"],
61-
)
62-
elif bzlmod:
63-
if gazelle_plugin:
64-
test_runner = "//tests/integration:test_runner_gazelle_plugin"
65-
else:
66-
test_runner = "//tests/integration:test_runner"
67-
elif gazelle_plugin:
68-
test_runner = "//tests/integration:workspace_test_runner_gazelle_plugin"
69-
else:
70-
test_runner = "//tests/integration:workspace_test_runner"
7180

7281
# Because glob expansion happens at loading time, the bazel-* symlinks
7382
# in the workspaces can recursively expand to tens-of-thousands of entries,
@@ -89,27 +98,35 @@ def rules_python_integration_test(
8998
],
9099
)
91100
kwargs.setdefault("size", "enormous")
92-
bazel_integration_tests(
93-
name = name,
94-
workspace_path = workspace_path,
95-
test_runner = test_runner,
96-
bazel_versions = bazel_versions or bazel_binaries.versions.all,
97-
workspace_files = [name + "_workspace_files"],
98-
# Override the tags so that the `manual` tag isn't applied.
99-
tags = (tags or []) + [
100-
# These tests are very heavy weight, so much so that only a couple
101-
# can be run in parallel without harming their reliability,
102-
# overall runtime, and the system's stability. Unfortunately,
103-
# there doesn't appear to be a way to tell Bazel to limit their
104-
# concurrency, only disable it entirely with exclusive.
105-
"exclusive",
106-
# The default_test_runner() assumes it can write to the user's home
107-
# directory for caching purposes. Give it access.
108-
"no-sandbox",
109-
# The CI RBE setup can't successfully run these tests remotely.
110-
"no-remote-exec",
111-
# A special tag is used so CI can run them as a separate job.
112-
"integration-test",
113-
],
114-
**kwargs
115-
)
101+
for bazel_version in bazel_versions or bazel_binaries.versions.all:
102+
test_runner = _test_runner(
103+
name = name,
104+
bazel_version = bazel_version,
105+
py_main = py_main,
106+
bzlmod = bzlmod,
107+
gazelle_plugin = gazelle_plugin,
108+
)
109+
bazel_integration_test(
110+
name = "{}_bazel_{}".format(name, bazel_version),
111+
workspace_path = workspace_path,
112+
test_runner = test_runner,
113+
bazel_version = bazel_version,
114+
workspace_files = [name + "_workspace_files"],
115+
# Override the tags so that the `manual` tag isn't applied.
116+
tags = (tags or []) + [
117+
# These tests are very heavy weight, so much so that only a couple
118+
# can be run in parallel without harming their reliability,
119+
# overall runtime, and the system's stability. Unfortunately,
120+
# there doesn't appear to be a way to tell Bazel to limit their
121+
# concurrency, only disable it entirely with exclusive.
122+
"exclusive",
123+
# The default_test_runner() assumes it can write to the user's home
124+
# directory for caching purposes. Give it access.
125+
"no-sandbox",
126+
# The CI RBE setup can't successfully run these tests remotely.
127+
"no-remote-exec",
128+
# A special tag is used so CI can run them as a separate job.
129+
"integration-test",
130+
],
131+
**kwargs
132+
)

version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# against.
1818
# This version should be updated together with the version of Bazel
1919
# in .bazelversion.
20-
BAZEL_VERSION = "7.0.0"
20+
BAZEL_VERSION = "7.1.0"
2121

2222
# NOTE: Keep in sync with .bazelci/presubmit.yml
2323
# This is the minimum supported bazel version, that we have some tests for.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy