From 350db17ae364b86c493978378ccde49533fa0b85 Mon Sep 17 00:00:00 2001 From: Jaden Peterson Date: Wed, 24 Sep 2025 12:58:25 -0400 Subject: [PATCH] Use buildifier-prebuilt instead of building buildifier It's my goal to remove `dev_deps`, and switching to `buildifier-prebuilt` gets us one step closer to doing that. It should also make CI faster. --- MODULE.bazel | 51 +-------------------------- MODULE.bazel.lock | 18 ++-------- WORKSPACE | 36 +++++++++---------- scala/private/extensions/dev_deps.bzl | 13 ------- tools/BUILD | 6 +--- 5 files changed, 21 insertions(+), 103 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 389809673..67a35ba51 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -195,7 +195,6 @@ internal_dev_deps = use_extension( # See //scala/private:extensions/dev_deps.bzl for notes on some of these repos. use_repo( internal_dev_deps, - "com_github_bazelbuild_buildtools", "com_github_jnr_jffi_native", "com_google_guava_guava_21_0", "com_google_guava_guava_21_0_with_file", @@ -255,54 +254,6 @@ bazel_dep( dev_dependency = True, repo_name = "bazelci_rules", ) -bazel_dep( - name = "rules_go", - version = "0.58.2", - dev_dependency = True, - repo_name = "io_bazel_rules_go", # for com_github_bazelbuild_buildtools -) -bazel_dep(name = "gazelle", version = "0.45.0", dev_dependency = True) - -go_sdk = use_extension( - "@io_bazel_rules_go//go:extensions.bzl", - "go_sdk", - dev_dependency = True, -) -go_sdk.download(version = "1.25.3") - -go_deps = use_extension( - "@gazelle//:extensions.bzl", - "go_deps", - dev_dependency = True, -) - -# The go_deps.module calls are inspired by the following to get the -# com_github_bazelbuild_buildtools repo to work: -# -# - https://github.com/bazelbuild/bazel-central-registry/blob/main/modules/gazelle/0.39.1/MODULE.bazel#L31-L57 -# -# To get the latest version and hashes for each per: -# -# - https://go.dev/ref/mod#go-list-m -# - 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.38.0 -go_deps.module( - path = "golang.org/x/tools", - sum = "h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=", - version = "v0.38.0", -) -go_deps.module( - path = "github.com/golang/protobuf", - sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", - version = "v1.5.4", -) -use_repo( - go_deps, - "com_github_golang_protobuf", - "org_golang_x_tools", -) - +bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True) bazel_dep(name = "rules_python", version = "1.6.3", dev_dependency = True) bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index e5307e400..46f3f191b 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -15,7 +15,6 @@ "https://bcr.bazel.build/modules/apple_support/1.23.1/source.json": "d888b44312eb0ad2c21a91d026753f330caa48a25c9b2102fae75eb2b0dcfdd2", "https://bcr.bazel.build/modules/bazel_ci_rules/1.0.0/MODULE.bazel": "0f92c944b9c466066ed484cfc899cf43fca765df78caca18984c62479f7925eb", "https://bcr.bazel.build/modules/bazel_ci_rules/1.0.0/source.json": "3405a2a7f9f827a44934b01470faeac1b56fb1304955c98ee9fcd03ad2ca5dcc", - "https://bcr.bazel.build/modules/bazel_features/1.1.0/MODULE.bazel": "cfd42ff3b815a5f39554d97182657f8c4b9719568eb7fded2b9135f084bf760b", "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", @@ -34,14 +33,10 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", "https://bcr.bazel.build/modules/bazel_worker_api/0.0.6/MODULE.bazel": "fd1f9432ca04c947e91b500df69ce7c5b6dbfe1bc45ab1820338205dae3383a6", "https://bcr.bazel.build/modules/bazel_worker_api/0.0.6/source.json": "5d68545f224904745a3cabd35aea6bc2b6cc5a78b7f49f3f69660eab2eeeb273", + "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.0.2/MODULE.bazel": "a9b689711d5b69f9db741649b218c119b9fdf82924ba390415037e09798edd03", + "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.0.2/source.json": "51eb0a4b38aaaeab7fa64361576d616c4d8bfd0f17a0a10184aeab7084d79f8e", "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", - "https://bcr.bazel.build/modules/gazelle/0.32.0/MODULE.bazel": "b499f58a5d0d3537f3cf5b76d8ada18242f64ec474d8391247438bf04f58c7b8", - "https://bcr.bazel.build/modules/gazelle/0.33.0/MODULE.bazel": "a13a0f279b462b784fb8dd52a4074526c4a2afe70e114c7d09066097a46b3350", - "https://bcr.bazel.build/modules/gazelle/0.34.0/MODULE.bazel": "abdd8ce4d70978933209db92e436deb3a8b737859e9354fb5fd11fb5c2004c8a", - "https://bcr.bazel.build/modules/gazelle/0.36.0/MODULE.bazel": "e375d5d6e9a6ca59b0cb38b0540bc9a05b6aa926d322f2de268ad267a2ee74c0", - "https://bcr.bazel.build/modules/gazelle/0.45.0/MODULE.bazel": "ecd19ebe9f8e024e1ccffb6d997cc893a974bcc581f1ae08f386bdd448b10687", - "https://bcr.bazel.build/modules/gazelle/0.45.0/source.json": "111d182facc5f5e80f0b823d5f077b74128f40c3fd2eccc89a06f34191bd3392", "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", @@ -53,8 +48,6 @@ "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", - "https://bcr.bazel.build/modules/package_metadata/0.0.5/MODULE.bazel": "ef4f9439e3270fdd6b9fd4dbc3d2f29d13888e44c529a1b243f7a31dfbc2e8e4", - "https://bcr.bazel.build/modules/package_metadata/0.0.5/source.json": "2326db2f6592578177751c3e1f74786b79382cd6008834c9d01ec865b9126a85", "https://bcr.bazel.build/modules/platforms/1.0.0/MODULE.bazel": "f05feb42b48f1b3c225e4ccf351f367be0371411a803198ec34a389fb22aa580", "https://bcr.bazel.build/modules/platforms/1.0.0/source.json": "f4ff1fd412e0246fd38c82328eb209130ead81d62dcd5a9e40910f867f733d96", "https://bcr.bazel.build/modules/protobuf/33.0/MODULE.bazel": "c5270efb4aad37a2f893536076518793f409ea7df07a06df995d848d1690f21c", @@ -79,17 +72,10 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", "https://bcr.bazel.build/modules/rules_cc/0.1.1/MODULE.bazel": "2f0222a6f229f0bf44cd711dc13c858dad98c62d52bd51d8fc3a764a83125513", - "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_cc/0.2.8/source.json": "85087982aca15f31307bd52698316b28faa31bd2c3095a41f456afec0131344c", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", - "https://bcr.bazel.build/modules/rules_go/0.41.0/MODULE.bazel": "55861d8e8bb0e62cbd2896f60ff303f62ffcb0eddb74ecb0e5c0cbe36fc292c8", - "https://bcr.bazel.build/modules/rules_go/0.42.0/MODULE.bazel": "8cfa875b9aa8c6fce2b2e5925e73c1388173ea3c32a0db4d2b4804b453c14270", - "https://bcr.bazel.build/modules/rules_go/0.46.0/MODULE.bazel": "3477df8bdcc49e698b9d25f734c4f3a9f5931ff34ee48a2c662be168f5f2d3fd", - "https://bcr.bazel.build/modules/rules_go/0.53.0/MODULE.bazel": "a4ed760d3ac0dbc0d7b967631a9a3fd9100d28f7d9fcf214b4df87d4bfff5f9a", - "https://bcr.bazel.build/modules/rules_go/0.58.2/MODULE.bazel": "baebed8067d059e50bb03d56a37ea975cb4830d78fd40b8d6b0b53ba267c664d", - "https://bcr.bazel.build/modules/rules_go/0.58.2/source.json": "90bb77dd3105fc3ac26d961a7d7969408c1a4952b0226ecb3fbe76d576b1a077", "https://bcr.bazel.build/modules/rules_java/8.16.1/MODULE.bazel": "0f20b1cecaa8e52f60a8f071e59a20b4e3b9a67f6c56c802ea256f6face692d3", "https://bcr.bazel.build/modules/rules_java/8.16.1/source.json": "072f8d11264edc499621be2dc9ea01d6395db5aa6f8799c034ae01a3e857f2e4", "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", diff --git a/WORKSPACE b/WORKSPACE index c591c9907..0cc2fa9e4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -104,25 +104,6 @@ local_repository( path = "third_party/test/example_external_workspace", ) -http_archive( - name = "io_bazel_rules_go", - sha256 = "54bbb67a4196170cc60ef3b52a2747ad1759cba4764b4c4752b744080ad99947", - urls = [ - "https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.58.2/rules_go-v0.58.2.zip", - "https://github.com/bazel-contrib/rules_go/releases/download/v0.58.2/rules_go-v0.58.2.zip", - ], -) - -load( - "@io_bazel_rules_go//go:deps.bzl", - "go_register_toolchains", - "go_rules_dependencies", -) - -go_rules_dependencies() - -go_register_toolchains(version = "1.25.3") - http_archive( name = "bazelci_rules", sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", @@ -132,6 +113,23 @@ http_archive( load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig") +buildifier_prebuilt_version = "8.2.0.2" + +http_archive( + name = "buildifier_prebuilt", + sha256 = "f98dd3d8f32661629b8cab11f02d7730bb8e03bd8af09dbbb268047889c8ff10", + strip_prefix = "buildifier-prebuilt-{}".format(buildifier_prebuilt_version), + urls = ["http://github.com/keith/buildifier-prebuilt/archive/{}.tar.gz".format(buildifier_prebuilt_version)], +) + +load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") + +buildifier_prebuilt_deps() + +load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains") + +buildifier_prebuilt_register_toolchains() + rbe_preconfig( name = "rbe_default", toolchain = "ubuntu2004-bazel-java11", diff --git a/scala/private/extensions/dev_deps.bzl b/scala/private/extensions/dev_deps.bzl index a528888b3..60c5af2cb 100644 --- a/scala/private/extensions/dev_deps.bzl +++ b/scala/private/extensions/dev_deps.bzl @@ -43,19 +43,6 @@ def dev_deps_repositories( fetch_sources: retrieve Maven artifact sources when True """ - # gazelle is still getting `buildtools` from its `go.mod` file, which breaks - # `bazel run //tools:lint_check` when we don't import it like this. See: - # - https://github.com/bazel-contrib/bazel-gazelle/blob/v0.43.0/MODULE.bazel#L32-L44 - http_archive( - name = "com_github_bazelbuild_buildtools", - integrity = _BUILD_TOOLS_INTEGRITY, - strip_prefix = "buildtools-%s" % _BUILD_TOOLS_RELEASE, - url = ( - "https://github.com/bazelbuild/buildtools/archive/v%s.tar.gz" % - _BUILD_TOOLS_RELEASE - ), - ) - # bazel's java_import_external has been altered in rules_scala to be a macro # based on jvm_import_external in order to allow for other jvm-language # imports (e.g. scala_import) the 3rd-party dependency below is using the diff --git a/tools/BUILD b/tools/BUILD index 2225c28b9..ce9916886 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -1,8 +1,4 @@ -load( - "@com_github_bazelbuild_buildtools//buildifier:def.bzl", - "buildifier", - "buildifier_test", -) +load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test") WARNINGS_CONFIG = [ "-module-docstring",