Skip to content

Commit fb08327

Browse files
authored
Fix last_green build after disable_autoloads flip (bazel-contrib#1738)
* Fix last_green build after disable_autoloads flip Explicitly loads all symbols affected by `--incompatible_disable_autoloads_in_main_repo` to fix `last_green` Bazel builds. Adds `rules_shell` as a dev dependency and updates files to fix `test_bzlmod_macros.sh` and `test_dependency_versions.sh`. As a result of using Buildifier to add the missing `load` statements, Buildifier reordered the `load` statements as well. Fixes the following breakage when using the `last_green` build from bazelbuild/bazel@f08d561 (and other breakages blocked by this one): ```sh $ bazel run //tools:lint_check ERROR: scala/private/rules/scala_test.bzl:130:21: name 'JavaInfo' is not defined ERROR: .../external/+dev_deps+com_github_bazelbuild_buildtools/buildifier/BUILD.bazel:3:10: While resolving toolchains for target @@+dev_deps+com_github_bazelbuild_buildtools//buildifier:buildifier (b5bbebe): invalid registered toolchain '//test/proto:scalapb_toolchain': error loading package 'test/proto': at /Users/mbland/src/bazel-contrib/rules_scala/scala/scala.bzl:35:5: compilation of module 'scala/private/rules/scala_test.bzl' failed ERROR: Analysis of target '//tools:lint_check' failed; build aborted: Analysis failed ``` Fixed using Buildifier 8.2.0 by first running the following to get the list of appropriate warnings: ```txt buildifier --lint=warn -r . 2>&1 | grep -- native- | awk '{print $2}' | sort | uniq ``` then running: ```txt buildifier --lint=fix \ --warnings=native-java-common,native-java-info,native-sh-test,native-sh-binary \ -r . ``` I also ran it separately on the changed files in `deps/test` and `scala/private/macros/test`, since Buildifier didn't automatically find them. --- bazelbuild/bazel@d87eaf5 from 2025-05-08 at 8:03am EDT flipped `--incompatible_disable_autoloads_in_main_repo` to `true` to prepare for Bazel 9. I did confirm that setting `--noincompatible_disable_autoloads_in_main_repo` resolved the breakage before using Buildifier to add the necessary `load` statements. Pull request bazel-contrib#1735 was the last to pass the `last_green` CI build using bazelbuild/bazel@94e0b44 from 2025-05-08 at 7:39am EDT. This was two commits before the commit that flipped `--incompatible_disable_autoloads_in_main_repo`: - https://buildkite.com/bazel/rules-scala-scala/builds/5596#0196afc2-4af3-4202-8232-d5f5fe113349 Pull request bazel-contrib#1736 failed the `last_green` CI build using bazelbuild/bazel@cac54c4 from 2025-05-09 at 6:14am EDT. That job ran on 2025-05-09 at 6:47am EDT. The `last_green` configuration in `.bazelci/presubmit.yml` emits a warning if the build fails. This warning was present on the build page, but we've overlooked it until now: - https://buildkite.com/bazel/rules-scala-scala/builds/5598#0196b4a8-e593-431a-ab4c-8d8471d9b08b Part of this change copies more files from `test/jmh` into the `test_dependency_versions.sh` test directory. It also replicates targets from `//test/jmh` in `deps/test/BUILD.bazel.test` to replace the previous dependency on `@rules_scala//test/jmh:add_numbers`. This is because `//test/jmh` now has a `load` dependency on `@rules_shell`, which is a `dev_dependency` of `@rules_scala`. Since `@rules_shell` isn't visible to `@rules_scala` when it isn't the root module, this broke the build within `test_dependency_versions.sh`. * Bump Buildkite to resolve transient error The following build experienced this seemingly transient error in `./test_coverage on macOS` (all other jobs in the same build passed): - https://buildkite.com/bazel/rules-scala-scala/builds/5608#0196dfd9-3da9-4fbd-b284-e63e849f9d0a/89-128 ```txt WARNING: Download from https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-osx-x86_64.zip failed: class java.io.IOException GET returned 500 Internal Server Error ```
1 parent 9f9883e commit fb08327

File tree

88 files changed

+225
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+225
-109
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,4 @@ use_repo(
302302
)
303303

304304
bazel_dep(name = "rules_python", version = "1.4.0", dev_dependency = True)
305+
bazel_dep(name = "rules_shell", version = "0.4.1", dev_dependency = True)

WORKSPACE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,20 @@ load("//scala/private/extensions:dev_deps.bzl", "dev_deps_repositories")
144144
dev_deps_repositories()
145145

146146
register_toolchains("//test/toolchains:java21_toolchain_definition")
147+
148+
http_archive(
149+
name = "rules_shell",
150+
sha256 = "bc61ef94facc78e20a645726f64756e5e285a045037c7a61f65af2941f4c25e1",
151+
strip_prefix = "rules_shell-0.4.1",
152+
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz",
153+
)
154+
155+
load(
156+
"@rules_shell//shell:repositories.bzl",
157+
"rules_shell_dependencies",
158+
"rules_shell_toolchains",
159+
)
160+
161+
rules_shell_dependencies()
162+
163+
rules_shell_toolchains()

deps/test/BUILD.bazel.test

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ load(
88
"scalafmt_scala_test",
99
"scrooge_transitive_outputs_test",
1010
)
11+
load("@rules_java//java:defs.bzl", "java_library")
1112
load("@rules_proto//proto:defs.bzl", "proto_library")
1213
load("@rules_scala//jmh:jmh.bzl", "scala_benchmark_jmh")
1314
load("@rules_scala//scala/scalafmt:phase_scalafmt_ext.bzl", "ext_scalafmt")
@@ -89,11 +90,37 @@ default_outputs_test(
8990
)
9091

9192
# From: `test/jmh/BUILD`
93+
java_library(
94+
name = "java_type",
95+
srcs = ["JavaType.java"],
96+
visibility = ["//visibility:public"],
97+
)
98+
99+
scala_library(
100+
name = "scala_type",
101+
srcs = ["ScalaType.scala"],
102+
visibility = ["//visibility:public"],
103+
)
104+
105+
scala_library(
106+
name = "add_numbers",
107+
srcs = ["AddNumbers.scala"],
108+
visibility = ["//visibility:public"],
109+
exports = [
110+
":java_type",
111+
":scala_type",
112+
],
113+
deps = [
114+
":java_type",
115+
":scala_type",
116+
],
117+
)
118+
92119
scala_benchmark_jmh(
93120
name = "test_benchmark",
94121
srcs = ["TestBenchmark.scala"],
95122
data = ["data.txt"],
96-
deps = ["@rules_scala//test/jmh:add_numbers"],
123+
deps = [":add_numbers"],
97124
)
98125

99126
# From: `test/src/main/scala/scalarules/test/twitter_scrooge/BUILD`

deps/test/defs.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
21
load("@bazel_skylib//lib:collections.bzl", "collections")
2+
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
3+
load("@rules_java//java/common:java_info.bzl", "JavaInfo")
34
load("@rules_scala//scala:advanced_usage/scala.bzl", "make_scala_test")
45
load("@rules_scala//scala/scalafmt:phase_scalafmt_ext.bzl", "ext_scalafmt")
56

examples/semanticdb/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")
21
load("@rules_scala//scala:scala.bzl", "scala_binary", "scala_library")
2+
load("@rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")
33

44
scala_toolchain(
55
name = "semanticdb_toolchain_impl",

jmh/jmh.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java/common:java_common.bzl", "java_common")
2+
load("@rules_java//java/common:java_info.bzl", "JavaInfo")
13
load("//scala/private:rules/scala_binary.bzl", "scala_binary")
24
load("//scala/private:rules/scala_library.bzl", "scala_library")
35

jmh/toolchain/toolchain.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
load("//scala/private/toolchain_deps:toolchain_deps.bzl", "expose_toolchain_deps")
1+
load("@rules_scala_config//:config.bzl", "SCALA_VERSION")
22
load("//scala:providers.bzl", "declare_deps_provider", _DepsInfo = "DepsInfo")
33
load(
44
"//scala:scala_cross_version.bzl",
55
_versioned_repositories = "repositories",
66
)
7-
load("@rules_scala_config//:config.bzl", "SCALA_VERSION")
7+
load("//scala/private/toolchain_deps:toolchain_deps.bzl", "expose_toolchain_deps")
88

99
DEP_PROVIDERS = [
1010
"jmh_classpath",

manual_test/scala_test_jacocorunner/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("//scala:scala_toolchain.bzl", "scala_toolchain")
21
load("//scala:scala.bzl", "scala_test")
2+
load("//scala:scala_toolchain.bzl", "scala_toolchain")
33

44
scala_toolchain(
55
name = "passing_toolchain_impl",

manual_test/scala_test_jvm_flags/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("//scala:scala_toolchain.bzl", "scala_toolchain")
21
load("//scala:scala.bzl", "scala_test")
2+
load("//scala:scala_toolchain.bzl", "scala_toolchain")
33

44
scala_toolchain(
55
name = "failing_toolchain_impl",

manual_test/scalac_jvm_opts/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@rules_proto//proto:defs.bzl", "proto_library")
2-
load("//scala:scala_toolchain.bzl", "scala_toolchain")
32
load("//scala:scala.bzl", "scala_library")
3+
load("//scala:scala_toolchain.bzl", "scala_toolchain")
44
load("//scala_proto:scala_proto.bzl", "scala_proto_library")
55

66
scala_toolchain(

0 commit comments

Comments
 (0)