Skip to content

Commit 20188f9

Browse files
gilbertwong96turtleDeng
authored andcommitted
Optimize develop workflow and support make run and code hot swapping (emqx#2644)
* Optimize develop workflow and support make run and code hot swapping
1 parent 481458d commit 20188f9

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ xrefr
4040
erlang.mk
4141
*.coverdata
4242
etc/emqx.conf.rendered
43+
Mnesia.*/

Makefile

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,43 @@
33
REBAR_GIT_CLONE_OPTIONS += --depth 1
44
export REBAR_GIT_CLONE_OPTIONS
55

6-
76
SUITES_FILES := $(shell find test -name '*_SUITE.erl')
87

98
CT_SUITES := $(foreach value,$(SUITES_FILES),$(shell val=$$(basename $(value) .erl); echo $${val%_*}))
109

1110
CT_NODE_NAME = [email protected]
1211

13-
.PHONY: cover
14-
run:
15-
@echo $(CT_TEST_SUITES)
12+
RUN_NODE_NAME = [email protected]
13+
14+
.PHONY: run
15+
run: run_setup
16+
@rebar3 as test get-deps
17+
@rebar3 as test auto --name $(RUN_NODE_NAME) --script test/run_emqx.escript
18+
19+
.PHONY: run_setup
20+
run_setup:
21+
@erl -noshell -eval \
22+
"{ok, [[HOME]]} = init:get_argument(home), \
23+
FilePath = HOME ++ \"/.config/rebar3/rebar.config\", \
24+
case file:consult(FilePath) of \
25+
{ok, Term} -> \
26+
NewTerm = case lists:keyfind(plugins, 1, Term) of \
27+
false -> [{plugins, [rebar3_auto]} | Term]; \
28+
{plugins, OldPlugins} -> \
29+
NewPlugins0 = OldPlugins -- [rebar3_auto], \
30+
NewPlugins = [rebar3_auto | NewPlugins0], \
31+
lists:keyreplace(plugins, 1, Term, {plugins, NewPlugins}) \
32+
end, \
33+
ok = file:write_file(FilePath, [io_lib:format(\"~p.\n\", [I]) || I <- NewTerm]); \
34+
_ -> \
35+
NewTerm=[{plugins, [rebar3_auto]}], \
36+
ok = file:write_file(FilePath, [io_lib:format(\"~p.\n\", [I]) || I <- NewTerm]) \
37+
end, \
38+
halt(0)."
39+
40+
.PHONY: shell
41+
shell:
42+
@rebar3 as test auto
1643

1744
compile:
1845
@rebar3 compile
@@ -89,5 +116,6 @@ gen-clean:
89116

90117
.PHONY: distclean
91118
distclean: gen-clean
119+
@rm -rf Mnesia.*
92120
@rm -rf _build cover deps logs log data
93121
@rm -f rebar.lock compile_commands.json cuttlefish erl_crash.dump

rebar.config

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{deps,
2-
[ {jsx, "2.9.0"} % hex
3-
, {cowboy, "2.6.1"} % hex
4-
, {gproc, "0.8.0"} % hex
5-
, {ekka, "0.5.6"} % hex
6-
, {replayq, "0.1.1"} %hex
7-
, {esockd, "5.5.0"} %hex
8-
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.3.1"}}}
9-
, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
2+
[{jsx, "2.9.0"}, % hex
3+
{cowboy, "2.6.1"}, % hex
4+
{gproc, "0.8.0"}, % hex
5+
{ekka, "0.5.6"}, % hex
6+
{replayq, "0.1.1"}, %hex
7+
{esockd, "5.5.0"}, %hex
8+
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.3.1"}}},
9+
{cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
1010
]}.
1111

1212
{edoc_opts, [{preprocess, true}]}.
@@ -29,9 +29,9 @@
2929
{profiles,
3030
[{test,
3131
[{deps,
32-
[ {meck, "0.8.13"} % hex
33-
, {bbmustache, "1.7.0"} % hex
34-
, {emqx_ct_helpers, {git, "https://github.com/emqx/emqx-ct-helpers", {tag, "v1.1.1"}}}
32+
[{meck, "0.8.13"}, % hex
33+
{bbmustache, "1.7.0"}, % hex
34+
{emqx_ct_helpers, "1.1.3"} % hex
3535
]}
3636
]}
3737
]}.

test/run_emqx.escript

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env escript
2+
3+
main(_) ->
4+
start().
5+
6+
start() ->
7+
SpecEmqxConfig = fun(_) -> ok end,
8+
start(SpecEmqxConfig).
9+
10+
start(SpecEmqxConfig) ->
11+
SchemaPath = filename:join(["priv", "emqx.schema"]),
12+
ConfPath = filename:join(["etc", "emqx.conf"]),
13+
emqx_ct_helpers:start_app(emqx, SchemaPath, ConfPath, SpecEmqxConfig).

0 commit comments

Comments
 (0)