From bc2a933e91ac3f539b7bc9f356e7b92b67eadf49 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:35:30 +0000 Subject: [PATCH 1/8] Migrate to Bzlmod --- .bazelrc | 3 --- WORKSPACE | 40 ----------------------------------- repositories/BUILD | 26 ----------------------- repositories/repositories.bzl | 36 ------------------------------- 4 files changed, 105 deletions(-) delete mode 100644 WORKSPACE delete mode 100644 repositories/BUILD delete mode 100644 repositories/repositories.bzl diff --git a/.bazelrc b/.bazelrc index d6f139529..6e46063f1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -15,6 +15,3 @@ # Defaults to auto which means off for Windows, explicitly enable for sh tests build --enable_runfiles=yes -# Explicitly enable WORKSPACE -# See https://github.com/bazelbuild/bazel/issues/23023 -common --enable_workspace diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index b4fd8bc16..000000000 --- a/WORKSPACE +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2017 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -workspace(name = "bazel_toolchains") - -# Use pre-generated toolchain configs for the latest Bazel and latest Ubuntu 16.04 -# container. Pre-generated configs are only provided as a convenience for -# experimenting with configuring Bazel for remote builds. Further, there are -# no guarantees on how long after a new release of Bazel or the Ubuntu 16.04 -# container mentioned above the corresponding pre-generated configs will be -# available. So, never depend directly on the URL mentioned below to download -# toolchain configs in production because they may break without warning. -# For more information and alternatives, please visit: -# https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rbe_default", - # The sha256 digest of the tarball might change without notice. So it's not - # included here. Please refer to the link mentioned above for instructions - # on how to generate your own configs. - urls = ["https://storage.googleapis.com/rbe-toolchain/bazel-configs/rbe-ubuntu1604/latest/rbe_default.tar"], -) - -load( - "//repositories:repositories.bzl", - bazel_toolchains_repositories = "repositories", -) - -bazel_toolchains_repositories() diff --git a/repositories/BUILD b/repositories/BUILD deleted file mode 100644 index b454e8a66..000000000 --- a/repositories/BUILD +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2016 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -licenses(["notice"]) # Apache 2.0 - -package(default_visibility = ["//visibility:public"]) - -bzl_library( - name = "repositories", - srcs = [ - "repositories.bzl", - ], -) diff --git a/repositories/repositories.bzl b/repositories/repositories.bzl deleted file mode 100644 index 85100ab27..000000000 --- a/repositories/repositories.bzl +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2016 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Once recursive workspace is implemented in Bazel, this file should cease -# to exist. -""" -Provides functions to pull all dependencies of this repository. -""" - -load( - "@bazel_tools//tools/build_defs/repo:http.bzl", - "http_archive", -) - -def repositories(): - """Download dependencies of bazel-toolchains.""" - excludes = native.existing_rules().keys() - - if "bazel_skylib" not in excludes: - http_archive( - name = "bazel_skylib", - sha256 = "e5d90f0ec952883d56747b7604e2a15ee36e288bb556c3d0ed33e818a4d971f2", - strip_prefix = "bazel-skylib-1.0.2", - urls = ["https://github.com/bazelbuild/bazel-skylib/archive/1.0.2.tar.gz"], - ) From 0c888b43c444de77bdbe08be59a2cf59f0bba554 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:37:50 +0000 Subject: [PATCH 2/8] Add more files --- .bazelversion | 1 + .gitignore | 3 ++- MODULE.bazel | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .bazelversion create mode 100644 MODULE.bazel diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..c6b7980b6 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.x diff --git a/.gitignore b/.gitignore index 1cbbb1ddb..11399e1dd 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ *.pyc # Go binaries built natively by the Go toolchain -/rbe_configs_gen \ No newline at end of file +/rbe_configs_gen +MODULE.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..0e39fcf5a --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,20 @@ +bazel_dep(name = "bazel_skylib", version = "1.7.1") + +# Use pre-generated toolchain configs for the latest Bazel and latest Ubuntu 16.04 +# container. Pre-generated configs are only provided as a convenience for +# experimenting with configuring Bazel for remote builds. Further, there are +# no guarantees on how long after a new release of Bazel or the Ubuntu 16.04 +# container mentioned above the corresponding pre-generated configs will be +# available. So, never depend directly on the URL mentioned below to download +# toolchain configs in production because they may break without warning. +# For more information and alternatives, please visit: +# https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rbe_default", + # The sha256 digest of the tarball might change without notice. So it's not + # included here. Please refer to the link mentioned above for instructions + # on how to generate your own configs. + urls = ["https://storage.googleapis.com/rbe-toolchain/bazel-configs/rbe-ubuntu1604/latest/rbe_default.tar"], +) From 59aff3b6481a2eab62ba65b333d94385268bb65d Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:41:21 +0000 Subject: [PATCH 3/8] Fix load --- tests/rules/exec_properties/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rules/exec_properties/BUILD b/tests/rules/exec_properties/BUILD index e10ca30d0..f5f741e0a 100644 --- a/tests/rules/exec_properties/BUILD +++ b/tests/rules/exec_properties/BUILD @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -load(":compare.bzl", "compare_dicts_test") load("//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict") +load(":compare.bzl", "compare_dicts_test") compare_dicts_test( name = "docker_network_compare_test", From 53f45c44820aa3fe32c16807c35c3dff31bceb28 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:42:48 +0000 Subject: [PATCH 4/8] Remove load-on-top --- .bazelci/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 2411c41e5..4accf7297 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -7,7 +7,7 @@ buildifier: # rule-impl-return,uninitialized,return-value,rule-impl-return,unsorted-dict-items,out-of-order-load # TODO (suvanjan): Re-enable once issues and https://github.com/bazelbuild/buildtools/issues/575 # are fixed. - warnings: "attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,confusing-name,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,function-docstring,git-repository,http-archive,integer-division,load,load-on-top,module-docstring,name-conventions,native-build,native-package,no-effect,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unreachable,unused-variable" + warnings: "attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,confusing-name,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,function-docstring,git-repository,http-archive,integer-division,load,module-docstring,name-conventions,native-build,native-package,no-effect,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unreachable,unused-variable" tasks: presubmit: platform: ubuntu1604 From 4a9c7952d9880f56589eeff8709ee6843ba197e3 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:44:19 +0000 Subject: [PATCH 5/8] Update workflow --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f8e68bd22..a9dec4c55 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -41,12 +41,12 @@ jobs: go test ./cmd/... ./pkg/... # Upload the config generation binaries for easy sharing. - name: Upload Artifact Linux AMD64 - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: rbe_configs_gen_linux_amd64 path: rbe_configs_gen_linux_amd64 - name: Upload Artifact Windows AMD64 - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: rbe_configs_gen_windows_amd64.exe - path: rbe_configs_gen_windows_amd64.exe \ No newline at end of file + path: rbe_configs_gen_windows_amd64.exe From 020a1b7b8dc554b76d81146f5bad350881a63a16 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:45:36 +0000 Subject: [PATCH 6/8] Update config --- .bazelci/presubmit.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 4accf7297..9a2ce666e 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,16 +1,9 @@ --- buildifier: version: latest - # Check for issues with the format of our bazel config files. - # All warnings from https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md - # are enabled except: - # rule-impl-return,uninitialized,return-value,rule-impl-return,unsorted-dict-items,out-of-order-load - # TODO (suvanjan): Re-enable once issues and https://github.com/bazelbuild/buildtools/issues/575 - # are fixed. - warnings: "attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,confusing-name,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,function-docstring,git-repository,http-archive,integer-division,load,module-docstring,name-conventions,native-build,native-package,no-effect,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unreachable,unused-variable" tasks: presubmit: - platform: ubuntu1604 + platform: ubuntu2204 build_targets: - "--" - "..." From e8fb212ef16f320fd5cd99e417c95cef550cc005 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:51:39 +0000 Subject: [PATCH 7/8] Fix BUILD files --- examples/remotebuildexecution/hello_world/cc/BUILD | 4 ++++ examples/remotebuildexecution/hello_world/java/BUILD | 2 ++ examples/remotebuildexecution/rbe_system_check/cc/BUILD | 3 +++ 3 files changed, 9 insertions(+) diff --git a/examples/remotebuildexecution/hello_world/cc/BUILD b/examples/remotebuildexecution/hello_world/cc/BUILD index 937b92030..f9df5895f 100644 --- a/examples/remotebuildexecution/hello_world/cc/BUILD +++ b/examples/remotebuildexecution/hello_world/cc/BUILD @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_cc//cc:cc_binary.bzl", "cc_binary") +load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@rules_cc//cc:cc_test.bzl", "cc_test") + package(default_visibility = ["//visibility:public"]) cc_library( diff --git a/examples/remotebuildexecution/hello_world/java/BUILD b/examples/remotebuildexecution/hello_world/java/BUILD index 4a72fd88a..9396bdb2d 100644 --- a/examples/remotebuildexecution/hello_world/java/BUILD +++ b/examples/remotebuildexecution/hello_world/java/BUILD @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_java//java:java_binary.bzl", "java_binary") + java_binary( name = "hello_java", srcs = ["HelloWorld.java"], diff --git a/examples/remotebuildexecution/rbe_system_check/cc/BUILD b/examples/remotebuildexecution/rbe_system_check/cc/BUILD index 596221607..597b15b4d 100644 --- a/examples/remotebuildexecution/rbe_system_check/cc/BUILD +++ b/examples/remotebuildexecution/rbe_system_check/cc/BUILD @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_cc//cc:cc_binary.bzl", "cc_binary") +load("@rules_cc//cc:cc_test.bzl", "cc_test") + package(default_visibility = ["//visibility:public"]) cc_binary( From 4a6e85e45b11e97c263b95a090838db09c63e295 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 29 Jan 2025 13:53:43 +0000 Subject: [PATCH 8/8] Add missing deps --- MODULE.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 0e39fcf5a..dc82f584d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,4 +1,6 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_java", version = "8.7.2") +bazel_dep(name = "rules_cc", version = "0.0.17") # Use pre-generated toolchain configs for the latest Bazel and latest Ubuntu 16.04 # container. Pre-generated configs are only provided as a convenience for