From 625755ea339fe71dc9636f4da6d579e441496aec Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sat, 6 Mar 2021 22:28:14 +0100 Subject: [PATCH 1/4] chore(Makefile): refine 'make clean' --- Makefile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ce92d5bbf..6470e124c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ export EMQX_CE_DASHBOARD_VERSION ?= v4.3.0-beta.1 PROFILE ?= emqx REL_PROFILES := emqx emqx-edge PKG_PROFILES := emqx-pkg emqx-edge-pkg -PROFILES := $(REL_PROFILES) $(PKG_PROFILES) +PROFILES := $(REL_PROFILES) $(PKG_PROFILES) default export REBAR_GIT_CLONE_OPTIONS += --depth=1 @@ -60,12 +60,22 @@ else endif @$(REBAR) as $(@) release -# rebar clean +## Not calling rebar3 clean because +## 1. rebar3 clean relies on rebar3, meaning it reads config, fetches dependencies etc. +## 2. it's slow +## NOTE: this does not force rebar3 to fetch new version dependencies +## make clean-all to delete all fetched dependencies for a fresh start-over .PHONY: clean $(PROFILES:%=clean-%) clean: $(PROFILES:%=clean-%) -$(PROFILES:%=clean-%): $(REBAR) - @$(REBAR) as $(@:clean-%=%) clean - @rm -rf apps/emqx_dashboard/priv/www +$(PROFILES:%=clean-%): + @if [ -d _build/$(@:clean-%=%) ]; then \ + rm -rf _build/$(@:clean-%=%)/rel; \ + find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -type f | xargs rm -f; \ + fi + +.PHONY: clean-all +clean-all: + @rm -rf _build .PHONY: deps-all deps-all: $(REBAR) $(PROFILES:%=deps-%) From e495213618ec727a72d02b514b3b66f873f51cee Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sat, 6 Mar 2021 23:12:37 +0100 Subject: [PATCH 2/4] chore(build): Add README for lib-extra --- lib-extra/README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++ lib-extra/plugins | 3 +-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 lib-extra/README.md diff --git a/lib-extra/README.md b/lib-extra/README.md new file mode 100644 index 000000000..3196f4b8c --- /dev/null +++ b/lib-extra/README.md @@ -0,0 +1,50 @@ +# EMQ X Extra plugin apps + +This directory keeps a `plugins` file which defines all the approved +external plugins from open-source community. + +The (maybe broken) symlinks are keept to help testing plugins +in this umbrella project. + +## How to build `plugin_foo` + +Add `plugin_foo` as a rebar3 dependency in `plugins` file. + +e.g. + +``` +{erlang_plugins, + [ {plugin_foo, {git, "https://github.com/bar/plugin-foo.git", {tag, "0.1.0"}}} + ] +}. +``` + +Exeucte command + +``` +export EMQX_EXTRA_PLUGINS='plugin_foo' +make +``` + +The plugin source code should downloaded to `_build/default/lib/plugin_foo` + +NOTE: Shallow clone with depth=1 is used for git dependencies. + +## How to test `plugin_foo` + +If the source code in `_build` is already symlinked from `lib-extra/`, +you may directlly run tests with commands below. + +```bash +./rebar3 eunit --dir lib-extra/plugin_foo +./rebar3 ct --dir lib-extra/plugin_foo +``` + +In case the plugin is being actively developed +it can be cloned to `lib-extra`, e.g. `lib-extra/plugin-bar-dev` +then it can be tested with commands below: + +```bash +./rebar3 eunit --dir lib-extra/plugin-bar-dev +./rebar3 ct --dir lib-extra/plugin-bar-dev +``` diff --git a/lib-extra/plugins b/lib-extra/plugins index 03a360fd9..0f3177b9e 100644 --- a/lib-extra/plugins +++ b/lib-extra/plugins @@ -1,5 +1,4 @@ {erlang_plugins, - [ - {emqx_plugin_template, {git, "https://github.com/emqx/emqx-plugin-template", {branch, "master"}}} + [ {emqx_plugin_template, {git, "https://github.com/emqx/emqx-plugin-template", {branch, "master"}}} ] }. From de6359b5fd57e433d885e1aa947fff6cfd5b18b9 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sun, 7 Mar 2021 09:48:01 +0100 Subject: [PATCH 3/4] chore(ci): find and run plugin tests --- .github/workflows/run_test_cases.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_test_cases.yaml b/.github/workflows/run_test_cases.yaml index 0680ef10a..0a2f13eca 100644 --- a/.github/workflows/run_test_cases.yaml +++ b/.github/workflows/run_test_cases.yaml @@ -40,9 +40,11 @@ jobs: - name: run eunit run: | docker exec -i erlang bash -c "make eunit" - docker exec --env EMQX_EXTRA_PLUGINS=all -i erlang bash -c "./rebar3 eunit --dir lib-extra/*" + docker exec --env EMQX_EXTRA_PLUGINS=all -i erlang bash -c "./rebar3 eunit --dir $(find lib-extra/ -mindepth 1 -maxdepth 2 -type l | tr '\n' ',')" - name: run common test - run: docker exec -i erlang bash -c "make ct" + run: | + docker exec -i erlang bash -c "make ct" + docker exec --env EMQX_EXTRA_PLUGINS=all -i erlang bash -c "./rebar3 ct --dir $(find lib-extra/ -mindepth 1 -maxdepth 2 -type l | tr '\n' ',')" - name: run cover run: | docker exec -i erlang bash -c "make cover" From b7bde35b512d7481f0813f3a1897d4ea2b103e37 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 8 Mar 2021 11:35:15 +0100 Subject: [PATCH 4/4] chore(Makefile): delete .o .d files when make clean --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6470e124c..6ccc2fe8f 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ clean: $(PROFILES:%=clean-%) $(PROFILES:%=clean-%): @if [ -d _build/$(@:clean-%=%) ]; then \ rm -rf _build/$(@:clean-%=%)/rel; \ - find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -type f | xargs rm -f; \ + find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \ fi .PHONY: clean-all