Skip to content
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

Test --incompatible_auto_exec_groups and update protobuf #4141

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ tasks:
bazel: 6.5.0 # test minimum supported version of bazel
build_targets:
- "//..."
build_flags:
- "--per_file_copt=external/.*@-w"
- "--host_per_file_copt=external/.*@-w"
test_targets:
- "//..."
# Nogo includes/excludes doesn't work before bazel 7
Expand All @@ -20,6 +23,9 @@ tasks:
- "-//tests/runfiles:runfiles_test"
# TODO: Investigate why this fails.
- "-//tests/core/starlark/cgo:missing_cc_toolchain_explicit_pure_off_test"
test_flags:
- "--per_file_copt=external/.*@-w"
- "--host_per_file_copt=external/.*@-w"
ubuntu2404:
# enable some unflipped incompatible flags on this platform to ensure we don't regress.
build_flags:
Expand Down Expand Up @@ -90,7 +96,7 @@ tasks:
- "//..."
test_flags:
# Some tests depend on this feature being disabled. However, because it's
# enabled by default in the rbe_ubuntu1604 platform, we cannot simply remove
# enabled by default in the rbe_ubuntu2004 platform, we cannot simply remove
# this flag here, we have to explicitly override it with 0.
- "--action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0"
# go_bazel_test rules are marked local, since the executors don't have bazel
Expand Down Expand Up @@ -176,13 +182,16 @@ tasks:
# TODO: Update stardoc for consistent line endings.
- "-//docs:all"
# The following configurations test a seperate WORKSPACE under the examples folder
# TODO: Remove --override_repository after the next release.
ubuntu2004_examples:
name: Examples test on Ubuntu
platform: ubuntu2404
working_directory: examples/basic-gazelle
build_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
test_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
build_targets:
- "//..."
Expand All @@ -193,8 +202,10 @@ tasks:
platform: macos_arm64
working_directory: examples/basic-gazelle
build_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
test_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
build_targets:
- "//..."
Expand All @@ -205,6 +216,7 @@ tasks:
platform: windows
working_directory: examples/basic-gazelle
build_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
# Go requires a C toolchain that accepts options and emits errors like
# gcc or clang. The Go SDK does not support MSVC.
Expand All @@ -216,6 +228,7 @@ tasks:
test_targets:
- "//..."
test_flags:
- "--override_repository=io_bazel_rules_go=../.."
- "--config=incompatible"
- '--action_env=PATH=C:\tools\msys64\usr\bin;C:\tools\msys64\bin;C:\tools\msys64\mingw64\bin;C:\python3\Scripts\;C:\python3;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\ProgramData\GooGet;C:\Program Files\Google\Compute Engine\metadata_scripts;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\Google\Compute Engine\sysprep;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\tools\msys64\usr\bin;c:\openjdk\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\CMake\bin;c:\ninja;c:\bazel;c:\buildkite'
# On Windows CI, bazel (bazelisk) needs %LocalAppData% to find the cache directory.
Expand Down
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ build:incompatible --incompatible_disallow_empty_glob
build:incompatible --incompatible_disable_starlark_host_transitions
build:incompatible --nolegacy_external_runfiles
build:incompatible --incompatible_enable_proto_toolchain_resolution
build:incompatible --incompatible_auto_exec_groups
# Also enable all incompatible flags in go_bazel_test by default.
test:incompatible --test_env=GO_BAZEL_TEST_BAZELFLAGS='--incompatible_disallow_empty_glob --incompatible_load_proto_rules_from_bzl --incompatible_enable_cc_toolchain_resolution --incompatible_config_setting_private_default_visibility --incompatible_enforce_config_setting_visibility --incompatible_disable_starlark_host_transitions --nolegacy_external_runfiles --incompatible_enable_proto_toolchain_resolution'
test:incompatible --test_env=GO_BAZEL_TEST_BAZELFLAGS='--incompatible_disallow_empty_glob --incompatible_load_proto_rules_from_bzl --incompatible_enable_cc_toolchain_resolution --incompatible_config_setting_private_default_visibility --incompatible_enforce_config_setting_visibility --incompatible_disable_starlark_host_transitions --nolegacy_external_runfiles --incompatible_enable_proto_toolchain_resolution --incompatible_auto_exec_groups'
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module(
bazel_dep(name = "bazel_features", version = "1.9.1", repo_name = "io_bazel_rules_go_bazel_features")
bazel_dep(name = "bazel_skylib", version = "1.2.0")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "protobuf", version = "3.19.2", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_proto", version = "7.0.2")
bazel_dep(name = "protobuf", version = "29.0-rc2.bcr.1", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_shell", version = "0.3.0")

go_sdk = use_extension("//go:extensions.bzl", "go_sdk")
Expand Down
57 changes: 46 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ http_archive(
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
)

# Required by protobuf.
http_archive(
name = "rules_cc",
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
strip_prefix = "rules_cc-0.0.16",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
)

# An up-to-date version is transitively required by Stardoc to fix
# https://github.com/bazelbuild/rules_java/commit/9fd8c492e7e5751f809912554d5ee9a4cc3f53d9
http_archive(
name = "rules_java",
sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz",
],
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()
Expand All @@ -40,9 +64,9 @@ go_register_nogo(

http_archive(
name = "rules_proto",
sha256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d",
strip_prefix = "rules_proto-6.0.0",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0/rules_proto-6.0.0.tar.gz",
sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8",
strip_prefix = "rules_proto-7.0.2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.2/rules_proto-7.0.2.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
Expand All @@ -55,9 +79,9 @@ rules_proto_toolchains()

http_archive(
name = "toolchains_protoc",
sha256 = "1f3cd768bbb92164952301228bac5e5079743843488598f2b17fecd41163cadb",
strip_prefix = "toolchains_protoc-0.2.4",
url = "https://github.com/aspect-build/toolchains_protoc/releases/download/v0.2.4/toolchains_protoc-v0.2.4.tar.gz",
sha256 = "f7302cce01d00c52f7ed8a033a3f133bd2c95f9608f3e4ad7d69f9e1ac2b0cc0",
strip_prefix = "toolchains_protoc-0.3.4",
url = "https://github.com/aspect-build/toolchains_protoc/releases/download/v0.3.4/toolchains_protoc-v0.3.4.tar.gz",
)

load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains")
Expand All @@ -67,14 +91,25 @@ protoc_toolchains(
version = "v25.3",
)

# An up-to-date version is required by com_google_protobuf below.
http_archive(
name = "rules_python",
sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913",
strip_prefix = "rules_python-0.36.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

http_archive(
name = "com_google_protobuf",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
# latest available in BCR, as of 2022-09-30
integrity = "sha256-zl0At4RQoMpAC/NgrADA1ZnMIl8EnZhqJ+mk45bFqEo=",
strip_prefix = "protobuf-29.0-rc2",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v29.0-rc2.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v29.0-rc2.tar.gz",
],
)

Expand Down
1 change: 1 addition & 0 deletions extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def _gomock_prog_exec_impl(ctx):
ctx.file.mockgen_tool,
go.sdk.go,
],
toolchain = GO_TOOLCHAIN_LABEL,
command = """
export GOROOT=$(pwd)/{goroot} &&
export PATH=$GOROOT/bin:$PATH &&
Expand Down
1 change: 1 addition & 0 deletions go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def _run_nogo(
outputs = [out_validation],
mnemonic = "ValidateNogo",
executable = go.toolchain._builder,
toolchain = GO_TOOLCHAIN_LABEL,
arguments = [validation_args],
execution_requirements = SUPPORTS_PATH_MAPPING_REQUIREMENT,
progress_message = "Validating nogo output for %{label}",
Expand Down
6 changes: 4 additions & 2 deletions go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,11 @@ exit /b %GO_EXIT_CODE%
)
ctx.actions.run(
executable = bat,
inputs = depset(
tools = depset(
ctx.files.srcs + [sdk.go],
transitive = [sdk.headers, sdk.srcs, sdk.tools],
),
toolchain = None,
outputs = [out, gotmp],
mnemonic = "GoToolchainBinaryBuild",
)
Expand All @@ -540,10 +541,11 @@ GO111MODULE=off \
)
ctx.actions.run_shell(
command = cmd,
inputs = depset(
tools = depset(
ctx.files.srcs + [sdk.go],
transitive = [sdk.headers, sdk.srcs, sdk.libs, sdk.tools],
),
toolchain = None,
outputs = [out],
mnemonic = "GoToolchainBinaryBuild",
)
Expand Down
1 change: 1 addition & 0 deletions go/private/rules/nogo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def _nogo_impl(ctx):
outputs = [nogo_main],
mnemonic = "GoGenNogo",
executable = go.toolchain._builder,
toolchain = GO_TOOLCHAIN,
arguments = [nogo_args],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/bcr/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bazel_dep(name = "protobuf", version = "3.19.6")

# Required with --incompatible_enable_proto_toolchain_resolution.
# Avoids building protoc from source, which speeds up CI runs.
bazel_dep(name = "toolchains_protoc", version = "0.2.1")
bazel_dep(name = "toolchains_protoc", version = "0.3.4")

go_sdk = use_extension("@my_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
Expand Down
2 changes: 1 addition & 1 deletion tests/core/cross/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
var testArgs = bazel_testing.Args{
ModuleFileSuffix: `
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "toolchains_protoc", version = "0.2.4")
bazel_dep(name = "toolchains_protoc", version = "0.3.4")
`,
WorkspacePrefix: `
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand Down
24 changes: 15 additions & 9 deletions tests/core/transition/hermeticity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ message Foo {
ModuleFileSuffix: `
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "toolchains_protoc", version = "0.2.4")
bazel_dep(name = "toolchains_protoc", version = "0.3.4")
`,
WorkspacePrefix: `
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand All @@ -140,18 +140,24 @@ http_archive(
load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

http_archive(
name = "rules_cc",
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
strip_prefix = "rules_cc-0.0.16",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
)
`,
WorkspaceSuffix: `
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_google_protobuf",
sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae",
strip_prefix = "protobuf-21.7",
# latest available in BCR, as of 2022-09-30
integrity = "sha256-zl0At4RQoMpAC/NgrADA1ZnMIl8EnZhqJ+mk45bFqEo=",
strip_prefix = "protobuf-29.0-rc2",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v21.7.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v29.0-rc2.tar.gz",
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v29.0-rc2.tar.gz",
],
)

Expand All @@ -161,9 +167,9 @@ protobuf_deps()

http_archive(
name = "rules_proto",
sha256 = "303e86e722a520f6f326a50b41cfc16b98fe6d1955ce46642a5b7a67c11c0f5d",
strip_prefix = "rules_proto-6.0.0",
url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.0/rules_proto-6.0.0.tar.gz",
sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8",
strip_prefix = "rules_proto-7.0.2",
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.2/rules_proto-7.0.2.tar.gz",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
Expand Down