From f9601927b2a63f3621a4a1d17479a406bdc1aba7 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 15 Apr 2024 16:48:15 +0100 Subject: [PATCH] Test BCR example in minimum bazel (#2613) --- .bazelci/presubmit.yml | 18 ++++++++++++++++-- .bcr/presubmit.yml | 6 ++++++ rust/extensions.bzl | 14 +++++++++----- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 281f8ea80b..ccea830fe6 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,4 +1,5 @@ --- +minimum_bazel_version: &minimum_bazel_version "6.3.0" aspects_flags: &aspects_flags - "--config=rustfmt" - "--config=clippy" @@ -232,7 +233,7 @@ tasks: ubuntu1804: name: "Min Bazel Version" # If updating the minimum bazel version, please also update /docs/index.md - bazel: "6.3.0" + bazel: *minimum_bazel_version platform: ubuntu1804 build_targets: *default_linux_targets test_targets: *default_linux_targets @@ -240,7 +241,7 @@ tasks: post_shell_commands: *coverage_validation_post_shell_commands ubuntu1804_with_aspects: name: "Min Bazel Version With Aspects" - bazel: "6.3.0" + bazel: *minimum_bazel_version platform: ubuntu1804 build_targets: *default_linux_targets test_targets: *default_linux_targets @@ -668,6 +669,19 @@ tasks: - "@rules_rust//tools/rust_analyzer:gen_rust_project" test_targets: - "//..." + ubuntu2004_bzlmod_minimum_bazel_bcr: + name: bzlmod BCR presubmit minimal bazel + bazel: *minimum_bazel_version + platform: ubuntu2004 + working_directory: examples/bzlmod/hello_world + test_flags: *bzlmod_flags + shell_commands: + - "rm MODULE.bazel.lock" + run_targets: + - "//third-party:vendor" + - "@rules_rust//tools/rust_analyzer:gen_rust_project" + test_targets: + - "//..." macos_bzlmod_bcr: name: bzlmod BCR presubmit platform: macos diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 7030f6ee72..81b8a77712 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -9,6 +9,9 @@ bcr_test_module: name: "Run test module" platform: ${{ platform }} bazel: ${{ bazel }} + # Remove the lockfile because we generate on Bazel 7, but test on Bazel 6 which may not be able to parse a future-generated lockfile. + shell_commands: + - "rm MODULE.bazel.lock" run_targets: - "//third-party:vendor" - "@rules_rust//tools/rust_analyzer:gen_rust_project" @@ -25,6 +28,9 @@ bcr_test_module_windows: name: "Run test module" platform: windows bazel: ${{ bazel }} + # Remove the lockfile because we generate on Bazel 7, but test on Bazel 6 which may not be able to parse a future-generated lockfile. + shell_commands: + - "rm MODULE.bazel.lock" run_targets: - "//third-party:vendor" build_targets: diff --git a/rust/extensions.bzl b/rust/extensions.bzl index cd68c59cc6..eb8ea831b5 100644 --- a/rust/extensions.bzl +++ b/rust/extensions.bzl @@ -171,16 +171,20 @@ def _rust_host_tools_impl(module_ctx): **host_tools ) + metadata_kwargs = {} if bazel_features.external_deps.extension_metadata_has_reproducible: - return module_ctx.extension_metadata(reproducible = True) - else: - return None + metadata_kwargs["reproducible"] = True + return module_ctx.extension_metadata(**metadata_kwargs) + +_conditional_rust_host_tools_args = { + "arch_dependent": True, + "os_dependent": True, +} if bazel_features.external_deps.module_extension_has_os_arch_dependent else {} rust_host_tools = module_extension( implementation = _rust_host_tools_impl, tag_classes = { "host_tools": _RUST_HOST_TOOLS_TAG, }, - os_dependent = True, - arch_dependent = True, + **_conditional_rust_host_tools_args )