Skip to content

Commit 2c7b37d

Browse files
authored
Use gazelle for external erlang deps (#6935)
* Add gazelle for use with update-repos command * Use explicit BUILD.app_name files for erlang app deps This allows us to remove the duplicate definitions in workspace_helpers.bzl These files are generated with gazelle. For instance: BUILD.ra is generated with `bazel run gazelle -- update-repos --verbose --build_files_dir=bazel hex.pm/ra@2.4.6` Running gazelle this way will modify the WORKSPACE file, as gazelle does not yet support MODULE.bazel files. Such changes to the WORKSPACE can be dropped, and should not be committed. It may also update the `moduleindex.yaml` file. Changes to `moduleindex.yaml` should be committed. However * skip the explicit bazel/BUILD.osiris file, as osiris already contains the file in its repo * skip the explict BUILD.inet_tcp_proxy_dist file, since the repo already contains a bazel BUILD.bazel file gazelle command: `bazel run gazelle -- update-repos --verbose --build_files_dir=bazel inet_tcp_proxy_dist=github.com/rabbitmq/inet_tcp_proxy@master` * jose is imported with `bazel run gazelle -- update-repos --verbose --build_files_dir=bazel jose=github.com/michaelklishin/erlang-jose@d63c1c5c8f9c1a4f1438e234b886de8607a0034e` * Move the bats dep directly to WORKSPACE, drop workspace_helpers.bzl * Use bzlmod in windows tests
1 parent 8e9f0f7 commit 2c7b37d

40 files changed

+7820
-463
lines changed

.github/workflows/test-windows.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ jobs:
6060
run: |
6161
bazelisk test //... ^
6262
--config=buildbuddy ^
63-
--noexperimental_enable_bzlmod ^
6463
--test_tag_filters=-aws,-docker,-bats,-starts-background-broker ^
6564
--build_tests_only ^
6665
--verbose_failures

BAZEL.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ Note: This takes quite some time on a single machine.
5959

6060
`bazel test //deps/rabbit:lazy_queue_SUITE`
6161

62+
## Add/update an external dependency from hex.pm
63+
64+
1. `bazel run gazelle -- update-repos --verbose --build_files_dir=bazel hex.pm/accept@0.3.5` to generate/update `bazel/BUILD.accept`
65+
~~`bazel run gazelle-update-repos -- -args hex.pm/accept@0.3.5`~~
66+
1. `git checkout WORKSPACE` to reset the workspace file
67+
1. Add/update the entry in MODULE.bazel
68+
69+
## Add/update an external dependency from github
70+
71+
`bazel run gazelle -- update-repos --verbose --build_files_dir=bazel github.com/extend/ct_helper`
72+
6273
## Additional Useful Commands
6374

6475
- Format all bazel files consistently (requires [buildifier](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md)):

BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
77
load("@rules_erlang//:dialyze.bzl", "plt")
88
load("@rules_erlang//:shell.bzl", "shell")
99
load("@rules_erlang//:erl_eval.bzl", "erl_eval")
10+
load("@bazel_gazelle//:def.bzl", "gazelle")
11+
load("@rules_erlang//gazelle:def.bzl", "GAZELLE_ERLANG_RUNTIME_DEPS")
1012
load("//bazel/elixir:iex_eval.bzl", "iex_eval")
1113
load(":rabbitmq_home.bzl", "rabbitmq_home")
1214
load(":rabbitmq_run.bzl", "rabbitmq_run", "rabbitmq_run_command")
@@ -20,6 +22,25 @@ exports_files([
2022
"release-notes",
2123
])
2224

25+
# gazelle:prefix github.com/rabbitmq/rabbitmq-server
26+
27+
gazelle(
28+
name = "gazelle",
29+
data = GAZELLE_ERLANG_RUNTIME_DEPS,
30+
gazelle = "@rules_erlang//gazelle:gazelle_erlang_binary",
31+
)
32+
33+
# gazelle(
34+
# name = "gazelle-update-repos",
35+
# extra_args = [
36+
# "--verbose",
37+
# "--build_files_dir=bazel",
38+
# ],
39+
# command = "update-repos",
40+
# data = GAZELLE_ERLANG_RUNTIME_DEPS,
41+
# gazelle = "@rules_erlang//gazelle:gazelle_erlang_binary",
42+
# )
43+
2344
bool_flag(
2445
name = "enable_test_build",
2546
build_setting_default = False,

BUILD.inet_tcp_proxy

Lines changed: 0 additions & 8 deletions
This file was deleted.

BUILD.jose

Lines changed: 0 additions & 10 deletions
This file was deleted.

BUILD.ranch

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)