Skip to content

Commit f92ad71

Browse files
authored
chore: make gazelle bcr tests compatible with bcr presubmit environment (#3365)
BCR recently changed how it extracts archives in its presubmits: instead of extracting the whole archive, only the specified portion (`gazelle/` in this case) is extracted. This broke the gazelle tests because they reference files above the gazelle directory. To fix, move the module it runs as a test under the gazelle directory. Because the test module also refers to rules_python, which is above the gazelle directory, the bcr presubmit has disable that override using `--override_module`. This means, going forward, the gazelle module, when bcr tests it, will use the version in the MODULE file (rather than the vendored copy). Fixes #3364
1 parent e487b6d commit f92ad71

File tree

30 files changed

+47
-23
lines changed

30 files changed

+47
-23
lines changed

.bazelci/presubmit.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,41 +329,41 @@ tasks:
329329
<<: *minimum_supported_version
330330
<<: *reusable_build_test_all
331331
<<: *coverage_targets_example_bzlmod_build_file_generation
332-
name: "examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
333-
working_directory: examples/bzlmod_build_file_generation
332+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
333+
working_directory: gazelle/examples/bzlmod_build_file_generation
334334
platform: ubuntu2204
335335
bazel: 7.x
336336
integration_test_bzlmod_generation_build_files_ubuntu:
337337
<<: *reusable_build_test_all
338338
<<: *coverage_targets_example_bzlmod_build_file_generation
339-
name: "examples/bzlmod_build_file_generation: Ubuntu"
340-
working_directory: examples/bzlmod_build_file_generation
339+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu"
340+
working_directory: gazelle/examples/bzlmod_build_file_generation
341341
platform: ubuntu2204
342342
integration_test_bzlmod_generation_build_files_ubuntu_run:
343343
<<: *reusable_build_test_all
344-
name: "examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
345-
working_directory: examples/bzlmod_build_file_generation
344+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
345+
working_directory: gazelle/examples/bzlmod_build_file_generation
346346
platform: ubuntu2204
347347
shell_commands:
348348
- "bazel run //:gazelle_python_manifest.update"
349349
- "bazel run //:gazelle -- update"
350350
integration_test_bzlmod_build_file_generation_debian:
351351
<<: *reusable_build_test_all
352352
<<: *coverage_targets_example_bzlmod_build_file_generation
353-
name: "examples/bzlmod_build_file_generation: Debian"
354-
working_directory: examples/bzlmod_build_file_generation
353+
name: "gazelle/examples/bzlmod_build_file_generation: Debian"
354+
working_directory: gazelle/examples/bzlmod_build_file_generation
355355
platform: debian11
356356
integration_test_bzlmod_build_file_generation_macos:
357357
<<: *reusable_build_test_all
358358
<<: *coverage_targets_example_bzlmod_build_file_generation
359-
name: "examples/bzlmod_build_file_generation: MacOS"
360-
working_directory: examples/bzlmod_build_file_generation
359+
name: "gazelle/examples/bzlmod_build_file_generation: MacOS"
360+
working_directory: gazelle/examples/bzlmod_build_file_generation
361361
platform: macos
362362
integration_test_bzlmod_build_file_generation_windows:
363363
<<: *reusable_build_test_all
364364
# coverage is not supported on Windows
365-
name: "examples/bzlmod_build_file_generation: Windows"
366-
working_directory: examples/bzlmod_build_file_generation
365+
name: "gazelle/examples/bzlmod_build_file_generation: Windows"
366+
working_directory: gazelle/examples/bzlmod_build_file_generation
367367
platform: windows
368368

369369
integration_test_multi_python_versions_ubuntu_workspace:

.bazelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ examples/pip_parse_vendored/bazel-pip_parse_vendored
2626
examples/pip_repository_annotations/bazel-pip_repository_annotations
2727
examples/py_proto_library/bazel-py_proto_library
2828
gazelle/bazel-gazelle
29+
gazelle/examples/bzlmod_build_file_generation/bazel-bin
30+
gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
31+
gazelle/examples/bzlmod_build_file_generation/bazel-out
32+
gazelle/examples/bzlmod_build_file_generation/bazel-testlog
2933
tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
3034
tests/integration/ignore_root_user_error/bazel-ignore_root_user_error
3135
tests/integration/local_toolchains/bazel-local_toolchains

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ query --deleted_packages=examples/build_file_generation,examples/build_file_gene
99

1010
test --test_output=errors
1111

12+
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation
13+
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles
14+
1215
# Do NOT implicitly create empty __init__.py files in the runfiles tree.
1316
# By default, these are created in every directory containing Python source code
1417
# or shared libraries, and every parent directory of those directories,

.bcr/gazelle/presubmit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
bcr_test_module:
16-
module_path: "../examples/bzlmod_build_file_generation"
16+
module_path: "examples/bzlmod_build_file_generation"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
1919
# last_rc is to get latest 8.x release. Replace with 8.x when available.
@@ -23,6 +23,8 @@ bcr_test_module:
2323
name: "Run test module"
2424
platform: ${{ platform }}
2525
bazel: ${{ bazel }}
26+
shell_commands:
27+
- "echo 'common --override_module=rules_python=' >> .bazelrc"
2628
build_targets:
2729
- "//..."
2830
- ":modules_map"

examples/bzlmod_build_file_generation/other_module/MODULE.bazel

Lines changed: 0 additions & 5 deletions
This file was deleted.

gazelle/.bazelignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bazel-bin
2+
bazel-gazelle
3+
bazel-out
4+
bazel-testlogs
5+
examples/bzlmod_build_file_generation/bazel-bin
6+
examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
7+
examples/bzlmod_build_file_generation/bazel-out
8+
examples/bzlmod_build_file_generation/bazel-testlog

gazelle/.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
common --deleted_packages=examples/bzlmod_build_file_generation
2+
common --deleted_packages=examples/bzlmod_build_file_generation/runfiles
3+
14
test --test_output=errors
25

36
# Do NOT implicitly create empty __init__.py files in the runfiles tree.

0 commit comments

Comments
 (0)