-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
210 lines (172 loc) · 6.98 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
$(info starting make in kong)
OS := $(shell uname | awk '{print tolower($$0)}')
MACHINE := $(shell uname -m)
DEV_ROCKS = "busted 2.1.1" "busted-htest 1.0.0" "luacheck 1.0.0" "lua-llthreads2 0.1.6" "http 0.4" "ldoc 1.4.6"
WIN_SCRIPTS = "bin/busted" "bin/kong"
BUSTED_ARGS ?= -v
TEST_CMD ?= bin/busted $(BUSTED_ARGS)
ifeq ($(OS), darwin)
OPENSSL_DIR ?= $(shell brew --prefix)/opt/openssl
GRPCURL_OS ?= osx
YAML_DIR ?= $(shell brew --prefix)/opt/libyaml
else
OPENSSL_DIR ?= /usr
GRPCURL_OS ?= $(OS)
YAML_DIR ?= /usr
endif
ifeq ($(MACHINE), aarch64)
GRPCURL_MACHINE ?= arm64
else
GRPCURL_MACHINE ?= $(MACHINE)
endif
.PHONY: install dependencies dev remove grpcurl \
setup-ci setup-kong-build-tools \
lint test test-integration test-plugins test-all \
pdk-phase-check functional-tests \
fix-windows release
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
KONG_SOURCE_LOCATION ?= $(ROOT_DIR)
KONG_BUILD_TOOLS_LOCATION ?= $(KONG_SOURCE_LOCATION)/../kong-build-tools
RESTY_VERSION ?= `grep RESTY_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_LUAROCKS_VERSION ?= `grep RESTY_LUAROCKS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_OPENSSL_VERSION ?= `grep RESTY_OPENSSL_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_PCRE_VERSION ?= `grep RESTY_PCRE_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_BUILD_TOOLS ?= `grep KONG_BUILD_TOOLS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
GRPCURL_VERSION ?= 1.8.5
OPENRESTY_PATCHES_BRANCH ?= master
KONG_NGINX_MODULE_BRANCH ?= master
PACKAGE_TYPE ?= deb
TAG := $(shell git describe --exact-match --tags HEAD || true)
ifneq ($(TAG),)
ISTAG = true
KONG_TAG = $(TAG)
OFFICIAL_RELEASE = true
else
# we're not building a tag so this is a nightly build
RELEASE_DOCKER_ONLY = true
OFFICIAL_RELEASE = false
ISTAG = false
endif
release-docker-images:
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
package-kong && \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
release-kong-docker-images
release:
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
KONG_TAG=${KONG_TAG} \
package-kong && \
$(MAKE) \
KONG_SOURCE_LOCATION=${KONG_SOURCE_LOCATION} \
RELEASE_DOCKER_ONLY=${RELEASE_DOCKER_ONLY} \
OFFICIAL_RELEASE=$(OFFICIAL_RELEASE) \
KONG_TAG=${KONG_TAG} \
release-kong
setup-ci:
OPENRESTY=$(RESTY_VERSION) \
LUAROCKS=$(RESTY_LUAROCKS_VERSION) \
OPENSSL=$(RESTY_OPENSSL_VERSION) \
OPENRESTY_PATCHES_BRANCH=$(OPENRESTY_PATCHES_BRANCH) \
KONG_NGINX_MODULE_BRANCH=$(KONG_NGINX_MODULE_BRANCH) \
.ci/setup_env.sh
package/deb: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.deb .
package/apk: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.apk.* .
package/rpm: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) package-kong && \
cp $(KONG_BUILD_TOOLS_LOCATION)/output/*.rpm .
package/test/deb: package/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) test
package/test/apk: package/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) test
package/test/rpm: package/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) test
package/docker/deb: package/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) build-test-container
package/docker/apk: package/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) build-test-container
package/docker/rpm: package/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) build-test-container
release/docker/deb: package/docker/deb
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=22.04 $(MAKE) release-kong-docker-images
release/docker/apk: package/docker/apk
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=apk RESTY_IMAGE_BASE=alpine RESTY_IMAGE_TAG=3 $(MAKE) release-kong-docker-images
release/docker/rpm: package/docker/rpm
cd $(KONG_BUILD_TOOLS_LOCATION); \
KONG_SOURCE_LOCATION=$(PWD) PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=rhel RESTY_IMAGE_TAG=8.6 $(MAKE) release-kong-docker-images
setup-kong-build-tools:
-git submodule update --init --recursive
-git submodule status
-rm -rf $(KONG_BUILD_TOOLS_LOCATION)
-git clone https://github.com/Kong/kong-build-tools.git --recursive $(KONG_BUILD_TOOLS_LOCATION)
cd $(KONG_BUILD_TOOLS_LOCATION); \
git reset --hard && git checkout $(KONG_BUILD_TOOLS); \
functional-tests: setup-kong-build-tools
cd $(KONG_BUILD_TOOLS_LOCATION); \
$(MAKE) setup-build && \
$(MAKE) build-kong && \
$(MAKE) test
install:
@luarocks make OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR) YAML_DIR=$(YAML_DIR)
remove:
-@luarocks remove kong
dependencies: bin/grpcurl
@for rock in $(DEV_ROCKS) ; do \
if luarocks list --porcelain $$rock | grep -q "installed" ; then \
echo $$rock already installed, skipping ; \
else \
echo $$rock not found, installing via luarocks... ; \
luarocks install $$rock OPENSSL_DIR=$(OPENSSL_DIR) CRYPTO_DIR=$(OPENSSL_DIR) || exit 1; \
fi \
done;
bin/grpcurl:
@curl -s -S -L \
https://github.com/fullstorydev/grpcurl/releases/download/v$(GRPCURL_VERSION)/grpcurl_$(GRPCURL_VERSION)_$(GRPCURL_OS)_$(GRPCURL_MACHINE).tar.gz | tar xz -C bin;
@rm bin/LICENSE
dev: remove install dependencies
lint:
@luacheck -q .
@!(grep -R -E -I -n -w '#only|#o' spec && echo "#only or #o tag detected") >&2
@!(grep -R -E -I -n -- '---\s+ONLY' t && echo "--- ONLY block detected") >&2
test:
@$(TEST_CMD) spec/01-unit
test-integration:
@$(TEST_CMD) spec/02-integration
test-plugins:
@$(TEST_CMD) spec/03-plugins
test-all:
@$(TEST_CMD) spec/
pdk-phase-checks:
rm -f t/phase_checks.stats
rm -f t/phase_checks.report
PDK_PHASE_CHECKS_LUACOV=1 prove -I. t/01*/*/00-phase*.t
luacov -c t/phase_checks.luacov
grep "ngx\\." t/phase_checks.report
grep "check_" t/phase_checks.report
fix-windows:
@for script in $(WIN_SCRIPTS) ; do \
echo Converting Windows file $$script ; \
mv $$script $$script.win ; \
tr -d '\015' <$$script.win >$$script ; \
rm $$script.win ; \
chmod 0755 $$script ; \
done;