Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Makefile for macosX installation about using luajit building deps #217

Merged
merged 8 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ go
\.*
conf/apisix.uid
deps
scgi_temp
uwsgi_temp
proxy_temp
fastcgi_temp
client_body_temp
50 changes: 23 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
os: linux
dist: xenial

sudo: required

matrix:
fast_finish: true
include:
- os: linux
- os: osx
if: branch = master
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew

compiler:
- gcc
- clang

addons:
apt:
packages:
Expand All @@ -17,37 +30,20 @@ addons:
- luarocks
- cmake
- lua-check
homebrew:
update: true

env:
global:
- OPENRESTY_PREFIX=/usr/local/openresty-debug
before_cache:
- brew cleanup

before_install:
- sudo cpanm --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)
- sudo luarocks install --lua-dir=/usr/local/openresty/luajit luacov-coveralls
- ./utils/travis_runner_$TRAVIS_OS_NAME.sh before_install

install:
- wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
- sudo apt-get -y install software-properties-common
- sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
- sudo apt-get update
- sudo apt-get install openresty-debug
- sudo luarocks install --lua-dir=/usr/local/openresty/luajit apisix-*.rockspec --only-deps
- git clone https://github.com/openresty/test-nginx.git test-nginx
- ./utils/travis_runner_$TRAVIS_OS_NAME.sh do_install

script:
- export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH
- sudo service etcd start
- ./bin/apisix help
- ./bin/apisix init
- ./bin/apisix init_etcd
- ./bin/apisix start
- mkdir -p logs
- sleep 1
- ./bin/apisix stop
- sleep 1
- make check || exit 1
- APISIX_ENABLE_LUACOV=1 prove -Itest-nginx/lib -r t
- ./utils/travis_runner_$TRAVIS_OS_NAME.sh script

after_success:
- luacov-coveralls
- ./utils/travis_runner_$TRAVIS_OS_NAME.sh after_success
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ INST_LUADIR ?= $(INST_PREFIX)/share/lua/5.1
INST_BINDIR ?= /usr/bin
INSTALL ?= install
UNAME ?= $(shell uname)
OR_EXEC ?= $(shell which openresty)
LUA_JIT_DIR ?= $(shell TMP='./v_tmp' && $(OR_EXEC) -V &>$${TMP} && cat $${TMP} | grep prefix | grep -Eo 'prefix=(.*?)/nginx' | grep -Eo '/.*/' && rm $${TMP})luajit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'./v_tmp' -> '/tmp/v_tmp', how about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't make any sense, the v_tmp file will been clean immediately at the end of this command.



.PHONY: default
Expand All @@ -23,7 +25,7 @@ help:
dev:
./utils/update_nginx_conf_dev.sh
ifeq ($(UNAME),Darwin)
luarocks install --lua-dir=/usr/local/openresty/luajit apisix-*.rockspec --tree=deps --only-deps
luarocks install --lua-dir=$(LUA_JIT_DIR) apisix-*.rockspec --tree=deps --only-deps
else
sudo luarocks install --lua-dir=/usr/local/openresty/luajit apisix-*.rockspec --tree=deps --only-deps
endif
Expand Down Expand Up @@ -52,13 +54,13 @@ init:
run:
mkdir -p logs
mkdir -p /tmp/cores/
$$(which openresty) -p $$PWD/ -c $$PWD/conf/nginx.conf
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf


### stop: Stop the apisix server
.PHONY: stop
stop:
$$(which openresty) -p $$PWD/ -c $$PWD/conf/nginx.conf -s stop
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s stop


