-
Notifications
You must be signed in to change notification settings - Fork 169
/
config.yml
314 lines (278 loc) · 7.88 KB
/
config.yml
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
perl-cache-paths: &perl-cache-paths
paths:
- ./local
- ./vendor/cache
- ./.cpanm
lua-cache-paths: &lua-cache-paths
paths:
- ./lua_modules
# ------------------------------------------------------------------------
version: 2.1
commands:
restore-lua-cache:
steps:
- restore_cache:
keys:
- apicast-rocks-v2.13-{{ arch }}-{{ checksum "gateway/Roverfile.lock" }}
- apicast-rocks-v2.13-{{ arch }}-{{ .Branch }}
- apicast-rocks-v2.13-{{ arch }}-master
restore-perl-cache:
steps:
- restore_cache:
keys:
- apicast-cpanm-v2-{{ arch }}-{{ checksum "gateway/cpanfile.snapshot" }}
- apicast-cpanm-v2-{{ arch }}-{{ .Branch }}
- apicast-cpanm-v2-{{ arch }}-master
install-docker-compose:
steps:
- run: |
pip install "docker-compose==${DOCKER_COMPOSE_VERSION}"
docker-compose version
setup-docker:
steps:
- setup_remote_docker:
docker_layer_caching: true
attach-workspace:
steps:
- checkout
- attach_workspace:
at: .
setup-build-env:
steps:
- run: apk update && apk add wget make bash curl py-pip git openssh-client
- install-docker-compose
- setup-docker
- attach-workspace
store-junit-results:
steps:
- store_test_results:
path: tmp/junit
- store_artifacts:
path: tmp/junit
destination: junit
report-codecov:
parameters:
suite:
type: string
flags:
type: string
default: ""
steps:
- run:
name: Report << parameters.suite >> Code Coverage
command: |
set +x # allow failures
curl -s https://codecov.io/bash | bash -s - << parameters.flags >> -F << parameters.suite >>
when: always
login-docker:
parameters:
command:
type: string
steps:
- deploy:
name: "Push image to the container registry"
command: |
if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_REGISTRY}" ]
then
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}" "${DOCKER_REGISTRY}";
sh -ec '<< parameters.command >>'
echo "Successfully pushed image to ${DOCKER_REGISTRY}"
else
echo "Skipping docker registry push."
fi
cleanup-docker:
steps:
- run:
name: "Cleanup docker images"
command: docker system prune -f
when: always
executors:
docker:
working_directory: /opt/app-root/apicast
docker:
- image: docker:stable
environment:
COMPOSE_TLS_VERSION: "TLSv1_2"
DOCKER_COMPOSE_VERSION: "1.16.1"
openresty:
working_directory: /opt/app-root/apicast
docker:
- image: quay.io/3scale/apicast-ci:openresty-1.19.3-23
- image: redis:3.2.8-alpine
environment:
TEST_NGINX_BINARY: openresty
LUA_BIN_PATH: /opt/app-root/bin
jobs:
# Build the runtime image and run smoke tests
build-runtime-image:
executor: docker
environment:
IMAGE_NAME: apicast-runtime-image
steps:
- setup-build-env
- run:
command: |
docker rmi --no-prune ${IMAGE_NAME} 2>/dev/null || :
make runtime-image
- run: make test-runtime-image gateway-logs --keep-going
- login-docker:
command: |
CIRCLE_BRANCH_LOWER=`echo $CIRCLE_BRANCH | tr '[:upper:]' '[:lower:]'`
IMAGE_TAG="${CIRCLE_TAG:-${CIRCLE_BRANCH_LOWER}}"
if [ "${IMAGE_TAG}" == "master" ]
then
IMAGE_TAG="latest"
fi
IMAGE_NAME="apicast:${IMAGE_TAG}"
docker tag apicast-runtime-image ${IMAGE_NAME}
make push
- cleanup-docker
# Build the development image
build-development-image:
executor: docker
environment:
DEVEL_IMAGE: apicast-development
steps:
- setup-build-env
- run:
name: "Build development image"
command: |
docker rmi --no-prune ${DEVEL_IMAGE} 2>/dev/null || :
make dev-build
- cleanup-docker
# Download, build and store Lua dependencies.
build-lua:
executor: openresty
steps:
- checkout
- run:
# This can happen when doing local build: lua_modules is copied from the host
name: Cleanup local dependencies
command: rm -rf lua_modules
- restore-lua-cache
- run: make lua_modules
- save_cache:
key: apicast-rocks-v2.13-{{ arch }}-{{ checksum "gateway/Roverfile.lock" }}
<<: *lua-cache-paths
- persist_to_workspace:
root: .
<<: *lua-cache-paths
# Download, build and store Perl dependencies.
build-perl:
executor: openresty
steps:
- checkout
- restore-perl-cache
- run: make carton
- save_cache:
key: apicast-cpanm-v2-{{ arch }}-{{ checksum "gateway/cpanfile.snapshot" }}
<<: *perl-cache-paths
- persist_to_workspace:
root: .
<<: *perl-cache-paths
# Run unit tests (busted)
busted:
executor: openresty
parallelism: 1
steps:
- attach-workspace
- run:
name: 'busted'
command: $(make rover) exec make busted
environment:
JUNIT_OUTPUT_FILE: tmp/junit/busted/report.xml
- report-codecov:
suite: busted
- store-junit-results
# Generate documentation
docs:
executor: openresty
steps:
- attach-workspace
- run: make doc
- store_artifacts:
path: doc/lua
destination: doc
# Run integration tests
prove:
executor: openresty
resource_class: medium+
parallelism: 3
steps:
- attach-workspace
- run:
name: 'prove'
command: make prove
environment:
JUNIT_OUTPUT_FILE: tmp/junit/prove/report.xml
TEST_NGINX_ERROR_LOG: tmp/junit/prove/error.log
HARNESS: TAP::Harness::JUnit
- report-codecov:
suite: prove
flags: -f 'luacov.report.*.out'
- store-junit-results
# Run benchmark on master and this branch
benchmark:
machine: true
steps:
- checkout
- run: IMAGE_TAG=`echo $CIRCLE_BRANCH | tr '[:upper:]' '[:lower:]'` make benchmark
- run: IMAGE_TAG=master make benchmark
- store_artifacts:
path: tmp/benchmark
destination: benchmark
# Run profiling tasks
profile:
machine: true
steps:
- attach-workspace
- run: sudo --preserve-env script/install/circleci.sh
- run: sudo --preserve-env script/install/utilities.sh
- run: script/install/apicast.sh
- run: sudo lua script/profiling/profile.lua
- store_artifacts:
path: tmp/profile
destination: profile
build-tags: &build-tags
filters:
tags:
only: /.*/
ignore-forks: &ignore-forks
branches:
ignore: '/pull\/\d+/' # forks branch name is pull/PR_NUMBER
workflows:
version: 2
build-test-deploy:
jobs:
- build-lua:
<<: *build-tags
- build-perl:
<<: *build-tags
- busted:
<<: *build-tags
requires:
- build-lua
- prove:
<<: *build-tags
requires:
- build-lua
- build-perl
- docs:
<<: *build-tags
requires:
- build-lua
- build-development-image:
<<: *build-tags
- build-runtime-image:
<<: *build-tags
context: org-global
requires:
- build-lua
- build-perl
## Commented until we figure out why on many runs there are only a few requests
## using luaJIT traces: https://github.com/3scale/APIcast/issues/1096
# - profile:
# <<: *build-tags
# requires:
# - build-lua
# - build-perl