forked from Automattic/wp-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
423 lines (406 loc) · 12.8 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
version: 2
references:
restore_nvm: &restore_nvm
restore_cache:
name: Restoring NVM cache
keys:
- nvm-0-33-11-{{ arch }}-{{ checksum "calypso/.nvmrc" }}
- nvm-0-33-11-{{ arch }}
setup_nvm: &setup_nvm
run:
name: Install nvm and calypso node version
command: |
set +e
set +u
set +x
NODE_VERSION=$(cat calypso/.nvmrc)
export NVM_DIR="${HOME}/.nvm"
mkdir -p "$NVM_DIR"
if [ ! -f "${NVM_DIR}/nvm.sh" ]; then
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
fi
[ -s "${NVM_DIR}/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install "$NODE_VERSION"
nvm alias default "$NODE_VERSION"
nvm use "$NODE_VERSION"
save_nvm: &save_nvm
save_cache:
name: Saving NVM cache
key: nvm-0-33-11-{{ arch }}-{{ checksum "calypso/.nvmrc" }}
paths:
- ~/.nvm
npm_restore_cache: &npm_restore_cache
restore_cache:
name: Restore npm cache
keys:
- v1-npm-{{ arch }}-{{ checksum "calypso/.nvmrc" }}-{{ checksum "package-lock.json" }}-{{ checksum "calypso/npm-shrinkwrap.json" }}
- v1-npm-{{ arch }}-{{ checksum "calypso/.nvmrc" }}-{{ checksum "package-lock.json" }}
- v1-npm-{{ arch }}-{{ checksum "calypso/.nvmrc" }}
npm_save_cache: &npm_save_cache
save_cache:
name: Save npm cache
key: v1-npm-{{ arch }}-{{ checksum "calypso/.nvmrc" }}-{{ checksum "package-lock.json" }}-{{ checksum "calypso/npm-shrinkwrap.json" }}
paths:
- ~/.npm
app_cache_paths: &app_cache_paths
- calypso-hash
- build
- resource/certificates/win.p12
- resource/certificates/mac.p12
- calypso/public
- calypso/server
- calypso/config
- calypso/package.json
- calypso/packages
- calypso/npm-shrinkwrap.json
- calypso/.nvmrc
calypso_prepare_cache: &calypso_prepare_cache
run:
name: Prepare calypso cache
command: |
if [ -n "${CALYPSO_HASH}" ]; then
# cache bust e2e tests
uuidgen > calypso-current-hash
else
git rev-parse @:./calypso > calypso-current-hash
fi
calypso_restore_cache: &calypso_restore_cache
restore_cache:
name: Restore calypso cache
keys:
- v3-calypso-{{ arch }}-{{ checksum "calypso-current-hash" }}
calypso_finalize_cache: &calypso_finalize_cache
run:
name: Finalize calypso cache
command: |
if [ "$(cat calypso-current-hash)" != "$(cat calypso-hash)" ]; then
cp calypso-current-hash calypso-hash
fi
calypso_save_cache: &calypso_save_cache
save_cache:
name: Save calypso cache
key: v3-calypso-{{ arch }}-{{ checksum "calypso-current-hash" }}
paths: *app_cache_paths
webhook_notify_success: &webhook_notify_success
run:
name: Notify webhook of successful build
when: on_success
command: |
set +o errexit
if [[ $CIRCLE_BRANCH != "tests/"* ]]; then
exit
fi
curl -X POST "https://a8c-gh-desktop-bridge.go-vip.co/circleciwebhook" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"payload": {
"outcome": "'"success"'",
"status": "'"success"'",
"branch": "'"$BRANCHNAME"'",
"build_url": "'"$CIRCLE_BUILD_URL"'",
"build_parameters": {
"build_num": '"$CIRCLE_BUILD_NUM"',
"sha": "'"$sha"'",
"calypsoProject": "'"$calypsoProject"'"
}
}
}'
webhook_notify_failed: &webhook_notify_failed
run:
name: Notify webhook of failed build
when: on_fail
command: |
set +o errexit
if [[ $BRANCHNAME != "tests/"* ]]; then
exit
fi
curl -X POST "https://a8c-gh-desktop-bridge.go-vip.co/circleciwebhook" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"payload": {
"outcome": "'"failed"'",
"status": "'"failed"'",
"branch": "'"$BRANCHNAME"'",
"build_url": "'"$CIRCLE_BUILD_URL"'",
"build_parameters": {
"build_num": '"$CIRCLE_BUILD_NUM"',
"sha": "'"$sha"'",
"calypsoProject": "'"$calypsoProject"'"
}
}
}'
jobs:
build:
macos:
xcode: "9.0"
shell: /bin/bash --login
working_directory: /Users/distiller/wp-desktop
steps:
- checkout
- run:
name: Setup calypso
command: |
git submodule init
git submodule update
if [ -n "${CALYPSO_HASH}" ]; then
cd calypso;
git fetch;
git checkout ${CALYPSO_HASH};
fi
- *calypso_prepare_cache
- *calypso_restore_cache
- *restore_nvm
- *setup_nvm
- *save_nvm
- run:
name: Decrypt assets
command: |
openssl aes-256-cbc -d -in resource/calypso/secrets.json.enc -out calypso/config/secrets.json -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
openssl aes-256-cbc -d -in resource/certificates/mac.p12.enc -out resource/certificates/mac.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
openssl aes-256-cbc -d -in resource/certificates/win.p12.enc -out resource/certificates/win.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
- *npm_restore_cache
- run:
name: Npm install
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm ci
cd calypso
npx lerna bootstrap
- *npm_save_cache
- run:
name: Build sources
no_output_timeout: 20m
command: |
# only use the updater when we are building from master or a release branch
# if [[ $CIRCLE_BRANCH =~ ^release(.*)|(^master$) ]]
# then
# CONFIG_ENV=release
# fi
# TODO: update accordingly when code from above changes
CONFIG_ENV=release
# only build the whole bundle when there is no calypso-hash file
if [ "$(cat calypso-current-hash)" != "$(cat calypso-hash)" ]; then
set +e
source $HOME/.nvm/nvm.sh
nvm use
if [ -n "${CALYPSO_HASH}" ]; then
CONFIG_ENV=test
fi
make build-source CONFIG_ENV=$CONFIG_ENV EMIT_STATS=true
else
make desktop/config.json CONFIG_ENV=$CONFIG_ENV
make build-desktop
fi
- run:
name: Test
command: |
set +e
# At this stage, we can only do canary tests when CONFIG_ENV=test as the electron binary is not signed
# TODO: We might be able to ignore this once we switched to electron-builders auto-update
if [ -n "${CALYPSO_HASH}" ]; then
source $HOME/.nvm/nvm.sh
nvm use
make test
fi
- *calypso_finalize_cache
- *calypso_save_cache
- persist_to_workspace:
root: /Users/distiller/wp-desktop
paths: *app_cache_paths
- *webhook_notify_success
- *webhook_notify_failed
linux:
docker:
- image: electronuserland/builder:wine-mono
working_directory: /wp-desktop
steps:
- checkout
- attach_workspace:
at: /wp-desktop
- *restore_nvm
- *setup_nvm
- *save_nvm
- *npm_restore_cache
- run:
name: Install linux dev dependencies
command: |
apt-get update
apt-get -y install libxkbfile-dev libxkbfile-dev:i386 libxss-dev libx11-dev:i386
- run:
name: Install dependencies
name: Npm install
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm ci
- *npm_save_cache
- run:
name: Build Linux
environment:
CSC_LINK: resource/certificates/win.p12
command: |
source $HOME/.nvm/nvm.sh
nvm use
make package BUILD_PLATFORM=l
- run:
name: Release cleanup
command: |
set +e
rm -rf release/github
rm -rf release/linux-unpacked
- persist_to_workspace:
root: /wp-desktop
paths:
- release
windows:
macos:
xcode: "9.0"
shell: /bin/bash --login
working_directory: /Users/distiller/wp-desktop
steps:
- checkout
- attach_workspace:
at: /Users/distiller/wp-desktop
- *restore_nvm
- *setup_nvm
- *save_nvm
- *npm_restore_cache
- run:
name: Npm install
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm ci
- *npm_save_cache
- run:
name: Build Windows
environment:
WIN_CSC_LINK: resource/certificates/win.p12
CSC_FOR_PULL_REQUEST: true # don't do this in production
USE_HARD_LINKS: "false" # must be string
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
make package BUILD_PLATFORM=w
- run:
name: Release cleanup
command: |
set +e
tar -zcvf release/win-unpacked-x64.tar.gz release/win-unpacked
tar -zcvf release/win-unpacked-ia32.tar.gz release/win-ia32-unpacked
rm -rf release/github
rm -rf release/win-unpacked
rm -rf release/win-ia32-unpacked/
- persist_to_workspace:
root: /Users/distiller/wp-desktop
paths:
- release
mac:
macos:
xcode: "9.0"
shell: /bin/bash --login
working_directory: /Users/distiller/wp-desktop
steps:
- checkout
- attach_workspace:
at: /Users/distiller/wp-desktop
- *restore_nvm
- *setup_nvm
- *save_nvm
- *npm_restore_cache
- run:
name: Npm install
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm ci
- *npm_save_cache
- run:
name: Build Mac
environment:
CSC_LINK: resource/certificates/mac.p12
CSC_FOR_PULL_REQUEST: true # don't do this in production
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
make package BUILD_PLATFORM=m
# Temporarily disable the test
# TODO: Fixme – seems to be an issue with `portscanner`
# - run:
# name: Test
# command: |
# source $HOME/.nvm/nvm.sh
# nvm use
# make test TEST_PRODUCTION_BINARY=true
- run:
name: e2e Tests
command: |
export BINARY_PATH="./release/mac/WordPress.com.app/Contents/MacOS/WordPress.com"
./node_modules/.bin/chromedriver >/dev/null 2>&1 &
./node_modules/.bin/mocha test/tests/e2e.js
- run:
name: Release cleanup
command: |
set +e
rm -rf release/github
rm -rf release/mac
- persist_to_workspace:
root: /Users/distiller/wp-desktop
paths:
- release
artifacts:
docker:
- image: buildpack-deps:trusty
working_directory: /wp-desktop
steps:
- attach_workspace:
at: /wp-desktop
- store_artifacts:
path: release
workflows:
version: 2
wp-desktop:
jobs:
- build:
filters:
tags:
only: /.*/
- windows:
requires:
- build
filters:
branches:
ignore: /tests.*/
tags:
only: /.*/
- linux:
requires:
- build
filters:
branches:
ignore: /tests.*/
tags:
only: /.*/
- mac:
requires:
- build
filters:
branches:
ignore: /tests.*/
tags:
only: /.*/
- artifacts:
requires:
- windows
- linux
- mac
filters:
branches:
ignore: /tests.*/
tags:
only: /.*/