Optimize develop workflow and support make run and code hot swapping (#2644)

* Optimize develop workflow and support make run and code hot swapping
This commit is contained in:
Gilbert 2019-06-21 20:52:27 +08:00 committed by turtleDeng
parent 481458d8ec
commit 20188f9189
4 changed files with 57 additions and 15 deletions

1
.gitignore vendored
View File

@ -40,3 +40,4 @@ xrefr
erlang.mk
*.coverdata
etc/emqx.conf.rendered
Mnesia.*/

View File

@ -3,16 +3,43 @@
REBAR_GIT_CLONE_OPTIONS += --depth 1
export REBAR_GIT_CLONE_OPTIONS
SUITES_FILES := $(shell find test -name '*_SUITE.erl')
CT_SUITES := $(foreach value,$(SUITES_FILES),$(shell val=$$(basename $(value) .erl); echo $${val%_*}))
CT_NODE_NAME = emqxct@127.0.0.1
.PHONY: cover
run:
@echo $(CT_TEST_SUITES)
RUN_NODE_NAME = emqxdebug@127.0.0.1
.PHONY: run
run: run_setup
@rebar3 as test get-deps
@rebar3 as test auto --name $(RUN_NODE_NAME) --script test/run_emqx.escript
.PHONY: run_setup
run_setup:
@erl -noshell -eval \
"{ok, [[HOME]]} = init:get_argument(home), \
FilePath = HOME ++ \"/.config/rebar3/rebar.config\", \
case file:consult(FilePath) of \
{ok, Term} -> \
NewTerm = case lists:keyfind(plugins, 1, Term) of \
false -> [{plugins, [rebar3_auto]} | Term]; \
{plugins, OldPlugins} -> \
NewPlugins0 = OldPlugins -- [rebar3_auto], \
NewPlugins = [rebar3_auto | NewPlugins0], \
lists:keyreplace(plugins, 1, Term, {plugins, NewPlugins}) \
end, \
ok = file:write_file(FilePath, [io_lib:format(\"~p.\n\", [I]) || I <- NewTerm]); \
_ -> \
NewTerm=[{plugins, [rebar3_auto]}], \
ok = file:write_file(FilePath, [io_lib:format(\"~p.\n\", [I]) || I <- NewTerm]) \
end, \
halt(0)."
.PHONY: shell
shell:
@rebar3 as test auto
compile:
@rebar3 compile
@ -89,5 +116,6 @@ gen-clean:
.PHONY: distclean
distclean: gen-clean
@rm -rf Mnesia.*
@rm -rf _build cover deps logs log data
@rm -f rebar.lock compile_commands.json cuttlefish erl_crash.dump

View File

@ -1,12 +1,12 @@
{deps,
[ {jsx, "2.9.0"} % hex
, {cowboy, "2.6.1"} % hex
, {gproc, "0.8.0"} % hex
, {ekka, "0.5.6"} % hex
, {replayq, "0.1.1"} %hex
, {esockd, "5.5.0"} %hex
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.3.1"}}}
, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
[{jsx, "2.9.0"}, % hex
{cowboy, "2.6.1"}, % hex
{gproc, "0.8.0"}, % hex
{ekka, "0.5.6"}, % hex
{replayq, "0.1.1"}, %hex
{esockd, "5.5.0"}, %hex
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.3.1"}}},
{cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
]}.
{edoc_opts, [{preprocess, true}]}.
@ -29,9 +29,9 @@
{profiles,
[{test,
[{deps,
[ {meck, "0.8.13"} % hex
, {bbmustache, "1.7.0"} % hex
, {emqx_ct_helpers, {git, "https://github.com/emqx/emqx-ct-helpers", {tag, "v1.1.1"}}}
[{meck, "0.8.13"}, % hex
{bbmustache, "1.7.0"}, % hex
{emqx_ct_helpers, "1.1.3"} % hex
]}
]}
]}.

13
test/run_emqx.escript Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env escript
main(_) ->
start().
start() ->
SpecEmqxConfig = fun(_) -> ok end,
start(SpecEmqxConfig).
start(SpecEmqxConfig) ->
SchemaPath = filename:join(["priv", "emqx.schema"]),
ConfPath = filename:join(["etc", "emqx.conf"]),
emqx_ct_helpers:start_app(emqx, SchemaPath, ConfPath, SpecEmqxConfig).