Updated CI structure to increase coverage (#865)
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 025c716..0ea62b5 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -1,116 +1,84 @@
---
+aspects_flags: &aspects_flags
+ - "--config=rustfmt"
+ - "--config=clippy"
default_linux_targets: &default_linux_targets
- - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- - "..."
- - "@examples//..."
+ - "//..."
# TODO: Switch manual tag to platform constraint after bazel 4.0.
- "//test/versioned_dylib:versioned_dylib_test"
- # Bindgen currently only has a working toolchain for 18.04
- - "-@examples//ffi/rust_calling_c/simple/..."
+default_macos_targets: &default_macos_targets
+ - "//..."
+default_windows_targets: &default_windows_targets
+ - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
+ - "//..."
+ - "-//bindgen/..."
+ - "-//test/test_env/..."
+ - "-//test/proto/..."
+ - "-//tools/rust_analyzer/..."
+ - "-//test/rustfmt/..."
+ # rust_doc_test targets are currently broken on windows
+ # see: https://github.com/bazelbuild/rules_rust/issues/887
+ - "-//test/chained_direct_deps:mod3_doc_test"
tasks:
- ubuntu1804:
- build_targets: *default_linux_targets
- test_targets:
- - "..."
- - "@examples//..."
- # TODO: Switch manual tag to platform constraint after bazel 4.0.
- - "//test/versioned_dylib:versioned_dylib_test"
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
ubuntu2004:
- name: "Minimum Supported Version"
- bazel: "3.5.0"
build_targets: *default_linux_targets
test_targets: *default_linux_targets
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
- macos:
- osx_targets: &osx_targets
- - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- - "..."
- - "@examples//..."
- # This test requires --incompatible_macos_set_install_name and Bazel 4.2.0+
- - "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- build_targets: *osx_targets
- test_targets: *osx_targets
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
rbe_ubuntu1604:
+ build_targets:
+ - "//..."
test_targets:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- - "..."
+ - "//..."
- "//test/..."
- - "@examples//..."
- "-//test/conflicting_deps:conflicting_deps_test"
# rust_doc_test is likely not fully sandboxed
- "-//test/chained_direct_deps:mod3_doc_test"
- - "-@examples//fibonacci:fibonacci_doc_test"
- - "-@examples//hello_lib:hello_lib_doc_test"
- - "-@examples//ffi/rust_calling_c/simple/..."
- # See https://github.com/bazelbuild/bazel/issues/9987
- - "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
+ macos:
+ build_targets: *default_macos_targets
+ test_targets: *default_macos_targets
+ build_flags: *aspects_flags
windows:
build_flags:
- "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
- "--config=rustfmt"
- "--config=clippy"
- windows_targets: &windows_targets
+ build_targets: *default_windows_targets
+ test_targets: *default_windows_targets
+ ubuntu2004_with_aspects:
+ name: With Aspects
+ platform: ubuntu2004
+ build_targets: *default_linux_targets
+ test_targets: *default_linux_targets
+ build_flags: *aspects_flags
+ rbe_ubuntu1604_with_aspects:
+ name: With Aspects
+ platform: rbe_ubuntu1604
+ build_targets: *default_linux_targets
+ test_targets:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- - "-//bindgen/..."
- - "-//test/test_env/..."
- - "-//test/proto/..."
- - "-//tools/rust_analyzer/..."
- - "-//test/rustfmt/..."
- - "@examples//..."
- - "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- - "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
- - "-@examples//ffi/rust_calling_c/simple/..."
- - "-@examples//sys/..."
- - "-@examples//proto/..."
- - "-@examples//wasm/..."
- # rust_doc_test targets are currently broken on windows
- # see: https://github.com/bazelbuild/rules_rust/issues/887
- - "-@examples//hello_lib:hello_lib_doc_test"
- - "-@examples//fibonacci:fibonacci_doc_test"
+ - "//test/..."
+ - "-//test/conflicting_deps:conflicting_deps_test"
+ # rust_doc_test is likely not fully sandboxed
- "-//test/chained_direct_deps:mod3_doc_test"
- build_targets: *windows_targets
- test_targets: *windows_targets
- examples:
- name: Examples
- platform: ubuntu1804
- working_directory: examples
- test_targets:
- - //...
+ build_flags: *aspects_flags
+ macos_with_aspects:
+ name: With Aspects
+ platform: macos
+ build_targets: *default_macos_targets
+ test_targets: *default_macos_targets
+ build_flags: *aspects_flags
+ windows_with_aspects:
+ name: With Aspects
+ platform: windows
build_flags:
+ - "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
- "--config=rustfmt"
- "--config=clippy"
- docs_linux:
- name: Docs
- platform: ubuntu1804
- working_directory: docs
- build_targets:
- - //...
- run_targets:
- - "//:test_docs"
- clippy_failure:
- name: Negative Clippy Tests
- platform: ubuntu1804
- run_targets:
- - "//test/clippy:clippy_failure_test"
- rustfmt_failure:
- name: Negative Rustfmt Tests
- platform: ubuntu2004
- run_targets:
- - "//test/rustfmt:test_runner"
+ build_targets: *default_windows_targets
+ test_targets: *default_windows_targets
ubuntu2004_clang:
- name: Ubuntu 20.04 with Clang
+ name: With Clang
platform: ubuntu2004
build_flags:
- "--config=rustfmt"
@@ -120,6 +88,99 @@
# - "--linkopt=-fuse-ld=lld"
build_targets: *default_linux_targets
test_targets: *default_linux_targets
+ ubuntu1804:
+ name: "Min Bazel Version"
+ bazel: "3.5.0"
+ platform: ubuntu1804
+ build_targets: *default_linux_targets
+ test_targets: *default_linux_targets
+ ubuntu1804_with_aspects:
+ name: "Min Bazel Version With Aspects"
+ bazel: "3.5.0"
+ platform: ubuntu1804
+ build_targets: *default_linux_targets
+ test_targets: *default_linux_targets
+ build_flags: *aspects_flags
+ linux_docs:
+ name: Docs
+ platform: ubuntu2004
+ working_directory: docs
+ build_targets:
+ - //...
+ run_targets:
+ - "//:test_docs"
+ clippy_failure:
+ name: Negative Clippy Tests
+ platform: ubuntu2004
+ run_targets:
+ - "//test/clippy:clippy_failure_test"
+ rustfmt_failure:
+ name: Negative Rustfmt Tests
+ platform: ubuntu2004
+ run_targets:
+ - "//test/rustfmt:test_runner"
+ ubuntu2004_examples:
+ name: Examples
+ platform: ubuntu2004
+ working_directory: examples
+ build_targets:
+ - "//..."
+ test_targets:
+ - "//..."
+ build_flags: *aspects_flags
+ rbe_ubuntu1604_examples:
+ name: Examples
+ platform: rbe_ubuntu1604
+ working_directory: examples
+ rbe_examples_targets: &rbe_examples_targets
+ - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
+ - "//..."
+ # TODO: This requires an updated `rules_foreign_cc`
+ - "-//sys/..."
+ # rust_doc_test is likely not fully sandboxed
+ - "-//fibonacci:fibonacci_doc_test"
+ - "-//hello_lib:hello_lib_doc_test"
+ - "-//ffi/rust_calling_c/simple/..."
+ # See https://github.com/bazelbuild/bazel/issues/9987
+ - "-//ffi/rust_calling_c:matrix_dylib_test"
+ build_targets: *rbe_examples_targets
+ test_targets: *rbe_examples_targets
+ build_flags: *aspects_flags
+ macos_examples:
+ name: Examples
+ platform: macos
+ working_directory: examples
+ build_targets:
+ - "//..."
+ test_targets:
+ - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
+ - "//..."
+ # This test requires --incompatible_macos_set_install_name and Bazel 4.2.0+
+ - "-//ffi/rust_calling_c:matrix_dylib_test"
+ build_flags: *aspects_flags
+ windows_examples:
+ name: Examples
+ platform: windows
+ working_directory: examples
+ build_flags:
+ - "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
+ - "--config=rustfmt"
+ - "--config=clippy"
+ windows_targets: &windows_targets
+ - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
+ - "//..."
+ - "-//ffi/rust_calling_c:matrix_dylib_test"
+ - "-//ffi/rust_calling_c:matrix_dynamically_linked"
+ - "-//ffi/rust_calling_c/simple/..."
+ - "-//sys/..."
+ - "-//proto/..."
+ - "-//wasm/..."
+ # rust_doc_test targets are currently broken on windows
+ # see: https://github.com/bazelbuild/rules_rust/issues/887
+ - "-//hello_lib:hello_lib_doc_test"
+ - "-//fibonacci:fibonacci_doc_test"
+ build_targets: *windows_targets
+ test_targets: *windows_targets
crate_universe_examples_ubuntu2004:
name: Crate Universe Examples
platform: ubuntu2004
@@ -130,9 +191,7 @@
- "//..."
test_targets:
- "//..."
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
+ build_flags: *aspects_flags
crate_universe_rbe_ubuntu1604:
name: Crate Universe Examples
platform: rbe_ubuntu1604
@@ -143,9 +202,7 @@
- "//..."
test_targets:
- "//..."
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
+ build_flags: *aspects_flags
crate_universe_examples_macos:
name: Crate Universe Examples
platform: macos
@@ -156,9 +213,7 @@
- "//..."
test_targets:
- "//..."
- build_flags:
- - "--config=rustfmt"
- - "--config=clippy"
+ build_flags: *aspects_flags
crate_universe_examples_windows:
name: Crate Universe Examples
platform: windows
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index b5b1276..b6599a6 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -52,41 +52,3 @@
# Use this as is if you are using the rbe_ubuntu16_04 container,
# otherwise refer to RBE docs.
rbe_autoconfig(name = "buildkite_config")
-
-# Load all dependencies for examples
-
-local_repository(
- name = "examples",
- path = "examples",
-)
-
-load("@examples//:examples_repositories.bzl", examples_repositories = "repositories")
-
-examples_repositories()
-
-load("@examples//:examples_deps.bzl", examples_deps = "deps")
-
-examples_deps()
-
-load("@examples//:examples_transitive_deps.bzl", examples_transitive_deps = "transitive_deps")
-
-examples_transitive_deps(is_top_level = True)
-
-# Load all dependencies for docs
-
-local_repository(
- name = "docs",
- path = "docs",
-)
-
-load("@docs//:docs_repositories.bzl", docs_repositories = "repositories")
-
-docs_repositories()
-
-load("@docs//:docs_deps.bzl", docs_deps = "deps")
-
-docs_deps()
-
-load("@docs//:docs_transitive_deps.bzl", docs_transitive_deps = "transitive_deps")
-
-docs_transitive_deps()
diff --git a/examples/WORKSPACE.bazel b/examples/WORKSPACE.bazel
index 7a647f7..fec26c9 100644
--- a/examples/WORKSPACE.bazel
+++ b/examples/WORKSPACE.bazel
@@ -11,3 +11,22 @@
load(":examples_transitive_deps.bzl", "transitive_deps")
transitive_deps()
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "bazel_toolchains",
+ sha256 = "179ec02f809e86abf56356d8898c8bd74069f1bd7c56044050c2cd3d79d0e024",
+ strip_prefix = "bazel-toolchains-4.1.0",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
+ "https://github.com/bazelbuild/bazel-toolchains/releases/download/4.1.0/bazel-toolchains-4.1.0.tar.gz",
+ ],
+)
+
+load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
+
+# Creates a default toolchain config for RBE.
+# Use this as is if you are using the rbe_ubuntu16_04 container,
+# otherwise refer to RBE docs.
+rbe_autoconfig(name = "buildkite_config")
diff --git a/examples/per_platform_printer/BUILD.bazel b/examples/per_platform_printer/BUILD.bazel
index 01cff4c..b0d0d2d 100644
--- a/examples/per_platform_printer/BUILD.bazel
+++ b/examples/per_platform_printer/BUILD.bazel
@@ -31,9 +31,16 @@
":print_windows.rs",
],
}),
+ # Because each os specific file is conditionally added to the target,
+ # rustfmt does not have all sources to complete formatting. To avoid
+ # this failure, rustfmt is not run on this target
+ tags = ["norustfmt"],
)
rust_test(
name = "printer_test",
crate = ":printer",
+ # The same rational used for `printer` applies here. Do not run rustfmt
+ # since not all sources are available.
+ tags = ["norustfmt"],
)
diff --git a/proto/BUILD.bazel b/proto/BUILD.bazel
index 4211ee7..2796a9dc 100644
--- a/proto/BUILD.bazel
+++ b/proto/BUILD.bazel
@@ -25,7 +25,7 @@
toolchain(
name = "default-proto-toolchain",
toolchain = ":default-proto-toolchain-impl",
- toolchain_type = "//proto:toolchain",
+ toolchain_type = "@rules_rust//proto:toolchain",
)
rust_proto_toolchain(name = "default-proto-toolchain-impl")
diff --git a/test/inline_test_with_deps/test_with_srcs/BUILD.bazel b/test/inline_test_with_deps/test_with_srcs/BUILD.bazel
index 3a3c6ab..912fa59 100644
--- a/test/inline_test_with_deps/test_with_srcs/BUILD.bazel
+++ b/test/inline_test_with_deps/test_with_srcs/BUILD.bazel
@@ -10,6 +10,10 @@
name = "inline",
srcs = ["src/lib.rs"],
edition = "2018",
+ # Not all source files are included in this this target (`extra.rs`)
+ # and as a result, rustfmt complains about a missing module. Do not
+ # run rustfmt to avoid this issue.
+ tags = ["norustfmt"],
)
rust_test(