Skip to content

Commit

Permalink
chore: add //bzlmod:hello_world_test and use it as BCR presubmit (#…
Browse files Browse the repository at this point in the history
…2347)

- Create `bzlmod/hello_world` package based upon
`examples/bzlmod/hello_world`.
- Add `rules_bazel_integration_test` so that `//bzlmod:hello_world_test`
can be executed as a test from the parent workspace.
- Add `filegroup` targets named `all_files` to collect files for all of
the packages that are necessary to use `rules_rust`. These are an input
to the `rules_bazel_integration_test` test.
- Replace `.bcr/presubmit.yml` to test `//bzlmod:hello_world_test`.
- Update CI to test `//bzlmod:hello_world_test`.

Related to
bazelbuild/bazel-central-registry#1199 (comment).
  • Loading branch information
cgrindel authored Dec 27, 2023
1 parent c85ce76 commit 6a93592
Show file tree
Hide file tree
Showing 12 changed files with 14,951 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,18 @@ tasks:
- "//:nix_cross_compiling"
test_targets:
- "//..."
ubuntu2004_bzlmod_bcr:
name: bzlmod BCR presubmit
platform: ubuntu2004
working_directory: bzlmod/hello_world
build_targets:
- "//..."
macos_bzlmod_bcr:
name: bzlmod BCR presubmit
platform: macos
working_directory: bzlmod/hello_world
build_targets:
- "//..."

buildifier:
version: latest
Expand Down
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bzlmod
docs
examples
crate_universe/private/bootstrap
Expand Down
1 change: 0 additions & 1 deletion .bcr/presubmit.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bcr_test_module:
module_path: ""
matrix:
platform: ["macos", "ubuntu2004"]
tasks:
run_tests:
working_directory: bzlmod/hello_world
name: "Run test module"
platform: ${{ platform }}
test_targets:
- "//..."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# bazel
/bazel-*
/bzlmod/hello_world/bazel-*
/examples/bazel-*
/examples/cargo_manifest_dir/external_crate/bazel-*
/examples/crate_universe/bazel-*
Expand Down
6 changes: 6 additions & 0 deletions bzlmod/hello_world/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Required on windows
common --enable_platform_specific_config
startup --windows_enable_symlinks
build:windows --enable_runfiles

build --experimental_enable_bzlmod
27 changes: 27 additions & 0 deletions bzlmod/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")

package(default_visibility = ["//visibility:public"])

rust_binary(
name = "hello_world",
srcs = ["src/main.rs"],
)

rust_doc(
name = "hello_world_doc",
crate = ":hello_world",
)

sh_test(
name = "hello_world_test",
srcs = ["hello_world_test.sh"],
args = [
"$(rootpath :hello_world)",
],
data = [
":hello_world",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
19 changes: 19 additions & 0 deletions bzlmod/hello_world/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module(
name = "hello_world_example",
version = "0.0.0",
)

bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
)

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021")
use_repo(
rust,
"rust_toolchains",
)

register_toolchains("@rust_toolchains//:all")
Loading

0 comments on commit 6a93592

Please sign in to comment.