forked from adieuadieu/serverless-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
335 lines (315 loc) · 12.9 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
version: 2
#
# Jobs
#
jobs:
# This job builds the base project directory (e.g. ~/package.json)
build:
docker:
- image: circleci/node:6.10.3
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
# This job runs the lint tool on the whole repository
lint:
docker:
- image: circleci/node:8
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}-{{ checksum "packages/lambda/integration-test/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "examples/serverless-framework/aws/package.json" }}
- restore_cache:
key: build-cache-{{ .Revision }}-package-lambda
# need to set permissions on the npm prefix so that we can npm link packages
- run: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- run: ./scripts/link-package.sh packages/serverless-plugin lambda
- run: npm run lint
# This job runs all of the unit tests in the repository
unit_test:
docker:
# Node 8 so we can avoid transpiling our tests
- image: circleci/node:8
# The unit tests require DevTools on localhost:9222
- image: adieuadieu/headless-chromium-for-aws-lambda:stable
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "examples/serverless-framework/aws/package.json" }}
- run:
name: Install Chromium for local development Launcher test
command: sudo apt-get install -y chromium
- run: npm run ava
# This job builds the @serverless-chrome/lambda package
build_lambda:
# use a machine because we extract binaries from Docker images
machine: true
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
- run:
name: Add chromium binary if missing
command: |
cd packages/lambda
if [ ! -f "dist/headless-chromium" ]; then
./scripts/package-binaries.sh chromium stable
cp dist/stable-headless-chromium dist/headless-chromium
fi
- run: cd packages/lambda && npm install
- save_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
paths:
- packages/lambda/node_modules
- packages/lambda/dist/headless-chromium
- packages/lambda/dist/stable-headless-chromium
- run: cd packages/lambda && npm run build
- save_cache:
key: build-cache-{{ .Revision }}-package-lambda
paths:
- packages/lambda/dist
- run: cd packages/lambda/integration-test && npm install
- save_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}-{{ checksum "packages/lambda/integration-test/package.json" }}
paths:
- packages/lambda/node_modules
- packages/lambda/integration-test/node_modules
# This job runs the @serverless-chrome/lambda package's integration tests
integration_test_lambda:
# use a machine because we run the integration tests with Docker (lambci/lambda)
machine: true
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}-{{ checksum "packages/lambda/integration-test/package.json" }}
- restore_cache:
key: build-cache-{{ .Revision }}-package-lambda
- run:
name: Integration test
command: cd packages/lambda && npm test
# This job builds the serverless-plugin package
build_serverless_plugin:
docker:
- image: circleci/node:6.10.3
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
- restore_cache:
key: build-cache-{{ .Revision }}-package-lambda
# need to set permissions on the npm prefix so that we can npm link packages
- run: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- run: ./scripts/link-package.sh packages/serverless-plugin lambda
- run: cd packages/serverless-plugin && npm install
- run: cd packages/serverless-plugin && npm run build
- save_cache:
key: build-cache-{{ .Revision }}-package-serverless-plugin
paths:
- packages/serverless-plugin/dist
- run: |
[ -z "$CIRCLE_TAG" ] || ./scripts/link-package.sh packages/serverless-plugin/integration-test lambda
- run: cd packages/serverless-plugin/integration-test && npm install
- save_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
paths:
- packages/serverless-plugin/node_modules
- packages/serverless-plugin/integration-test/node_modules
# This job runs the serverless-plugin package's integration tests
integration_test_serverless_plugin:
# use a machine because we run the integration tests with Docker (lambci/lambda)
machine: true
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
- restore_cache:
key: build-cache-{{ .Revision }}-package-lambda
- run:
name: Integration test
command: cd packages/serverless-plugin && npm test
# This job builds the serverless-framework AWS example service
build_serverless_example:
docker:
- image: circleci/node:6.10.3
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "examples/serverless-framework/aws/package.json" }}
- restore_cache:
key: build-cache-{{ .Revision }}-package-lambda
- restore_cache:
key: build-cache-{{ .Revision }}-package-serverless-plugin
# need to set permissions on the npm prefix so that we can npm link packages
- run: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- run: ./scripts/link-package.sh packages/serverless-plugin lambda
- run: ./scripts/link-package.sh examples/serverless-framework/aws serverless-plugin
- run: cd examples/serverless-framework/aws && npm install
- save_cache:
key: dependency-cache-{{ checksum "examples/serverless-framework/aws/package.json" }}
paths:
- examples/serverless-framework/aws/node_modules
# This job checks for new versions of browsers (chromium)
# and updates the repository code when new docker images have been built
update_browser_versions:
docker:
- image: circleci/node:6.10.3
branch:
- master
steps:
- checkout
- run: scripts/update-browser-versions.sh
# This job handles release automation. Usually run when new binaries of
# browsers have been built. Only stable-channel binaries will trigger a git tag
# from which we make releases.
release:
# use a machine because we run Docker containers while preparing the release
machine: true
branch:
- master
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/lambda/package.json" }}
- restore_cache:
key: dependency-cache-{{ checksum "packages/serverless-plugin/package.json" }}-{{ checksum "packages/serverless-plugin/integration-test/package.json" }}
# we need a newer version of NPM than is available by default, e.g. >=4
# because we make use of the "prepublishOnly" package.json script, which was introduces in npm@4
- run:
name: Update NPM
command: npm install -g npm@latest
- run: scripts/release.sh
# This step triggers builds of binaries when new versions are available
# The builds happen on AWS Spot Instances created by this step and are not run
# on CircleCI due to instance-size/build-time constraints there.
# AWS Spot Instances are configured by ~/aws/ec2-spot-instance-specification.json.
# On start up, the spot instances run the user-data script in ~/aws/user-data.sh.
# Using "amazonlinux:latest" image because it's easy to install aws-cli.
build_new_binaries:
docker:
- image: amazonlinux:latest
branch:
- master
steps:
- checkout
- run:
name: Install AWS CLI & JQ
command: yum install -y aws-cli jq
- run:
name: Build stable-channel Chromium
command: scripts/ci-daily.sh stable chromium
- run:
name: Build beta-channel Chromium
command: scripts/ci-daily.sh beta chromium
- run:
name: Build dev-channel Chromium
command: scripts/ci-daily.sh dev chromium
#
# Workflows
#
workflows:
version: 2
# Runs on every commit. The jobs install and build dependencies
# and also setup test environments and prerequisites for integration tests
# On tagged commits on master branch, the "release" job automates publishing
# of NPM packages and making a GitHub release. The release and npm packages are published
# by a bot account (botsimo).
build_test_release:
jobs:
- build
- build_lambda:
requires:
- build
- build_serverless_plugin:
requires:
- build_lambda
- build_serverless_example:
requires:
- build_serverless_plugin
- lint:
requires:
- build
- build_lambda
- build_serverless_plugin
- build_serverless_example
- unit_test:
requires:
- build
- build_lambda
- build_serverless_plugin
- build_serverless_example
- integration_test_lambda:
requires:
- build_lambda
- integration_test_serverless_plugin:
requires:
- build_serverless_plugin
- release:
filters:
branches:
only: master
requires:
- lint
- unit_test
- integration_test_lambda
- integration_test_serverless_plugin
# Runs daily at 08:00 UTC. The job checks for new versions of
# headless browsers (chromium) and creates an AWS spot-instance-request
# on which to compile/build any new versions.
# Takes about 2h10m for Chromium 64+ on c5.2xlarge
daily_build:
triggers:
- schedule:
cron: "0 8 * * *"
filters:
branches:
only:
- master
jobs:
- build_new_binaries
# Runs daily at 11:00 UTC. The job checks if any new versions of
# headless browsers (chromium) have been built and updates the repository
# code to point at any new versions. A new stable-channel version will
# trigger an automated release in the "release" job in the build_test_release workflow
daily_version_update:
triggers:
- schedule:
cron: "0 11 * * *"
filters:
branches:
only:
- master
jobs:
- update_browser_versions