diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 132f33ee7a..b9cf3b9fda 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -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" @@ -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 - "--" - "//..." @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docs/src/index.md b/docs/src/index.md index 84392b5a97..3e47eeb243 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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. diff --git a/examples/crate_universe_local_path/.bazelrc b/examples/crate_universe_local_path/.bazelrc index 15ef707cb2..8c7e2612ee 100644 --- a/examples/crate_universe_local_path/.bazelrc +++ b/examples/crate_universe_local_path/.bazelrc @@ -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 @@ -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 ############################################################################### @@ -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 ############################################################################### diff --git a/examples/crate_universe_local_path/MODULE.bazel b/examples/crate_universe_local_path/MODULE.bazel index 2aaa401a5e..5453d6d3f9 100644 --- a/examples/crate_universe_local_path/MODULE.bazel +++ b/examples/crate_universe_local_path/MODULE.bazel @@ -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") diff --git a/examples/crate_universe_local_path/WORKSPACE.bazel b/examples/crate_universe_local_path/WORKSPACE.bazel index d03b8bcfd2..2dd72ee98c 100644 --- a/examples/crate_universe_local_path/WORKSPACE.bazel +++ b/examples/crate_universe_local_path/WORKSPACE.bazel @@ -18,7 +18,7 @@ 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`. @@ -26,6 +26,6 @@ crates_repository( 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() diff --git a/examples/crate_universe_local_path/crates_from_workspace/BUILD.bazel b/examples/crate_universe_local_path/crates_from_workspace/BUILD.bazel index bdcf43e1df..38915bf652 100644 --- a/examples/crate_universe_local_path/crates_from_workspace/BUILD.bazel +++ b/examples/crate_universe_local_path/crates_from_workspace/BUILD.bazel @@ -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(), )