Skip to content

Commit

Permalink
Merge pull request Kong#54 from Mashape/feature/simpler-travis
Browse files Browse the repository at this point in the history
Simpler travis setup test
  • Loading branch information
thibaultcha committed Mar 4, 2015
2 parents 7094624 + 3969dcc commit 36c6666
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 24 deletions.
28 changes: 9 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
language: erlang

env:
- LUA=""
global:
- LUAROCKS=2.2.0
- OPENRESTY=1.7.7.2
- CASSANDRA=2.1.2
matrix:
- LUA=lua5.1

branches:
only:
- master

before_install:
- sudo apt-get update
- sudo apt-get install libreadline-dev libncurses5-dev libpcre3 libpcre3-dev libssl-dev perl make lua5.1 lua5.1-dev
- wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
- tar xzf ngx_openresty-1.7.7.2.tar.gz
- cd ngx_openresty-1.7.7.2/
- ./configure
- make
- sudo make install
- cd ..
- bash .travis/setup_lua.sh
- bash .travis/setup_openresty.sh
- export PATH=$PATH:/usr/local/openresty/nginx/sbin
- wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
- tar xzf luarocks-2.2.0.tar.gz
- cd luarocks-2.2.0
- ./configure
- make build
- sudo make install
- cd ..
- sudo rm -rf /var/lib/cassandra/*
- wget http://www.us.apache.org/dist/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz && tar -xvzf apache-cassandra-2.1.2-bin.tar.gz && sudo sh apache-cassandra-2.1.2/bin/cassandra
- bash .travis/setup_cassandra.sh

install:
- sudo make install
Expand Down
15 changes: 15 additions & 0 deletions .travis/platform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ -z "$PLATFORM" ]; then
PLATFORM=$TRAVIS_OS_NAME;
fi

if [ "$PLATFORM" == "osx" ]; then
PLATFORM="macosx";
fi

if [ -z "$PLATFORM" ]; then
if [ "$(uname)" == "Linux" ]; then
PLATFORM="linux";
else
PLATFORM="macosx";
fi;
fi
7 changes: 7 additions & 0 deletions .travis/setup_cassandra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

CASSANDRA_BASE=apache-cassandra-$CASSANDRA

sudo rm -rf /var/lib/cassandra/*
curl http://www.us.apache.org/dist/cassandra/2.1.2/$CASSANDRA_BASE-bin.tar.gz | tar xz
sudo sh $CASSANDRA_BASE/bin/cassandra
101 changes: 101 additions & 0 deletions .travis/setup_lua.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#! /bin/bash

# A script for setting up environment for travis-ci testing.
# Sets up Lua and Luarocks.
# LUA must be "lua5.1", "lua5.2" or "luajit".
# luajit2.0 - master v2.0
# luajit2.1 - master v2.1

LUAJIT_BASE="LuaJIT-2.0.3"

source .travis/platform.sh

LUAJIT="no"

if [ "$PLATFORM" == "macosx" ]; then
if [ "$LUA" == "luajit" ]; then
LUAJIT="yes";
fi
if [ "$LUA" == "luajit2.0" ]; then
LUAJIT="yes";
fi
if [ "$LUA" == "luajit2.1" ]; then
LUAJIT="yes";
fi;
elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then
LUAJIT="yes";
fi

if [ "$LUAJIT" == "yes" ]; then

if [ "$LUA" == "luajit" ]; then
curl http://luajit.org/download/$LUAJIT_BASE.tar.gz | tar xz;
else
git clone http://luajit.org/git/luajit-2.0.git $LUAJIT_BASE;
fi

cd $LUAJIT_BASE

if [ "$LUA" == "luajit2.1" ]; then
git checkout v2.1;
fi

make && sudo make install

if [ "$LUA" == "luajit2.1" ]; then
sudo ln -s /usr/local/bin/luajit-2.1.0-alpha /usr/local/bin/luajit
sudo ln -s /usr/local/bin/luajit /usr/local/bin/lua;
else
sudo ln -s /usr/local/bin/luajit /usr/local/bin/lua;
fi;

else
if [ "$LUA" == "lua5.1" ]; then
curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
cd lua-5.1.5;
elif [ "$LUA" == "lua5.2" ]; then
curl http://www.lua.org/ftp/lua-5.2.3.tar.gz | tar xz
cd lua-5.2.3;
elif [ "$LUA" == "lua5.3" ]; then
curl http://www.lua.org/ftp/lua-5.3.0.tar.gz | tar xz
cd lua-5.3.0;
fi
sudo make $PLATFORM install;
fi

cd $TRAVIS_BUILD_DIR;

LUAROCKS_BASE=luarocks-$LUAROCKS

# curl http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz

git clone https://github.com/keplerproject/luarocks.git $LUAROCKS_BASE
cd $LUAROCKS_BASE

git checkout v$LUAROCKS

if [ "$LUA" == "luajit" ]; then
./configure --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.0;
elif [ "$LUA" == "luajit2.0" ]; then
./configure --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.0;
elif [ "$LUA" == "luajit2.1" ]; then
./configure --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.1;
else
./configure;
fi

make build && sudo make install

cd $TRAVIS_BUILD_DIR

rm -rf $LUAROCKS_BASE

if [ "$LUAJIT" == "yes" ]; then
rm -rf $LUAJIT_BASE;
elif [ "$LUA" == "lua5.1" ]; then
rm -rf lua-5.1.5;
elif [ "$LUA" == "lua5.2" ]; then
rm -rf lua-5.2.3;
elif [ "$LUA" == "lua5.3" ]; then
rm -rf lua-5.3.0;
fi
12 changes: 12 additions & 0 deletions .travis/setup_openresty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/bash

OPENRESTY_BASE=ngx_openresty-$OPENRESTY

sudo apt-get update && sudo apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make

curl http://openresty.org/download/$OPENRESTY_BASE.tar.gz | tar xz
cd $OPENRESTY_BASE
./configure
make && sudo make install
cd $TRAVIS_BUILD_DIR
rm -rf $OPENRESTY_BASE
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ KONG_HOME = `pwd`
export SILENT_FLAG ?=
export COVERAGE_FLAG ?=

# Tests variables
TESTS_CONF ?= kong_TEST.yml
DEVELOPMENT_CONF ?= kong_DEVELOPMENT.yml

Expand Down
6 changes: 3 additions & 3 deletions bin/kong
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function show_help {
printf "Usage: kong [OPTION]... {start|stop|restart|migrate}\n
\t-c specify the path to a custom Kong configuration file
\t default is: '$KONG_HOME/kong.yml'
\t-v output version information and exit
\t-h show the help
\nCommands available:\n
\t-v output version informations and exit
\t-h show this message
\nCommands:\n
\tstart start Kong
\tstop stop a running Kong
\trestart restart Kong
Expand Down
2 changes: 1 addition & 1 deletion scripts/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local Faker = require "kong.tools.faker"
local Migrations = require "kong.tools.migrations"

cli:set_name("db.lua")
cli:add_argument("COMMAND", "<create|migrate|rollback|reset|seed|drop>")
cli:add_argument("COMMAND", "{create|migrate|rollback|reset|seed|drop}")
cli:add_option("-c, --config=CONFIG", "configuration file", "kong.yml")
cli:add_option("-n, --name=NAME", "If <create>, sets a name to the migration", "new_migration")
cli:add_flag("-r, --random", "If seeding, also seed random entities (1000 for each collection by default)")
Expand Down

0 comments on commit 36c6666

Please sign in to comment.