Skip to content

Commit

Permalink
Fix presubmit for BCR + minimum bazel
Browse files Browse the repository at this point in the history
* Remove lockfile before running, it may be incompatible
* Gate version-requiring attrs
  • Loading branch information
illicitonion committed Apr 15, 2024
1 parent c227160 commit 0bcd465
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ tasks:
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"
Expand Down
6 changes: 6 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down
14 changes: 9 additions & 5 deletions rust/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 0bcd465

Please sign in to comment.