Skip to content

Commit

Permalink
bcr_presubmit: pass --check_direct_dependencies=off for test module i…
Browse files Browse the repository at this point in the history
…f bazel version is overridden (#2140)

Address:
bazelbuild/bazel-central-registry#3260 (comment)
  • Loading branch information
meteorcloudy authored Dec 9, 2024
1 parent a743628 commit 99bea4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions buildkite/bazel-central-registry/bcr_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def unpack_archive(archive_file, output_dir):
else:
shutil.unpack_archive(archive_file, output_dir)

def prepare_test_module_repo(module_name, module_version):
def prepare_test_module_repo(module_name, module_version, overwrite_bazel_version=None):
"""Prepare the test module repo and the presubmit yml file it should use"""
bazelci.print_collapsed_group(":information_source: Prepare test module repo")
root = pathlib.Path(bazelci.get_repositories_root())
Expand Down Expand Up @@ -271,8 +271,10 @@ def prepare_test_module_repo(module_name, module_version):
scratch_file(test_module_root, ".bazelrc", [
# .bazelrc may not end with a newline.
"",
"build --experimental_enable_bzlmod",
"build --registry=%s" % BCR_REPO_DIR.as_uri(),
"common --experimental_enable_bzlmod",
"common --registry=%s" % BCR_REPO_DIR.as_uri(),
# In case the test module sets --check_direct_dependencies=error and a different Bazel version may trigger the error.
"common --check_direct_dependencies=warning" if overwrite_bazel_version else "",
], mode="a")
bazelci.eprint("* Append Bzlmod flags to .bazelrc file:\n%s\n" % read(test_module_root.joinpath(".bazelrc")))

Expand Down Expand Up @@ -523,7 +525,7 @@ def main(argv=None):
config_file = get_presubmit_yml(args.module_name, args.module_version)
return run_test(repo_location, config_file, args.task, args.overwrite_bazel_version)
elif args.subparsers_name == "test_module_runner":
repo_location, config_file = prepare_test_module_repo(args.module_name, args.module_version)
repo_location, config_file = prepare_test_module_repo(args.module_name, args.module_version, args.overwrite_bazel_version)
return run_test(repo_location, config_file, args.task, args.overwrite_bazel_version)
else:
parser.print_help()
Expand Down

0 comments on commit 99bea4e

Please sign in to comment.