-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
116 lines (103 loc) · 5.63 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# NOTE: Every line in a recipe must begin with a tab character.
BUILD_DIR ?= target
REDIS_VERSION ?= 2.8.6
PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install
TEST_NGINX_AWS_CLIENT_ID ?= ''
TEST_NGINX_AWS_SECRET ?= ''
REDIS_SERVER ?= $(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server
.PHONY: all clean test install
all: ;
install: all
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/key/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/oauth2/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/signing/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/dogstatsd/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/redis/
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/util/
$(INSTALL) src/lua/api-gateway/validation/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/
$(INSTALL) src/lua/api-gateway/validation/key/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/key/
$(INSTALL) src/lua/api-gateway/validation/oauth2/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/oauth2/
$(INSTALL) src/lua/api-gateway/validation/signing/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/validation/signing/
$(INSTALL) src/lua/api-gateway/dogstatsd/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/dogstatsd/
$(INSTALL) src/lua/api-gateway/redis/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/redis/
$(INSTALL) src/lua/api-gateway/util/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/api-gateway/util/
test: redis
echo "Starting redis server on default port"
# $(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server test/resources/redis/redis-test.conf
$(REDIS_SERVER) test/resources/redis/redis-test.conf
echo "updating git submodules ..."
if [ ! -d "test/resources/test-nginx/lib" ]; then git submodule update --init --recursive; fi
echo "running tests ..."
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
rm -f $(BUILD_DIR)/test-logs/*
TEST_NGINX_AWS_CLIENT_ID="${TEST_NGINX_AWS_CLIENT_ID}" TEST_NGINX_AWS_SECRET="${TEST_NGINX_AWS_SECRET}" PATH=/usr/local/sbin:$$PATH TEST_NGINX_SERVROOT=`pwd`/$(BUILD_DIR)/servroot TEST_NGINX_PORT=1989 prove -I ./test/resources/test-nginx/lib -I ./test/resources/test-nginx/inc -r ./test/perl
cat $(BUILD_DIR)/redis-test.pid | xargs kill
redis: all
mkdir -p $(BUILD_DIR)
if [ "$(REDIS_SERVER)" = "$(BUILD_DIR)/redis-$(REDIS_VERSION)/src/redis-server" ]; then \
tar -xf test/resources/redis/redis-$(REDIS_VERSION).tar.gz -C $(BUILD_DIR)/;\
cd $(BUILD_DIR)/redis-$(REDIS_VERSION) && make; \
fi
echo " ... using REDIS_SERVER=$(REDIS_SERVER)"
test-docker:
echo "Running tests with docker, using NO password protection for Redis"
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
sed -i '' 's/127\.0\.0\.1/redis\.docker/g' $(BUILD_DIR)/api-gateway/redis-upstream.conf
rm -f $(BUILD_DIR)/test-logs/*
mkdir -p ~/tmp/apiplatform/api-gateway-request-validation
cp -r ./src ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./test ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./target ~/tmp/apiplatform/api-gateway-request-validation/
cd ./test && docker-compose up
cp -r ~/tmp/apiplatform/api-gateway-request-validation/target/ ./target
rm -rf ~/tmp/apiplatform/api-gateway-request-validation
test-docker-jenkins:
echo "Running tests with docker, using NO password protection for Redis"
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
sed -i '' 's/127\.0\.0\.1/redis\.docker/g' $(BUILD_DIR)/api-gateway/redis-upstream.conf
rm -f $(BUILD_DIR)/test-logs/*
mkdir -p ~/tmp/apiplatform/api-gateway-request-validation
cp -r ./src ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./test ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./target ~/tmp/apiplatform/api-gateway-request-validation/
cd ./test && docker-compose -f docker-compose-jenkins.yml up --force-recreate -d
test-docker-with-password:
echo "running tests with docker, using password protected Redis instance"
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
sed -i '' 's/127\.0\.0\.1/redis\.docker/g' $(BUILD_DIR)/api-gateway/redis-upstream.conf
rm -f $(BUILD_DIR)/test-logs/*
mkdir -p ~/tmp/apiplatform/api-gateway-request-validation
cp -r ./src ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./test ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./target ~/tmp/apiplatform/api-gateway-request-validation/
cd ./test && docker-compose -f docker-compose-with-password.yml up
cp -r ~/tmp/apiplatform/api-gateway-request-validation/target/ ./target
rm -rf ~/tmp/apiplatform/api-gateway-request-validation
test-docker-with-password-jenkins:
echo "running tests with docker, using password protected Redis instance"
mkdir -p $(BUILD_DIR)
mkdir -p $(BUILD_DIR)/test-logs
cp -r test/resources/api-gateway $(BUILD_DIR)
sed -i '' 's/127\.0\.0\.1/redis\.docker/g' $(BUILD_DIR)/api-gateway/redis-upstream.conf
rm -f $(BUILD_DIR)/test-logs/*
mkdir -p ~/tmp/apiplatform/api-gateway-request-validation
cp -r ./src ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./test ~/tmp/apiplatform/api-gateway-request-validation/
cp -r ./target ~/tmp/apiplatform/api-gateway-request-validation/
cd ./test && docker-compose -f docker-compose-with-password-jenkins.yml up --force-recreate -d
package:
git archive --format=tar --prefix=api-gateway-request-validation-1.3.0/ -o api-gateway-request-validation-1.3.0.tar.gz -v HEAD
clean: all
rm -rf $(BUILD_DIR)