Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin non-bzlmod tests to Bazel 7 #3173

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---
minimum_bazel_version: &minimum_bazel_version "7.4.1"
no_bzlmod_bazel_version: &no_bzlmod_bazel_version "7.4.1"
no_bzlmod_shell_commands: &no_bzlmod_shell_commands
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
- echo "7.4.1" > .bazelversion
no_bzlmod_rbe_shell_commands: &no_bzlmod_rbe_shell_commands
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
- echo "7.4.1" > .bazelversion
aspects_flags: &aspects_flags
- "--config=rustfmt"
- "--config=clippy"
Expand All @@ -16,12 +25,6 @@ bzlmod_flags: &bzlmod_flags
bzlmod_plus_repo_names_flags: &bzlmod_plus_repo_names_flags
# `--lockfile_mode=error` is omitted because the repo names leak into the lock file.
- "--incompatible_use_plus_in_repo_names"
no_bzlmod_shell_commands: &no_bzlmod_shell_commands
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
no_bzlmod_rbe_shell_commands: &no_bzlmod_rbe_shell_commands
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
single_rust_channel_targets: &single_rust_channel_targets
- "--"
- "//..."
Expand Down Expand Up @@ -116,6 +119,7 @@ tasks:
ubuntu2004_no_bzlmod:
name: No Bzlmod
platform: ubuntu2004
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_shell_commands
build_targets: *default_linux_targets
test_targets: *default_linux_targets
Expand All @@ -126,12 +130,14 @@ tasks:
rbe_ubuntu2004_no_bzlmod:
name: No Bzlmod
platform: rbe_ubuntu2004
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_rbe_shell_commands
build_targets: *default_linux_targets
test_targets: *default_linux_targets
macos_no_bzlmod:
name: No Bzlmod
platform: macos_arm64
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_shell_commands
build_targets: *default_macos_targets
test_targets: *default_macos_targets
Expand All @@ -140,6 +146,7 @@ tasks:
windows_no_bzlmod:
name: No Bzlmod
platform: windows
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_shell_commands
build_targets: *default_windows_targets
test_targets: *default_windows_targets
Expand Down Expand Up @@ -475,6 +482,22 @@ tasks:
working_directory: examples/crate_universe_local_path
run_targets:
- "//:vendor_edit_test_in_tree"
crate_universe_local_path_external_no_bzlmod:
name: Crate Universe Local Path External (No Bzlmod)
platform: ubuntu2004
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_shell_commands
working_directory: examples/crate_universe_local_path
run_targets:
- "//:vendor_edit_test_out_of_tree"
crate_universe_local_path_in_tree_no_bzlmod:
name: Crate Universe Local Path In Tree (No Bzlmod)
platform: ubuntu2004
bazel: *no_bzlmod_bazel_version
shell_commands: *no_bzlmod_shell_commands
working_directory: examples/crate_universe_local_path
run_targets:
- "//:vendor_edit_test_in_tree"
# See https://github.com/bazelbuild/rules_rust/issues/2186 about re-enabling these.
# crate_universe_examples_windows:
# name: Crate Universe Examples
Expand Down
4 changes: 4 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ The oldest version of Bazel the `main` branch is tested against is `7.4.1`. Prev

We test these rules against the latest rolling releases of Bazel, and aim for compatibility with them, but prioritise stable releases over rolling releases where necessary.

### WORKSPACE support

WORKSPACE support is officially tested with Bazel 7 for as long as that is the min supported version. While it may work with later versions, compatibility with those versions is not guaranteed or actively verified.

## Supported platforms

We aim to support Linux and macOS.
Expand Down
33 changes: 33 additions & 0 deletions examples/crate_universe_local_path/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
## https://bazel.build/docs/best-practices#bazelrc-file
###############################################################################

# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
common --enable_platform_specific_config

# Enable the only currently supported report type
# https://bazel.build/reference/command-line-reference#flag--combined_report
coverage --combined_report=lcov

# Avoid fully cached builds reporting no coverage and failing CI
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
coverage --experimental_fetch_all_coverage_outputs

# Required for some of the tests
# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library
common --experimental_cc_shared_library

###############################################################################
## Unique configuration groups
###############################################################################

# Enable use of the nightly toolchains.
build:nightly --@rules_rust//rust/toolchain/channel=nightly

# Enable rustfmt for all targets in the workspace
build:rustfmt --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
build:rustfmt --output_groups=+rustfmt_checks
Expand All @@ -13,6 +35,14 @@ build:rustfmt --output_groups=+rustfmt_checks
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build:clippy --output_groups=+clippy_checks

# Enable unpretty for all targets in the workspace
build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect
build:unpretty --output_groups=+rust_unpretty

# `unpretty` requires the nightly toolchain. See tracking issue:
# https://github.com/rust-lang/rust/issues/43364
build:unpretty --config=nightly

###############################################################################
## Incompatibility flags
###############################################################################
Expand All @@ -26,6 +56,9 @@ build --nolegacy_external_runfiles
# Required for cargo_build_script support before Bazel 7
build --incompatible_merge_fixed_and_default_shell_env

# https://github.com/bazelbuild/bazel/issues/23043.
build --incompatible_autoload_externally=

###############################################################################
## Bzlmod
###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/crate_universe_local_path/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ crate = use_extension(
"crate",
)
crate.from_cargo(
name = "bzlmod_crates_from_cargo_workspace",
name = "crates_from_cargo_workspace",
cargo_lockfile = "//crates_from_workspace:Cargo.lock",
manifests = ["//crates_from_workspace:Cargo.toml"],
)
use_repo(crate, "bzlmod_crates_from_cargo_workspace")
use_repo(crate, "crates_from_cargo_workspace")
4 changes: 2 additions & 2 deletions examples/crate_universe_local_path/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ crate_universe_dependencies(bootstrap = True)
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")

crates_repository(
name = "workspace_crates_from_cargo_workspace",
name = "crates_from_cargo_workspace",
cargo_lockfile = "//crates_from_workspace:Cargo.lock",
# `generator` is not necessary in official releases.
# See load satement for `cargo_bazel_bootstrap`.
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
manifests = ["//crates_from_workspace:Cargo.toml"],
)

load("@workspace_crates_from_cargo_workspace//:defs.bzl", "crate_repositories")
load("@crates_from_cargo_workspace//:defs.bzl", "crate_repositories")

crate_repositories()
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
load("@bzlmod_crates_from_cargo_workspace//:defs.bzl", bzlmod_all_crate_deps = "all_crate_deps")
load("@crates_from_cargo_workspace//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_test")
load("@workspace_crates_from_cargo_workspace//:defs.bzl", workspace_all_crate_deps = "all_crate_deps")

rust_test(
name = "bzlmod_test",
name = "test",
srcs = ["test.rs"],
deps = bzlmod_all_crate_deps(),
)

rust_test(
name = "workspace_test",
srcs = ["test.rs"],
deps = workspace_all_crate_deps(),
deps = all_crate_deps(),
)
Loading