Skip to content

Commit f848f11

Browse files
authored
test: make compile_pip_requirements_test_from_external_workspace work with bzlmod (#1528)
Bazel at head enables bzlmod by default, so the tests must also be updated to be bzlmod compatible. Also makes compile_pip_requirements ignore its convenience symlinks. This allows locally running the "from external" workspace test even if the compile_pip_requirements workspace previously had convenience symlinks in it from other builds. Work towards #1520
1 parent 9b73d02 commit f848f11

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

.bazelci/presubmit.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,34 +570,34 @@ tasks:
570570
working_directory: tests/compile_pip_requirements_test_from_external_workspace
571571
platform: ubuntu2004
572572
shell_commands:
573-
# Assert that @external_repository//:requirements_test does the right thing.
574-
- "bazel test @external_repository//..."
573+
# Assert that @compile_pip_requirements//:requirements_test does the right thing.
574+
- "bazel test @compile_pip_requirements//..."
575575
integration_compile_pip_requirements_test_from_external_repo_ubuntu:
576576
name: compile_pip_requirements test from external repo on Ubuntu
577577
working_directory: tests/compile_pip_requirements_test_from_external_workspace
578578
platform: ubuntu2004
579579
shell_commands:
580-
# Assert that @external_repository//:requirements_test does the right thing.
581-
- "bazel test @external_repository//..."
580+
# Assert that @compile_pip_requirements//:requirements_test does the right thing.
581+
- "bazel test @compile_pip_requirements//..."
582582
integration_compile_pip_requirements_test_from_external_repo_debian:
583583
name: compile_pip_requirements test from external repo on Debian
584584
working_directory: tests/compile_pip_requirements_test_from_external_workspace
585585
platform: debian11
586586
shell_commands:
587-
# Assert that @external_repository//:requirements_test does the right thing.
588-
- "bazel test @external_repository//..."
587+
# Assert that @compile_pip_requirements//:requirements_test does the right thing.
588+
- "bazel test @compile_pip_requirements//..."
589589
integration_compile_pip_requirements_test_from_external_repo_macos:
590590
name: compile_pip_requirements test from external repo on macOS
591591
working_directory: tests/compile_pip_requirements_test_from_external_workspace
592592
platform: macos
593593
shell_commands:
594-
# Assert that @external_repository//:requirements_test does the right thing.
595-
- "bazel test @external_repository//..."
594+
# Assert that @compile_pip_requirements//:requirements_test does the right thing.
595+
- "bazel test @compile_pip_requirements//..."
596596
integration_compile_pip_requirements_test_from_external_repo_windows:
597597
name: compile_pip_requirements test from external repo on Windows
598598
working_directory: tests/compile_pip_requirements_test_from_external_workspace
599599
platform: windows
600600
shell_commands:
601-
# Assert that @external_repository//:requirements_test does the right thing.
602-
- "bazel test @external_repository//..."
601+
# Assert that @compile_pip_requirements//:requirements_test does the right thing.
602+
- "bazel test @compile_pip_requirements//..."
603603

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# While normally ignored by default, it must be explicitly
2+
# specified so that compile_pip_requirements_test_from_external_workspace
3+
# properly ignores it
4+
bazel-compile_pip_requirements
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module(name = "compile_pip_requirements_test_from_external_workspace")
2+
3+
bazel_dep(name = "rules_python", version = "0.0.0")
4+
local_path_override(
5+
module_name = "rules_python",
6+
path = "../..",
7+
)
8+
9+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
10+
python.toolchain(
11+
python_version = "3.9",
12+
)
13+
14+
bazel_dep(name = "compile_pip_requirements", version = "0.0.0")
15+
local_path_override(
16+
module_name = "compile_pip_requirements",
17+
path = "../compile_pip_requirements",
18+
)
19+
20+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
21+
pip.parse(
22+
hub_name = "pypi",
23+
python_version = "3.9",
24+
requirements_lock = "@compile_pip_requirements//:requirements_lock.txt",
25+
)

tests/compile_pip_requirements_test_from_external_workspace/WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ load("@python39//:defs.bzl", "interpreter")
2020
load("@rules_python//python:pip.bzl", "pip_parse")
2121

2222
local_repository(
23-
name = "external_repository",
23+
name = "compile_pip_requirements",
2424
path = "../compile_pip_requirements",
2525
)
2626

2727
pip_parse(
2828
name = "pypi",
2929
python_interpreter_target = interpreter,
30-
requirements_lock = "@external_repository//:requirements_lock.txt",
30+
requirements_lock = "@compile_pip_requirements//:requirements_lock.txt",
3131
)
3232

3333
load("@pypi//:requirements.bzl", "install_deps")

tests/compile_pip_requirements_test_from_external_workspace/WORKSPACE.bzlmod

Whitespace-only changes.

0 commit comments

Comments
 (0)