### clean: Remove generated files
Expand All @@ -70,7 +72,7 @@ clean:
### reload: Reload the apisix server
.PHONY: reload
reload:
$$(which openresty) -p $$PWD/ -c $$PWD/conf/nginx.conf -s reload
$(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s reload


### install: Install the apisix
Expand Down Expand Up @@ -101,4 +103,8 @@ install:
$(INSTALL) bin/apisix $(INST_BINDIR)/apisix

test:
ifeq ($(UNAME),Darwin)
prove -I../test-nginx/lib -I./ -r -s t/
else
prove -I../test-nginx/lib -r -s t/
endif
74 changes: 74 additions & 0 deletions utils/travis_runner_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

### BEGIN ###
# Author: idevz
# Since: 08:52:47 2019/07/08
# Description: travis_runnerz_linux.sh
# travis_runner_linux ./travis_runner_linux.sh
#
# Environment variables that control this script:
#
### END ###

set -ex

export_or_prefix() {
export OPENRESTY_PREFIX="/usr/local/openresty-debug"
}

before_install() {
sudo cpanm --notest Test::Nginx IPC::Run >build.log 2>&1 || (cat build.log && exit 1)
sudo luarocks install --lua-dir=/usr/local/openresty/luajit luacov-coveralls
}

do_install() {
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install openresty-debug

export_or_prefix

sudo luarocks install --lua-dir=${OPENRESTY_PREFIX}luajit apisix-*.rockspec --only-deps

git clone https://github.com/openresty/test-nginx.git test-nginx
}

script() {
export_or_prefix
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH
sudo service etcd start
./bin/apisix help
./bin/apisix init
./bin/apisix init_etcd
./bin/apisix start
mkdir -p logs
sleep 1
./bin/apisix stop
sleep 1
make check || exit 1
APISIX_ENABLE_LUACOV=1 prove -Itest-nginx/lib -r t
}

after_success() {
luacov-coveralls
}

case_opt=$1
shift

case ${case_opt} in
before_install)
before_install "$@"
;;
do_install)
do_install "$@"
;;
script)
script "$@"
;;
after_success)
after_success "$@"
;;
esac
83 changes: 83 additions & 0 deletions utils/travis_runner_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

### BEGIN ###
# Author: idevz
# Since: 08:52:47 2019/07/08
# Description: travis_runner_osx.sh
# travis_runner_osx ./travis_runner_osx.sh
#
# Environment variables that control this script:
#
### END ###

set -ex

export_or_prefix() {
export OPENRESTY_PREFIX=$(TMP='./v_tmp' && $(which openresty) -V &>${TMP} &&
cat ${TMP} | grep prefix | grep -Eo 'prefix=(.*?)/nginx' |
grep -Eo '/.*/' && rm ${TMP})
}

before_install() {
HOMEBREW_NO_AUTO_UPDATE=1 brew install perl cpanminus etcd luarocks openresty/brew/openresty-debug tree
sudo cpanm --notest Test::Nginx IPC::Run >build.log 2>&1 || (cat build.log && exit 1)
export_or_prefix
luarocks install --lua-dir=${OPENRESTY_PREFIX}luajit luacov-coveralls --local --tree=deps
}

do_install() {
export_or_prefix

make dev

git clone https://github.com/openresty/test-nginx.git test-nginx
}

script() {
export_or_prefix
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH

luarocks install luacheck
brew services start etcd
make help
make init
sudo make run
mkdir -p logs
sleep 1
sudo make stop

sudo cpanm Test::Nginx

sleep 1
make check || exit 1

ln -sf $PWD/deps/lib $PWD/deps/lib64
sudo mkdir -p /usr/local/var/log/nginx/
sudo touch /usr/local/var/log/nginx/error.log
sudo chmod 777 /usr/local/var/log/nginx/error.log
APISIX_ENABLE_LUACOV=1 prove -Itest-nginx/lib -I./ -r t
# cat $PWD/t/servroot/conf/nginx.conf
# cat /usr/local/var/log/nginx/error.log
}

after_success() {
$PWD/deps/bin/luacov-coveralls
}

case_opt=$1
shift

case ${case_opt} in
before_install)
before_install "$@"
;;
do_install)
do_install "$@"
;;
script)
script "$@"
;;
after_success)
after_success "$@"
;;
esac