Skip to content

Commit

Permalink
Use gazelle for external erlang deps (#6935)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HoloRin authored Jan 25, 2023
1 parent 8e9f0f7 commit 2c7b37d
Show file tree
Hide file tree
Showing 40 changed files with 7,820 additions and 463 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
run: |
bazelisk test //... ^
--config=buildbuddy ^
--noexperimental_enable_bzlmod ^
--test_tag_filters=-aws,-docker,-bats,-starts-background-broker ^
--build_tests_only ^
--verbose_failures
11 changes: 11 additions & 0 deletions BAZEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ Note: This takes quite some time on a single machine.

`bazel test //deps/rabbit:lazy_queue_SUITE`

## Add/update an external dependency from hex.pm

1. `bazel run gazelle -- update-repos --verbose --build_files_dir=bazel hex.pm/accept@0.3.5` to generate/update `bazel/BUILD.accept`
~~`bazel run gazelle-update-repos -- -args hex.pm/accept@0.3.5`~~
1. `git checkout WORKSPACE` to reset the workspace file
1. Add/update the entry in MODULE.bazel

## Add/update an external dependency from github

`bazel run gazelle -- update-repos --verbose --build_files_dir=bazel github.com/extend/ct_helper`

## Additional Useful Commands

- Format all bazel files consistently (requires [buildifier](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md)):
Expand Down
21 changes: 21 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_erlang//:dialyze.bzl", "plt")
load("@rules_erlang//:shell.bzl", "shell")
load("@rules_erlang//:erl_eval.bzl", "erl_eval")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_erlang//gazelle:def.bzl", "GAZELLE_ERLANG_RUNTIME_DEPS")
load("//bazel/elixir:iex_eval.bzl", "iex_eval")
load(":rabbitmq_home.bzl", "rabbitmq_home")
load(":rabbitmq_run.bzl", "rabbitmq_run", "rabbitmq_run_command")
Expand All @@ -20,6 +22,25 @@ exports_files([
"release-notes",
])

# gazelle:prefix github.com/rabbitmq/rabbitmq-server

gazelle(
name = "gazelle",
data = GAZELLE_ERLANG_RUNTIME_DEPS,
gazelle = "@rules_erlang//gazelle:gazelle_erlang_binary",
)

# gazelle(
# name = "gazelle-update-repos",
# extra_args = [
# "--verbose",
# "--build_files_dir=bazel",
# ],
# command = "update-repos",
# data = GAZELLE_ERLANG_RUNTIME_DEPS,
# gazelle = "@rules_erlang//gazelle:gazelle_erlang_binary",
# )

bool_flag(
name = "enable_test_build",
build_setting_default = False,
Expand Down
8 changes: 0 additions & 8 deletions BUILD.inet_tcp_proxy

This file was deleted.

10 changes: 0 additions & 10 deletions BUILD.jose

This file was deleted.

41 changes: 0 additions & 41 deletions BUILD.ranch

This file was deleted.

Loading

0 comments on commit 2c7b37d

Please sign in to comment.