Skip to content

Commit f629972

Browse files
fix(module): Avoid subrepo use (#658)
Local repos break in BCR and would break consumers. Move the #610 test case to a new e2e dir which is how we've organized and managed repo level tests. ### Changes are visible to end-users: no ### Test plan This is the test plan. --------- Co-authored-by: aspect-marvin[bot] <[email protected]>
1 parent 96d1574 commit f629972

File tree

14 files changed

+115
-30
lines changed

14 files changed

+115
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,21 @@ jobs:
2626
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@646899086d7aaee8e532540480f3e91e00596234 # 11 Dec 2024
2727
with:
2828
# NB: the root folder is tested with Aspect Workflows on BuildKite, see /.aspect/workflows/config.yaml
29-
folders: '["e2e/smoke", "e2e/repository-rule-deps", "e2e/system-interpreter", "examples/uv_pip_compile"]'
29+
folders: |
30+
[
31+
"e2e/cross-repo-610",
32+
"e2e/repository-rule-deps",
33+
"e2e/smoke",
34+
"e2e/system-interpreter",
35+
"examples/uv_pip_compile"
36+
]
3037
# TODO: Build Windows tools and add to toolchain
3138
# TODO(alex): switch the root folder to bzlmod
3239
# TODO: fix remaining folders on Bazel 8
3340
exclude: |
3441
[
3542
{"os": "windows-latest"},
43+
{"folder": "e2e/cross-repo-610", "bzlmodEnabled": false},
3644
{"folder": "e2e/repository-rule-deps", "bzlmodEnabled": false},
3745
{"folder": "e2e/system-interpreter", "bzlmodEnabled": false},
3846
{"folder": "examples/uv_pip_compile", "bzlmodEnabled": false},

MODULE.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,3 @@ oci.pull(
114114
tag = "latest",
115115
)
116116
use_repo(oci, "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8")
117-
118-
# For tests
119-
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
120-
121-
local_repository(
122-
name = "rpy610_test",
123-
path = "./py/tests/rpy610/subrepo",
124-
)

e2e/cross-repo-610/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@aspect_rules_py//py/unstable:defs.bzl", "py_venv_test")
2+
load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements")
3+
4+
py_venv_test(
5+
name = "test",
6+
srcs = [
7+
"test.py",
8+
],
9+
imports = [
10+
".",
11+
],
12+
main = "test.py",
13+
deps = [
14+
"@pip//cowsay",
15+
"@subrepo_a//:foo",
16+
],
17+
)
18+
19+
compile_pip_requirements(
20+
name = "requirements",
21+
extra_args = ["--allow-unsafe"],
22+
requirements_in = "requirements.in",
23+
requirements_txt = "requirements.txt",
24+
)

e2e/cross-repo-610/MODULE.bazel

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"Bazel dependencies"
2+
3+
bazel_dep(name = "aspect_rules_py", version = "0.0.0", dev_dependency = True)
4+
local_path_override(
5+
module_name = "aspect_rules_py",
6+
path = "../..",
7+
)
8+
9+
# Because we use a prerelease of rules_py, we must compile the rust tools from source.
10+
bazel_dep(name = "rules_rust", version = "0.53.0")
11+
12+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
13+
rust.toolchain(
14+
edition = "2021",
15+
versions = ["1.81.0"],
16+
)
17+
use_repo(rust, "rust_toolchains")
18+
19+
register_toolchains("@rust_toolchains//:all")
20+
21+
bazel_dep(name = "rules_python", version = "0.29.0", dev_dependency = True)
22+
23+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
24+
python.toolchain(
25+
configure_coverage_tool = True,
26+
python_version = "3.11.6",
27+
)
28+
29+
# TODO: Swap in our pip
30+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
31+
pip.parse(
32+
hub_name = "pip",
33+
python_version = "3.11.6",
34+
requirements_lock = "//:requirements.txt",
35+
)
36+
use_repo(pip, "pip")
37+
38+
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
39+
40+
local_repository(
41+
name = "subrepo_a",
42+
path = "./subrepo_a",
43+
)
44+
45+
local_repository(
46+
name = "subrepo_b",
47+
path = "./subrepo_b",
48+
)

e2e/cross-repo-610/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cowsay
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# bazel run //:requirements.update
6+
#
7+
cowsay==6.1 \
8+
--hash=sha256:274b1e6fc1b966d53976333eb90ac94cb07a450a700b455af9fbdf882244b30a
9+
# via -r requirements.in
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("@aspect_rules_py//py:defs.bzl", "py_library")
2+
3+
py_library(
4+
name = "foo",
5+
srcs = [
6+
"foo.py",
7+
],
8+
imports = ["."],
9+
visibility = ["//visibility:public"],
10+
deps = [
11+
"@subrepo_b//:bar",
12+
],
13+
)
File renamed without changes.
File renamed without changes.

py/tests/rpy610/subrepo/BUILD.bazel renamed to e2e/cross-repo-610/subrepo_b/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
load("@aspect_rules_py//py:defs.bzl", "py_library")
22

33
py_library(
4-
name = "foo",
4+
name = "bar",
55
srcs = [
6-
"foo.py",
6+
"bar.py",
77
],
88
imports = ["."],
99
visibility = ["//visibility:public"],

0 commit comments

Comments
 (0)