-
Notifications
You must be signed in to change notification settings - Fork 0
/
wercker.yml
305 lines (290 loc) · 9.42 KB
/
wercker.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
source-dir: src
box:
id: iad.ocir.io/odx-pipelines/wercker/node12-instantclient12-2
tag: 1.0
registry: https://iad.ocir.io/v2
username: ${OCIR_USERNAME}
password: ${OCIR_PASSWORD}
no-response-timeout: 10
dev:
box:
id: quay.io/wercker/wercker-dev:$WERCKER_GIT_BRANCH
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
registry: quay.io
services:
- mongo:3.2
steps:
- add-ssh-key:
keyname: WERCKER_COMMON
host: github.com
- script:
name: setup env
code: |
export WERCKER_MONGODB_HOST=${MONGO_PORT:6}
export mongodbUrl="mongodb://$WERCKER_MONGODB_HOST/wercker"
export PATH=$PATH:$WERCKER_SOURCE_DIR/node_modules/.bin/
export NODE_ENV=development
rm -rf ./node_modules
ln -s /dist/node_modules ./
- script:
name: fetch and install mongo fixtures
code: |
./load_fixtures.sh
- internal/shell:
code: |
yarn start
- script:
name: cleanup symlinks
code: |
rm ./node_modules
build:
services:
- mongo:3.2
steps:
- script:
name: restore cache-loader folder
code: |
echo "Contents of the cache dir"
du -h -d1 $WERCKER_CACHE_DIR
ls -p | grep -v /
# copy previous cache-loader folder over if exists
if [ -f "$WERCKER_CACHE_DIR/.cache-loader" ]; then
echo ".cache-loader folder restored!"
mv "$WERCKER_CACHE_DIR/.cache-loader" .
fi
- add-ssh-key:
keyname: WERCKER_COMMON
host: github.com
- add-to-known_hosts:
hostname: github.com
fingerprint: nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
- script:
name: update git submodules
code: |
cd ..
git submodule update --init --recursive
- script:
name: yarn install
code: |
yarn --pure-lockfile --cache-folder $WERCKER_CACHE_DIR
cp yarn.lock $WERCKER_REPORT_ARTIFACTS_DIR
- script:
name: lint formatting
code: |
yarn run prettier-lint
- script:
name: lint code
code: |
yarn run lint
- script:
name: run flow
code: |
yarn run flow
- script:
name: check licenses
code: yarn run license-check
- script:
name: compile hbs helpers for emails
code: |
# this compilation is required to ensure tests succeed
yarn run build-helpers
- script:
name: nodeunit tests
code: |
export WERCKER_MONGODB_HOST=${MONGO_PORT:6}
export mongodbUrl="mongodb://$WERCKER_MONGODB_HOST/werckerunittest"
export PATH=$PATH:$WERCKER_SOURCE_DIR/node_modules/.bin
NODE_ENV=test nodeunit test lib/wercker-common/test
- script:
name: run front-end tests
code: |
yarn run frontend-test
- script:
name: test local_modules
code: NODE_ENV=test tap --color local_modules/*/test.js
- script:
name: bundle static assets
code: |
if [ -f "$WERCKER_CACHE_DIR/.cache-loader" ]; then
# copy previous records.json over if exists
cp "$WERCKER_CACHE_DIR/records.json" ./config
fi
# run yarn bulde
yarn run bundle
mv report.html stats.json $WERCKER_REPORT_ARTIFACTS_DIR
if [ -f "$WERCKER_CACHE_DIR/.cache-loader" ]; then
# remove previous records.json if exists
rm "$WERCKER_CACHE_DIR/records.json"
fi
# Copy records.json to cache
mv config/records.json $WERCKER_CACHE_DIR
- script:
name: compile server-side jsx code
code: |
yarn run build-server
- script:
name: store/move cache-loader to cache
code: |
rm -rf $WERCKER_CACHE_DIR/.cache-loader
mv .cache-loader $WERCKER_CACHE_DIR
echo "Contents of the cache dir"
du -h -d1 $WERCKER_CACHE_DIR
ls -p | grep -v /
integration:
services:
- mongo:3.2
steps:
- script:
name: Add chrome to package list
code: |
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main"| sudo tee -a /etc/apt/sources.list
curl https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
apt-get update
- install-packages:
name: install system dependencies
packages: libfreetype6 libfontconfig ssh xserver-common xvfb google-chrome-stable netcat
- script:
name: setup display
code: |
export DISPLAY=:99.0
start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1280x1024x24 -ac +extension GLX +render -noreset
- script:
name: ui test
code: |
export WERCKER_MONGODB_HOST=${MONGO_PORT:6}
export mongodbUrl="mongodb://$WERCKER_MONGODB_HOST/werckertest"
export MONGODB_NAME="werckertest"
export NODE_ENV="development"
node app.js &
node test-ui/pre.js
echo "waiting for server to be ready"
while ! nc -vz localhost 3000; do sleep 0.3; done
sleep 3
yarn run test-ui
- script:
name: move to output dir
code: mv $WERCKER_ROOT/src $WERCKER_ROOT/deployment $WERCKER_OUTPUT_DIR
clean:
steps:
- script:
name: cleanup
code: rm -rf $WERCKER_SOURCE_DIR/.bundle/ $WERCKER_SOURCE_DIR/vendor/
- script:
name: cleanup dev dependencies
code: |
yarn install --prod --pure-lockfile --cache-folder $WERCKER_CACHE_DIR
cp yarn.lock $WERCKER_REPORT_ARTIFACTS_DIR
- script:
name: move to output dir
code: |
mv $WERCKER_ROOT/src $WERCKER_ROOT/deployment $WERCKER_OUTPUT_DIR
sync-cdn:
steps:
- script:
name: change static structure to match cdn layout
code: |
mkdir -p public/cdn/web
cp -R public/out/* public/cdn/web
- s3sync:
key-id: $AWS_ACCESS_S3_KEY_ID
key-secret: $AWS_ACCESS_S3_KEY_SECRET
bucket-url: $AWS_S3_BUCKET_URL
source_dir: src/public/cdn/
delete-removed: false
opts: --acl-public --add-header=Cache-Control:max-age=315360000
- script:
name: cleanup
code: |
rm -rf public/cdn
push-quay:
steps:
- script:
name: fetch wercker-specific dev dependencies
code: |
mkdir -p /dist
curl -o /dist/mhook https://s3.amazonaws.com/wercker-development/mhook/master/latest/linux_amd64/build
chmod +x /dist/mhook
- script:
name: move node modules to global dir
code: |
mkdir -p /dist
mv ./node_modules /dist/node_modules
ln -s /dist/node_modules ./node_modules
- internal/docker-push:
repository: quay.io/wercker/web-service
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
registry: quay.io
tag: ${WERCKER_GIT_BRANCH},${WERCKER_GIT_BRANCH}-${WERCKER_GIT_COMMIT}
working-dir: /pipeline/source/src
user: 1000
entrypoint: >
/bin/bash -c
"mongodbUrl=\"mongodb://\$MONGODB_PORT_27017_TCP_ADDR:\$MONGODB_PORT_27017_TCP_PORT/wercker\"
/pipeline/source/src/app.js"
- script:
name: move to output dir
code: |
mv $WERCKER_ROOT/src $WERCKER_ROOT/deployment $WERCKER_OUTPUT_DIR
push-quay-static:
box:
id: nginx:stable-alpine
cmd: /bin/sh
steps:
- script:
name: cleanup /usr/share/nginx/html
code: rm -rf /usr/share/nginx/html/*
- script:
name: move static files to /usr/share/nginx/html
code: mv $WERCKER_SOURCE_DIR/public /usr/share/nginx/html
- script:
name: setup nginx.config
code: |
rm /etc/nginx/conf.d/*
mv $WERCKER_ROOT/deployment/nginx.conf /etc/nginx/conf.d/
- script:
name: cleanup source dir
code: |
rm -rf $WERCKER_SOURCE_DIR
mkdir -p $WERCKER_SOURCE_DIR
- internal/docker-push:
repository: quay.io/wercker/web-static
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
registry: quay.io
tag: ${WERCKER_GIT_BRANCH},${WERCKER_GIT_BRANCH}-${WERCKER_GIT_COMMIT}
cmd: nginx -g 'daemon off;'
kube-deploy:
steps:
- script:
name: backup k8s template files
code: |
cp -r $WERCKER_ROOT/deployment $WERCKER_ROOT/deployment_original
- script:
name: prepare environment variables
code: |
export TPL_STRIPE_PUBLISHABLE_KEY_BASE64=$(printf "$TPL_STRIPE_PUBLISHABLE_KEY" | base64 -w 0)
- termie/bash-template:
name: render templates
cwd: $WERCKER_ROOT/deployment
input: "*.template.yml"
- script:
name: merge kubernetes files
cwd: $WERCKER_ROOT/deployment
code: |
rm *.template.yml
cat *.yml > web.yml
cp *.yml $WERCKER_REPORT_ARTIFACTS_DIR/
- kubectl:
name: deploy to kubernetes
cwd: $WERCKER_ROOT/deployment
server: $KUBE_URL
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: apply -f web.yml
- script:
name: restore k8s template files
code: |
rm -rf $WERCKER_ROOT/deployment
mv $WERCKER_ROOT/deployment_original $WERCKER_ROOT/deployment