You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2019/11/20 02:25:38 UTC

[incubator-apisix] branch v0.9 updated: change: avoid duplicate code. (#877)

This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch v0.9
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/v0.9 by this push:
     new 6de220d  change: avoid duplicate code. (#877)
6de220d is described below

commit 6de220d3354d940f8fe408514ff992d030ab61cc
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Wed Nov 20 10:25:32 2019 +0800

    change: avoid duplicate code. (#877)
---
 .travis/linux_openresty_runner.sh |  2 +-
 .travis/linux_tengine_runner.sh   |  2 +-
 Makefile                          | 47 ++++++++++++++++-----------------------
 3 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/.travis/linux_openresty_runner.sh b/.travis/linux_openresty_runner.sh
index 872a744..f4c35fd 100755
--- a/.travis/linux_openresty_runner.sh
+++ b/.travis/linux_openresty_runner.sh
@@ -123,7 +123,7 @@ script() {
     ./bin/apisix stop
     sleep 1
 
-    make check || exit 1
+    make linter || exit 1
     APISIX_ENABLE_LUACOV=1 prove -Itest-nginx/lib -r t
 }
 
diff --git a/.travis/linux_tengine_runner.sh b/.travis/linux_tengine_runner.sh
index 4cdb12b..039295b 100755
--- a/.travis/linux_tengine_runner.sh
+++ b/.travis/linux_tengine_runner.sh
@@ -195,7 +195,7 @@ script() {
     sleep 1
     ./bin/apisix stop
     sleep 1
-    make check || exit 1
+    make linter || exit 1
     APISIX_ENABLE_LUACOV=1 prove -Itest-nginx/lib -r t
 }
 
diff --git a/Makefile b/Makefile
index 19bac98..bcfe9f6 100644
--- a/Makefile
+++ b/Makefile
@@ -24,9 +24,15 @@ UNAME ?= $(shell uname)
 OR_EXEC ?= $(shell which openresty)
 LUAROCKS_VER ?= $(shell luarocks --version | grep -E -o  "luarocks [0-9]+.")
 lj-releng-exist = $(shell if [ -f 'utils/lj-releng' ]; then echo "exist"; else echo "not_exist"; fi;)
+LUTJIT_DIR = $(shell ${OR_EXEC} -V 2>&1 | grep prefix | grep -Eo 'prefix=(.*?)/nginx' | grep -Eo '/.*/')luajit
+
 
 .PHONY: default
 default:
+ifeq ($(OR_EXEC), )
+	@echo "OpenResty not found. You have to install OpenResty and add the binary file to PATH before install Apache APISIX."
+	exit 1
+endif
 
 
 ### help:         Show Makefile rules.
@@ -39,33 +45,30 @@ help:
 
 ### deps:         Installation dependencies
 .PHONY: deps
-deps:
-ifeq ($(OR_EXEC), )
-	@echo "OpenResty not found. You have to install OpenResty and add the binary file to PATH before install Apache APISIX."
-	exit 1
-else ifeq ($(UNAME),Darwin)
-	luarocks install --lua-dir=$(shell ${OR_EXEC} -V 2>&1 | grep prefix | grep -Eo 'prefix=(.*?)/nginx' | grep -Eo '/.*/')luajit rockspec/apisix-0.9-0.rockspec --tree=deps --only-deps --local
+deps: default
+ifeq ($(UNAME),Darwin)
+	luarocks install --lua-dir=$(LUTJIT_DIR) rockspec/apisix-0.9-0.rockspec --tree=deps --only-deps --local
 else ifneq ($(LUAROCKS_VER),'luarocks 3.')
 	luarocks install rockspec/apisix-0.9-0.rockspec --tree=deps --only-deps --local
 else
 	luarocks install --lua-dir=/usr/local/openresty/luajit rockspec/apisix-0.9-0.rockspec --tree=deps --only-deps --local
 endif
 
-### utils:        Installation tools
+### utils:        Installation linter tools
 .PHONY: utils
-utils:
+utils: default
 ifeq ($(lj-releng-exist), not_exist)
 	wget -O utils/lj-releng https://raw.githubusercontent.com/iresty/openresty-devel-utils/iresty/lj-releng
 	chmod a+x utils/lj-releng
 endif
 
 
-### check:        Check Lua source code
-.PHONY: check
-check:
+### linter:       Check code style or error
+.PHONY: linter
+linter: default
 	.travis/openwhisk-utilities/scancode/scanCode.py --config .travis/ASF-Release.cfg ./
 	luacheck -q lua
-	./utils/lj-releng lua/*.lua lua/apisix/*.lua \
+	PATH="${LUTJIT_DIR}/bin:${PATH}" ./utils/lj-releng lua/*.lua lua/apisix/*.lua \
 		lua/apisix/admin/*.lua \
 		lua/apisix/core/*.lua \
 		lua/apisix/http/*.lua \
@@ -77,30 +80,22 @@ check:
 
 ### init:         Initialize the runtime environment
 .PHONY: init
-init:
+init: default
 	./bin/apisix init
 	./bin/apisix init_etcd
 
 
 ### run:          Start the apisix server
 .PHONY: run
-run:
+run: default
 	mkdir -p logs
 	mkdir -p /tmp/apisix_cores/
-ifeq ($(OR_EXEC), )
-	@echo "You have to install OpenResty and add the binary file to PATH first"
-	exit 1
-endif
 	$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf
 
 
 ### stop:         Stop the apisix server
 .PHONY: stop
-stop:
-ifeq ($(OR_EXEC), )
-	@echo "You have to install OpenResty and add the binary file to PATH first"
-	exit 1
-endif
+stop: default
 	$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s stop
 
 
@@ -112,11 +107,7 @@ clean:
 
 ### reload:       Reload the apisix server
 .PHONY: reload
-reload:
-ifeq ($(OR_EXEC), )
-	@echo "You have to install OpenResty and add the binary file to PATH first"
-	exit 1
-endif
+reload: default
 	$(OR_EXEC) -p $$PWD/  -c $$PWD/conf/nginx.conf -s reload