فهرست منبع

Merge pull request #4300 from zmstone/chore-makefile-clean-target

Chore makefile clean target
Zaiming Shi 5 سال پیش
والد
کامیت
72f5468001
4فایلهای تغییر یافته به همراه70 افزوده شده و 9 حذف شده
  1. 4 2
      .github/workflows/run_test_cases.yaml
  2. 15 5
      Makefile
  3. 50 0
      lib-extra/README.md
  4. 1 2
      lib-extra/plugins

+ 4 - 2
.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"

+ 15 - 5
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' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \
+	fi
+
+.PHONY: clean-all
+clean-all:
+	@rm -rf _build
 
 .PHONY: deps-all
 deps-all: $(REBAR) $(PROFILES:%=deps-%)

+ 50 - 0
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
+```

+ 1 - 2
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"}}}
   ]
 }.