Skip to content

Fix last_green w/bazel_worker_api rules_java 8.15 #1756

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

Merged
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
10 changes: 0 additions & 10 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ tasks:
# Install xmllint
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with last_green Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
# Remove this job once the last_green job passes after a fix lands for
# bazelbuild/bazel#26579.
test_rules_scala_linux_9_prerelease:
name: "./test_rules_scala (Bazel 9 rolling prerelease)"
platform: ubuntu2004
bazel: 9.0.0-pre.20250710.1
shell_commands:
# Install xmllint
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- "./test_rules_scala.sh"
test_rules_scala_macos:
name: "./test_rules_scala"
platform: macos
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.9.8"
version = "3.9.9"
runner.dialect = scala213
align.openParenCallSite = false
align.openParenDefnSite = false
Expand Down
12 changes: 7 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ single_version_override(
bazel_dep(name = "rules_java", version = "7.6.0")
single_version_override(
module_name = "rules_java",
version = "8.14.0",
version = "8.15.0",
)

bazel_dep(name = "rules_proto", version = "6.0.0")
Expand All @@ -66,6 +66,8 @@ single_version_override(
version = "31.1",
)

bazel_dep(name = "bazel_worker_java", version = "0.0.6")

scala_protoc = use_extension(
"//scala/extensions:protoc.bzl",
"scala_protoc",
Expand Down Expand Up @@ -254,11 +256,11 @@ bazel_dep(
)
bazel_dep(
name = "rules_go",
version = "0.55.1",
version = "0.56.1",
dev_dependency = True,
repo_name = "io_bazel_rules_go", # for com_github_bazelbuild_buildtools
)
bazel_dep(name = "gazelle", version = "0.44.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.45.0", dev_dependency = True)

go_sdk = use_extension(
"@io_bazel_rules_go//go:extensions.bzl",
Expand All @@ -284,7 +286,7 @@ go_deps = use_extension(
# - https://go.dev/ref/mod#checksum-database
#
# go list -m golang.org/x/tools@latest
# curl https://sum.golang.org/lookup/golang.org/x/tools@v0.34.0
# curl https://sum.golang.org/lookup/golang.org/x/tools@v0.35.0
go_deps.module(
path = "golang.org/x/tools",
sum = "h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=",
Expand All @@ -302,4 +304,4 @@ use_repo(
)

bazel_dep(name = "rules_python", version = "1.5.1", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.5.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.5.1", dev_dependency = True)
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1318,36 +1318,12 @@ future compatibility.

__`rules_scala` 7.x officially drops support for Bazel 6.5.0.__ Bzlmod builds
with Bazel 6.5.0 won't work at all because [Bazel 6.5.0 doesn't support
'use_repo_rule']( https://bazel.build/versions/6.5.0/rules/lib/globals), which
'use_repo_rule'](https://bazel.build/versions/6.5.0/rules/lib/globals), which
['rules_jvm_external' >= 6.3 requires](
https://github.com/bazelbuild/rules_scala/issues/1482#issuecomment-2515496234).

At the moment, `WORKSPACE` builds mostly continue to work with Bazel 6.5.0, but
not out of the box, and may break at any time.

#### Maximum of `protobuf` v29

You _must_ use `protobuf` v29 or earlier. `rules_scala` now uses v30 by default,
which removes `py_proto_library` and other symbols that Bazel 6.5.0 requires:

```txt
ERROR: Traceback (most recent call last):
File ".../external/bazel_tools/src/main/protobuf/BUILD",
line 1, column 46, in <toplevel>
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")

Error: file '@com_google_protobuf//:protobuf.bzl'
does not contain symbol 'py_proto_library'

ERROR: .../src/java/io/bazel/rulesscala/worker/BUILD:3:13:
no such target '@bazel_tools//src/main/protobuf:worker_protocol_java_proto':
target 'worker_protocol_java_proto'
not declared in package 'src/main/protobuf'
defined by .../external/bazel_tools/src/main/protobuf/BUILD
(Tip: use `query "@bazel_tools//src/main/protobuf:*"`
to see all the targets in that package)
and referenced by '//src/java/io/bazel/rulesscala/worker:worker'
```
may break at any time.

#### Configuring the protocol compiler toolchain

Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ local_repository(

http_archive(
name = "io_bazel_rules_go",
sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a",
sha256 = "89d2050410602142c9acafd01c95baf48b65f8dd16f4771d37c89f82f5e147f2",
urls = [
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.0.zip",
"https://github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.56.1/rules_go-v0.56.1.zip",
"https://github.com/bazel-contrib/rules_go/releases/download/v0.56.1/rules_go-v0.56.1.zip",
],
)

Expand Down
2 changes: 1 addition & 1 deletion deps/latest/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "protobuf", version = "31.1")
bazel_dep(name = "rules_java", version = "8.14.0")
bazel_dep(name = "rules_java", version = "8.15.0")
bazel_dep(name = "rules_proto", version = "7.1.0")

# https://github.com/bazelbuild/bazel/pull/25681 removed
Expand Down
6 changes: 3 additions & 3 deletions dt_patches/dt_patch_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test_compiler_srcjar() {
run_in_test_repo \
test_dt_patches_user_srcjar \
bazel build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... 2>&1 |
(! grep "canonical reproducible")
(! grep "scala_compiler_source.*canonical reproducible")
}

test_compiler_srcjar_nonhermetic() {
Expand All @@ -46,7 +46,7 @@ test_compiler_srcjar_nonhermetic() {
run_in_test_repo \
test_dt_patches_user_srcjar \
bazel build "--repo_env=SCALA_VERSION=${SCALA_VERSION}" //... 2>&1 |
grep 'canonical reproducible'
grep 'scala_compiler_source.*canonical reproducible'
}

test_compiler_srcjar_error() {
Expand Down Expand Up @@ -129,7 +129,7 @@ $runner test_compiler_srcjar_error 2.12.13
# that we grep for will only be outputted the first time (on Bazel >= 6).
# So we clean the repo first to ensure consistency.

run_in_test_repo 'test_dt_patches_user_srcjar' bazel clean --expunge
run_in_test_repo 'test_dt_patches_user_srcjar' bazel clean --expunge_async

$runner test_compiler_srcjar 2.12.14
$runner test_compiler_srcjar 2.12.15
Expand Down
3 changes: 3 additions & 0 deletions scala/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//scala/private:macros/workspace_compat.bzl", "workspace_compat")

def rules_scala_dependencies():
"""Instantiates repos needed by rules provided by `rules_scala`."""
Expand Down Expand Up @@ -64,3 +65,5 @@ def rules_scala_dependencies():
strip_prefix = "rules_proto-6.0.2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
)

workspace_compat()
16 changes: 10 additions & 6 deletions scala/latest_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//scala/private:macros/workspace_compat.bzl", "workspace_compat")

def rules_scala_dependencies():
"""Instantiates repos needed by rules provided by `rules_scala`."""
Expand Down Expand Up @@ -29,9 +30,9 @@ def rules_scala_dependencies():
http_archive,
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/8.14.0/rules_java-8.14.0.tar.gz",
"https://github.com/bazelbuild/rules_java/releases/download/8.15.0/rules_java-8.15.0.tar.gz",
],
sha256 = "bbe7d94360cc9ed4607ec5fd94995fd1ec41e84257020b6f09e64055281ecb12",
sha256 = "0a7e8811cac04b553f6c6c0d185046e3c68a4cb774e83f37a7a5fb6a3deee261",
)

maybe(
Expand Down Expand Up @@ -72,7 +73,8 @@ def rules_scala_dependencies():

# Can't upgrade for now because https://github.com/bazel-contrib/rules_python/pull/2760
# broke Bazel 7 WORKSPACE builds. It's really only a dev dep anyway.
# If it's fixed per https://github.com/bazel-contrib/rules_python/issues/3119,
# If it's fixed per https://github.com/bazel-contrib/rules_python/issues/3119
# (i.e., once https://github.com/bazel-contrib/rules_python/pull/3134 lands),
# then we can upgrade.
maybe(
http_archive,
Expand All @@ -85,7 +87,9 @@ def rules_scala_dependencies():
maybe(
http_archive,
name = "rules_shell",
sha256 = "b15cc2e698a3c553d773ff4af35eb4b3ce2983c319163707dddd9e70faaa062d",
strip_prefix = "rules_shell-0.5.0",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.5.0/rules_shell-v0.5.0.tar.gz",
sha256 = "99bfc7aaefd1ed69613bbd25e24bf7871d68aeafca3a6b79f5f85c0996a41355",
strip_prefix = "rules_shell-0.5.1",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.5.1/rules_shell-v0.5.1.tar.gz",
)

workspace_compat()
2 changes: 1 addition & 1 deletion scala/private/macros/test/MODULE.bzlmod_test
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dev_test_ext = use_extension(
dev_dependency = True,
)

bazel_dep(name = "rules_shell", version = "0.4.1")
bazel_dep(name = "rules_shell", version = "0.5.1")
32 changes: 32 additions & 0 deletions scala/private/macros/workspace_compat.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Macro to translate Bazel modules into legacy WORKSPACE compatible repos

Used only for Bazel modules that don't offer a legacy WORKSPACE compatible API
already. Originally became necessary due to:

- https://github.com/bazelbuild/bazel/issues/26579#issuecomment-3120862995
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def _bazel_worker_api_repo(name, strip_prefix):
maybe(
http_archive,
name = name,
sha256 = "5aac6ae6a23015cc7984492a114dc539effc244ec5ac7f8f6b1539c15fb376eb",
urls = [
"https://github.com/bazelbuild/bazel-worker-api/releases/download/v0.0.6/bazel-worker-api-v0.0.6.tar.gz",
],
strip_prefix = "bazel-worker-api-0.0.6/" + strip_prefix,
)

def workspace_compat():
_bazel_worker_api_repo(
name = "bazel_worker_api",
strip_prefix = "proto",
)

_bazel_worker_api_repo(
name = "bazel_worker_java",
strip_prefix = "java",
)
8 changes: 4 additions & 4 deletions scripts/create_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
]
PARSER_COMBINATORS_VERSION = '1.1.2'
SBT_COMPILER_INTERFACE_VERSION = '1.10.8'
SBT_UTIL_INTERFACE_VERSION = '1.11.3'
SBT_UTIL_INTERFACE_VERSION = '1.11.4'
SCALATEST_VERSION = "3.2.19"
SCALAFMT_VERSION = "3.9.8"
SCALAFMT_VERSION = "3.9.9"
KIND_PROJECTOR_VERSION = "0.13.3"
PROTOBUF_JAVA_VERSION = "4.31.1"
JLINE_VERSION = '3.30.4'
SCALAPB_VERSION = '1.0.0-alpha.1'
PROTOC_BRIDGE_VERSION = '0.9.9'
GRPC_VERSION = '1.73.0'
PROTO_GOOGLE_COMMON_PROTOS_VERSION = '2.59.2'
GRPC_VERSION = '1.74.0'
PROTO_GOOGLE_COMMON_PROTOS_VERSION = '2.60.0'
GRPC_LIBS = ['netty', 'protobuf', 'stub']
GUAVA_VERSION = '33.4.8-jre'

Expand Down
2 changes: 1 addition & 1 deletion src/java/io/bazel/rulesscala/coverage/instrumenter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ java_binary(
"//src/java/io/bazel/rulesscala/io_utils",
"//src/java/io/bazel/rulesscala/jar",
"//src/java/io/bazel/rulesscala/worker",
"@bazel_tools//src/main/protobuf:worker_protocol_java_proto",
"@bazel_tools//tools/jdk:JacocoCoverage",
"@bazel_worker_java//:worker_protocol_java_proto",
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/java/io/bazel/rulesscala/scalac/definitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DEFAULT_SCALAC_DEPS = [
"//src/protobuf/io/bazel/rules_scala:diagnostics_java_proto",
"//src/java/io/bazel/rulesscala/scalac/compileoptions",
"//src/java/io/bazel/rulesscala/scalac/reporter",
"@bazel_tools//src/main/protobuf:worker_protocol_java_proto",
"@bazel_worker_java//:worker_protocol_java_proto",
]
]

Expand Down
4 changes: 2 additions & 2 deletions src/java/io/bazel/rulesscala/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ java_library(
srcs = ["Worker.java"],
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//src/main/protobuf:worker_protocol_java_proto",
"@bazel_worker_java//:worker_protocol_java_proto",
],
)

Expand All @@ -20,6 +20,6 @@ java_test(
test_class = "io.bazel.rulesscala.worker.WorkerTest",
deps = [
":worker",
"@bazel_tools//src/main/protobuf:worker_protocol_java_proto",
"@bazel_worker_java//:worker_protocol_java_proto",
],
)
4 changes: 2 additions & 2 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ scala_specs2_junit_test(
name = "data_location_expansion",
size = "small",
srcs = ["src/main/scala/scalarules/test/location_expansion/LocationExpansionTest.scala"],
data = ["@bazel_tools//src/main/protobuf:worker_protocol_java_proto"],
jvm_flags = ["-Dlocation.expanded='$(rootpaths @bazel_tools//src/main/protobuf:worker_protocol_java_proto)'"],
data = ["@bazel_worker_java//:worker_protocol_java_proto"],
jvm_flags = ["-Dlocation.expanded='$(rootpaths @bazel_worker_java//:worker_protocol_java_proto)'"],
suffixes = ["Test"],
)

Expand Down
2 changes: 1 addition & 1 deletion test/scalafmt/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.9.8"
version = "3.9.9"
runner.dialect = scala213
maxColumn = 40
lineEndings = preserve
4 changes: 3 additions & 1 deletion test/shell/test_bzlmod_macros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ setup_suite() {
}

teardown_suite() {
teardown_test_tmpdir "$original_dir" "$test_tmpdir"
if [[ -n "${original_dir:-}" ]]; then
teardown_test_tmpdir "$original_dir" "$test_tmpdir"
fi
}

setup_test_module() {
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ fail() {
target_file_location() {
local target="$1"
local cmd=(bazel query --output location "$target")
local regex="([^[:cntrl:]]*):[0-9]+:[0-9]+: [^[:cntrl:]]+ ${target//./\\.}$"
local regex="([^[:cntrl:]]*):[0-9]+:[0-9]+: [^[:cntrl:]]+ ${target//./\\.}"
local output

if ! output="$("${cmd[@]}" 2>&1)"; then
fail "failed: ${cmd[*]}" "$output"
elif [[ "$output" =~ $regex ]]; then
printf '%s' "${BASH_REMATCH[1]}"
else
fail "output of: ${cmd[*]}" "does not match: ${pattern}" "$output"
fail "output of: ${cmd[*]}" "does not match: ${regex}" "$output"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion test_cross_build/scalafmt/.scalafmt2.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.9.8"
version = "3.9.9"
runner.dialect = scala213
maxColumn = 40
lineEndings = preserve
2 changes: 1 addition & 1 deletion test_cross_build/scalafmt/.scalafmt3.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.9.8"
version = "3.9.9"
runner.dialect = scala3
maxColumn = 40
lineEndings = preserve
6 changes: 6 additions & 0 deletions test_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ check_module_bazel_template() {
}

test_check_module_bazel_template() {
if [[ "$(bazel --version)" =~ ^bazel\ 6\. ]]; then
local msg="${FUNCNAME} not compatible with Bazel 6, skipping..."
echo -e " ${YELLOW}${msg}${NC}"
return
fi

run_in_test_repo "check_module_bazel_template" \
"bzlmod_tidy" \
"version_specific_tests_dir/"
Expand Down
4 changes: 2 additions & 2 deletions test_version/MODULE.bazel.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ local_path_override(
path = "../../deps/latest",
)

bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "rules_java", version = "8.15.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_shell", version = "0.4.1")
bazel_dep(name = "rules_shell", version = "0.5.1")
bazel_dep(
name = "protobuf",
version = "31.1",
Expand Down
Loading