Skip to content

Commit d273660

Browse files
authored
Add Bazel build (#47)
Add Bazel build files corresponding to #2938 The gnu make build should remain unchanged by theses additions
1 parent 700f5c0 commit d273660

File tree

7 files changed

+186
-49
lines changed

7 files changed

+186
-49
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build
2+
on: push
3+
jobs:
4+
test:
5+
name: build
6+
runs-on: ubuntu-18.04
7+
strategy:
8+
matrix:
9+
erlang_version:
10+
- "23.2"
11+
timeout-minutes: 10
12+
steps:
13+
- name: CHECKOUT REPOSITORY
14+
uses: actions/checkout@v2
15+
- name: CONFIGURE OTP & ELIXIR
16+
uses: actions/setup-elixir@v1
17+
with:
18+
otp-version: ${{ matrix.erlang_version }}
19+
elixir-version: 1.10.4
20+
- name: CONFIGURE BAZEL
21+
run: |
22+
ERLANG_HOME="$(dirname $(dirname $(which erl)))"
23+
cat << EOF >> .bazelrc
24+
build --@bazel-erlang//:erlang_version=${{ matrix.erlang_version }}
25+
build --@bazel-erlang//:erlang_home=${ERLANG_HOME}
26+
EOF
27+
#! - name: Setup tmate session
28+
#! uses: mxschmitt/action-tmate@v3
29+
- name: BUILD
30+
run: |
31+
bazelisk build :bazel_erlang_lib

deps/rabbitmq_ct_helpers/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ terraform.tfstate*
2020

2121
/rabbitmq_ct_helpers.d
2222
/.rabbitmq_ct_helpers.plt
23+
24+
/.bazelrc
25+
/bazel-*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("@bazel-erlang//:bazel_erlang_lib.bzl", "erlang_lib")
2+
3+
erlang_lib(
4+
app_name = "rabbitmq_ct_helpers",
5+
app_version = "master",
6+
deps = [
7+
"@proper//:bazel_erlang_lib",
8+
"@rabbitmq-server//deps/rabbit_common:bazel_erlang_lib",
9+
],
10+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "bazel-erlang",
5+
strip_prefix = "bazel-erlang-master",
6+
urls = ["https://github.com/rabbitmq/bazel-erlang/archive/master.zip"],
7+
)
8+
9+
http_archive(
10+
name = "rabbitmq-server",
11+
strip_prefix = "rabbitmq-server-master",
12+
urls = ["https://github.com/rabbitmq/rabbitmq-server/archive/master.zip"],
13+
)
14+
15+
load("@rabbitmq-server//:workspace_helpers.bzl", "rabbitmq_external_deps")
16+
17+
rabbitmq_external_deps()

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,27 @@
198198
%% -------------------------------------------------------------------
199199

200200
setup_steps() ->
201-
[
202-
fun run_make_dist/1,
203-
fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1,
204-
fun rabbit_ct_helpers:ensure_rabbitmqctl_app/1,
205-
fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1,
206-
fun set_lager_flood_limit/1,
207-
fun start_rabbitmq_nodes/1,
208-
fun share_dist_and_proxy_ports_map/1
209-
].
201+
case os:getenv("RABBITMQ_RUN") of
202+
false ->
203+
[
204+
fun run_make_dist/1,
205+
fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1,
206+
fun rabbit_ct_helpers:ensure_rabbitmqctl_app/1,
207+
fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1,
208+
fun set_lager_flood_limit/1,
209+
fun start_rabbitmq_nodes/1,
210+
fun share_dist_and_proxy_ports_map/1
211+
];
212+
_ ->
213+
[
214+
fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1,
215+
fun rabbit_ct_helpers:load_rabbitmqctl_app/1,
216+
fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1,
217+
fun set_lager_flood_limit/1,
218+
fun start_rabbitmq_nodes/1,
219+
fun share_dist_and_proxy_ports_map/1
220+
]
221+
end.
210222

211223
teardown_steps() ->
212224
[
@@ -646,13 +658,7 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
646658
undefined ->
647659
ExtraArgs0;
648660
ExtraPluginsDir ->
649-
PathSep = case os:type() of
650-
{win32, _} -> ";";
651-
_ -> ":"
652-
end,
653-
RegularPluginsDir = filename:join(SrcDir, "plugins"),
654-
[{"RABBITMQ_PLUGINS_DIR=~s~s~s",
655-
[RegularPluginsDir, PathSep, ExtraPluginsDir]}
661+
[{"EXTRA_PLUGINS_DIR=~s", [ExtraPluginsDir]}
656662
| ExtraArgs0]
657663
end,
658664
StartWithPluginsDisabled = rabbit_ct_helpers:get_config(
@@ -717,17 +723,33 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
717723
{"TEST_TMPDIR=~s", [PrivDir]}
718724
| ExtraArgs],
719725
Cmd = ["start-background-broker" | MakeVars],
720-
case rabbit_ct_helpers:make(Config, SrcDir, Cmd) of
721-
{ok, _} ->
722-
NodeConfig1 = rabbit_ct_helpers:set_config(
723-
NodeConfig,
724-
[{effective_srcdir, SrcDir},
725-
{make_vars_for_node_startup, MakeVars}]),
726-
query_node(Config, NodeConfig1);
727-
_ ->
728-
AbortCmd = ["stop-node" | MakeVars],
729-
_ = rabbit_ct_helpers:make(Config, SrcDir, AbortCmd),
730-
{skip, "Failed to initialize RabbitMQ"}
726+
case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of
727+
undefined ->
728+
case rabbit_ct_helpers:make(Config, SrcDir, Cmd) of
729+
{ok, _} ->
730+
NodeConfig1 = rabbit_ct_helpers:set_config(
731+
NodeConfig,
732+
[{effective_srcdir, SrcDir},
733+
{make_vars_for_node_startup, MakeVars}]),
734+
query_node(Config, NodeConfig1);
735+
_ ->
736+
AbortCmd = ["stop-node" | MakeVars],
737+
_ = rabbit_ct_helpers:make(Config, SrcDir, AbortCmd),
738+
{skip, "Failed to initialize RabbitMQ"}
739+
end;
740+
RunCmd ->
741+
case rabbit_ct_helpers:exec([RunCmd, "-C", SrcDir] ++ Cmd) of
742+
{ok, _} ->
743+
NodeConfig1 = rabbit_ct_helpers:set_config(
744+
NodeConfig,
745+
[{effective_srcdir, SrcDir},
746+
{make_vars_for_node_startup, MakeVars}]),
747+
query_node(Config, NodeConfig1);
748+
_ ->
749+
AbortCmd = ["stop-node" | MakeVars],
750+
_ = rabbit_ct_helpers:exec([RunCmd | AbortCmd]),
751+
{skip, "Failed to initialize RabbitMQ"}
752+
end
731753
end.
732754

733755
query_node(Config, NodeConfig) ->
@@ -958,7 +980,12 @@ stop_rabbitmq_node(Config, NodeConfig) ->
958980
{"RABBITMQ_NODENAME_FOR_PATHS=~s", [InitialNodename]}
959981
],
960982
Cmd = ["stop-node" | MakeVars],
961-
rabbit_ct_helpers:make(Config, SrcDir, Cmd),
983+
case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of
984+
undefined ->
985+
rabbit_ct_helpers:make(Config, SrcDir, Cmd);
986+
RunCmd ->
987+
rabbit_ct_helpers:exec([RunCmd | Cmd])
988+
end,
962989
NodeConfig.
963990

964991
%% -------------------------------------------------------------------

deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ensure_application_srcdir/4,
2222
ensure_rabbitmqctl_cmd/1,
2323
ensure_rabbitmqctl_app/1,
24+
load_rabbitmqctl_app/1,
2425
ensure_rabbitmq_plugins_cmd/1,
2526
ensure_rabbitmq_queues_cmd/1,
2627
start_long_running_testsuite_monitor/1,
@@ -67,24 +68,40 @@ run_setup_steps(Config) ->
6768
run_setup_steps(Config, []).
6869

6970
run_setup_steps(Config, ExtraSteps) ->
70-
Steps = [
71-
fun init_skip_as_error_flag/1,
72-
fun guess_tested_erlang_app_name/1,
73-
fun ensure_secondary_umbrella/1,
74-
fun ensure_current_srcdir/1,
75-
fun ensure_rabbitmq_ct_helpers_srcdir/1,
76-
fun ensure_erlang_mk_depsdir/1,
77-
fun ensure_secondary_erlang_mk_depsdir/1,
78-
fun ensure_secondary_current_srcdir/1,
79-
fun ensure_rabbit_common_srcdir/1,
80-
fun ensure_rabbitmq_cli_srcdir/1,
81-
fun ensure_rabbit_srcdir/1,
82-
fun ensure_make_cmd/1,
83-
fun ensure_erl_call_cmd/1,
84-
fun ensure_ssl_certs/1,
85-
fun start_long_running_testsuite_monitor/1,
86-
fun load_elixir/1
87-
],
71+
Steps = case os:getenv("RABBITMQ_RUN") of
72+
false ->
73+
[
74+
fun init_skip_as_error_flag/1,
75+
fun guess_tested_erlang_app_name/1,
76+
fun ensure_secondary_umbrella/1,
77+
fun ensure_current_srcdir/1,
78+
fun ensure_rabbitmq_ct_helpers_srcdir/1,
79+
fun ensure_erlang_mk_depsdir/1,
80+
fun ensure_secondary_erlang_mk_depsdir/1,
81+
fun ensure_secondary_current_srcdir/1,
82+
fun ensure_rabbit_common_srcdir/1,
83+
fun ensure_rabbitmq_cli_srcdir/1,
84+
fun ensure_rabbit_srcdir/1,
85+
fun ensure_make_cmd/1,
86+
fun ensure_erl_call_cmd/1,
87+
fun ensure_ssl_certs/1,
88+
fun start_long_running_testsuite_monitor/1,
89+
fun load_elixir/1
90+
];
91+
_ ->
92+
[
93+
fun init_skip_as_error_flag/1,
94+
% fun guess_tested_erlang_app_name/1,
95+
fun ensure_secondary_umbrella/1,
96+
fun ensure_current_srcdir/1,
97+
fun ensure_rabbitmq_ct_helpers_srcdir/1,
98+
% fun ensure_rabbit_srcdir/1,
99+
fun ensure_make_cmd/1,
100+
fun ensure_rabbitmq_run_cmd/1,
101+
fun ensure_ssl_certs/1,
102+
fun start_long_running_testsuite_monitor/1
103+
]
104+
end,
88105
run_steps(Config, Steps ++ ExtraSteps).
89106

90107
run_teardown_steps(Config) ->
@@ -117,8 +134,14 @@ run_steps(Config, [Step | Rest]) ->
117134
{skip, _} = Error ->
118135
run_teardown_steps(Config),
119136
Error;
120-
Config1 ->
121-
run_steps(Config1, Rest)
137+
Config1 when is_list(Config1) ->
138+
run_steps(Config1, Rest);
139+
Other ->
140+
ct:pal(?LOW_IMPORTANCE,
141+
"~p:~p/~p failed with ~p steps remaining (Config value ~p is not a proplist)",
142+
[?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY, length(Rest), Other]),
143+
run_teardown_steps(Config),
144+
exit("A setup step returned a non-proplist")
122145
end;
123146
run_steps(Config, []) ->
124147
Config.
@@ -137,7 +160,8 @@ init_skip_as_error_flag(Config) ->
137160
guess_tested_erlang_app_name(Config) ->
138161
case os:getenv("DIALYZER_PLT") of
139162
false ->
140-
ok;
163+
{skip,
164+
"plt file required, please set DIALYZER_PLT"};
141165
Filename ->
142166
AppName0 = filename:basename(Filename, ".plt"),
143167
AppName = string:strip(AppName0, left, $.),
@@ -328,6 +352,16 @@ ensure_make_cmd(Config) ->
328352
"please set MAKE or 'make_cmd' in ct config"}
329353
end.
330354

355+
ensure_rabbitmq_run_cmd(Config) ->
356+
case os:getenv("RABBITMQ_RUN") of
357+
false ->
358+
{skip,
359+
"Bazel helper rabbitmq-run required, " ++
360+
"please set RABBITMQ_RUN"};
361+
P ->
362+
set_config(Config, {rabbitmq_run_cmd, P})
363+
end.
364+
331365
ensure_erl_call_cmd(Config) ->
332366
ErlCallDir = code:lib_dir(erl_interface, bin),
333367
ErlCall = filename:join(ErlCallDir, "erl_call"),
@@ -419,6 +453,17 @@ ensure_rabbitmqctl_app(Config) ->
419453
"please build rabbitmq_cli and set MIX_ENV"}
420454
end.
421455

456+
load_rabbitmqctl_app(Config) ->
457+
case application:load(rabbitmqctl) of
458+
ok ->
459+
Config;
460+
{error, {already_loaded, rabbitmqctl}} ->
461+
Config;
462+
{error, _} ->
463+
{skip, "Application rabbitmqctl could not be loaded, " ++
464+
"please place compiled rabbitmq_cli on the code path"}
465+
end.
466+
422467
ensure_rabbitmq_plugins_cmd(Config) ->
423468
Rabbitmqplugins = case get_config(Config, rabbitmq_plugins_cmd) of
424469
undefined ->
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
exports_files([
2+
"Makefile",
3+
"openssl.cnf.in",
4+
])

0 commit comments

Comments
 (0)