Skip to content

Commit

Permalink
Fix plugin build logic
Browse files Browse the repository at this point in the history
For reasons to me unknown, the build logic was unable to package and
run the plugin against the broker anymore.

As the build logic is incredibly overengineerd and complicated, the
following hacks were done to make it work.

1. We target against a fixed (and stable version) by switching from
the main branch to the versioned one.
2. We build the `.ez` archive ourselves via `mix` and copy both the
plugin and its dependencies within the `plugins` folder.
3. We override an internal variable `EXTRA_DIST_EZS` to avoid RMQ
Makefiles from removing the copied plugins.

This logic is brittle to say the least, I am not sure for how long I
will manage to maintain this package as every time things are more
complicated and less documented...

Signed-off-by: Matteo Cafasso <[email protected]>
  • Loading branch information
noxdafox committed Jan 21, 2024
1 parent 3ec1529 commit bb7bef5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ jobs:
sudo apt install -y --allow-downgrades esl-erlang=${{ matrix.erlang }}
- name: Install Elixir
run: |
sudo apt install -y elixir=1.13.4-1
- name: Install RMQ requirements
run: |
wget https://github.com/rabbitmq/mix_task_archive_deps/releases/download/0.5.0/mix_task_archive_deps-0.5.0.ez
mix archive.install --force ./mix_task_archive_deps-0.5.0.ez
rm mix_task_archive_deps-0.5.0.ez
sudo apt install -y elixir=1.15.7-1
- name: Run tests
run: |
git checkout -b v3.12.x
Expand Down
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
PROJECT = rabbitmq_message_deduplication

BUILD_DEPS = rabbitmq_cli
DEPS = rabbit_common rabbit
DEPS = rabbit_common rabbit rabbitmq_management
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client

DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk

# Mix customizations

MIX_ENV ?= dev
override MIX := mix
elixir_srcs := mix.exs

# RMQ `dist` target removes anything within the `plugins` folder
# which is not managed by erlang.mk.
# We need to instruct the `rabbitmq-dist:do-dist` target to not
# remove our plugin and related dependencies.
ELIXIR_VERSION := $(shell elixir --version | grep Elixir | cut -d ' ' -f 2)
PROJECT_VERSION := $(shell git describe --tags --abbrev=0)
EXTRA_DIST_EZS := plugins/elixir-$(ELIXIR_VERSION).ez plugins/$(PROJECT)-$(PROJECT_VERSION).ez

app:: $(elixir_srcs) deps
$(MIX) make_all
cp -r _build/$(MIX_ENV)/archives/elixir-*.ez plugins/
cp -r _build/$(MIX_ENV)/archives/$(PROJECT)-*.ez plugins/

tests:: $(elixir_srcs) deps
MIX_ENV=test $(MIX) make_tests

# FIXME: Use erlang.mk patched for RabbitMQ, while waiting for PRs to be
# reviewed and merged.
clean::
@rm -fr _build

ERLANG_MK_REPO = https://github.com/rabbitmq/erlang.mk.git
ERLANG_MK_COMMIT = rabbitmq-tmp
# erlang.mk modules

include rabbitmq-components.mk
include erlang.mk
25 changes: 8 additions & 17 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,7 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Mixfile do
deps_path: deps_dir,
deps: deps(deps_dir),
aliases: aliases(),
xref: [
exclude: [
:amqqueue,
:rabbit_amqqueue,
:rabbit_backing_queue,
:rabbit_exchange,
:rabbit_router,
:rabbit_binary_parser,
:rabbit_exchange_type,
:rabbit_log,
:rabbit_misc,
:rabbit_policy_validator,
:rabbit_registry,
:rabbit_policy
]
]
# elixirc_paths: ["src"],
]
end

Expand All @@ -42,12 +27,16 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Mixfile do

[
applications: applications,
registered: [RabbitMQMessageDeduplication],
mod: {RabbitMQMessageDeduplication, []}
]
end

defp deps(deps_dir) do
[
{
:mix_task_archive_deps, "~> 1.0"
},
{
:rabbit,
path: Path.join(deps_dir, "rabbit"),
Expand Down Expand Up @@ -77,7 +66,9 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Mixfile do
make_all: [
"deps.get",
"deps.compile",
"compile"
"compile",
"archive.build.elixir",
"archive.build.all"
],
make_tests: [
"test"
Expand Down

0 comments on commit bb7bef5

Please sign in to comment.