-
Notifications
You must be signed in to change notification settings - Fork 2k
/
config.yml
534 lines (505 loc) · 18.2 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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
version: 2.1
orbs:
win: circleci/windows@5.0.0
references:
defaults: &defaults
working_directory: ~/wp-calypso
docker:
- image: cimg/node:18.13.0
environment:
CIRCLE_ARTIFACTS: /tmp/artifacts
CIRCLE_TEST_REPORTS: /tmp/test_results
PUPPETEER_SKIP_DOWNLOAD: 'true'
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 'true'
SKIP_TSC: 'true'
NODE_OPTIONS: --max-old-space-size=3072
npm_config_cache: /home/circleci/.cache/yarn
desktop_defaults: &desktop_defaults
working_directory: ~/wp-calypso
setup-results-and-artifacts: &setup-results-and-artifacts
name: Create Directories for Results and Artifacts
command: |
mkdir -p \
"$CIRCLE_ARTIFACTS/notifications-panel" \
"$CIRCLE_ARTIFACTS/screenshots" \
"$CIRCLE_ARTIFACTS/wpcom-block-editor" \
"$CIRCLE_TEST_REPORTS/client" \
"$CIRCLE_TEST_REPORTS/eslint" \
"$CIRCLE_TEST_REPORTS/integration" \
"$CIRCLE_TEST_REPORTS/packages" \
"$CIRCLE_TEST_REPORTS/server" \
"$CIRCLE_TEST_REPORTS/e2ereports" \
"$HOME/jest-cache"
# Git cache
#
# Calypso is a big repository with a lot of history. It can take a long time to do a full checkout.
# By including the `.git` directory in the cache, we can speed things up by only needing to update
# the local repository.
#
# We cache on the branch and revision, falling back to origin/HEAD, or any recent cache.
#
# More about the CircleCI cache: https://circleci.com/docs/2.0/caching
restore-git-cache: &restore-git-cache
name: Restore git cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-trunk
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git
update-git: &update-git
name: Update all branches
command: git fetch --force origin
save-git-cache: &save-git-cache
name: Save git cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v2-git-{{ .Branch }}-{{ .Revision }}
paths:
- '.git'
# yarn cache
#
# yarn caches the modules it installs in ~/.cache/yarn.
# We cache that cache to save time pulling modules from the network.
#
#
# Some prior art:
# - https://github.com/Automattic/wp-calypso/pull/25431
# - https://github.com/Automattic/wp-calypso/pull/25487
# - https://github.com/Automattic/wp-calypso/pull/27180
#
# More about the CircleCI cache: https://circleci.com/docs/2.0/caching and https://circleci.com/docs/2.0/yarn/
restore-yarn-cache: &restore-yarn-cache
name: 'Restore yarn cache'
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v3-yarn-cache-{{ arch }}-{{ checksum ".yarnrc.yml" }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v3-yarn-cache-{{ arch }}
yarn-install: &yarn-install
name: Install dependencies
command: |
source "$HOME/.nvm/nvm.sh"
nvm use
npm install -g yarn
yarn install --immutable --inline-builds
update-node: &update-node
name: Update node
command: |
set +e
set +x
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout v0.35.3
) && \. "$NVM_DIR/nvm.sh" --no-use
nvm install
nvm use
save-yarn-cache: &save-yarn-cache
name: 'Save yarn cache'
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v3-yarn-cache-{{ arch }}-{{ checksum ".yarnrc.yml" }}
paths:
# This is the default path when using enableGlobalCache:true
- ~/.yarn/berry/cache
desktop-cache-paths: &desktop-cache-paths
- desktop/resource/certificates/win.p12
- desktop/resource/certificates/mac.p12
desktop-decrypt-certs: &desktop-decrypt-certs
name: Decrypt desktop code signing certificates
command: |
openssl aes-256-cbc -md md5 -d -in desktop/resource/certificates/mac.p12.enc -out desktop/resource/certificates/mac.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
openssl aes-256-cbc -md md5 -d -in desktop/resource/certificates/win.p12.enc -out desktop/resource/certificates/win.p12 -k "${CALYPSO_SECRETS_ENCRYPTION_KEY}"
desktop-notify-github-success: &desktop-notify-github-success
name: Notify Github Success
when: on_success
command: cd desktop && yarn ci:github:dismiss-review
desktop-notify-github-failure: &desktop-notify-github-failure
name: Notify Github Failure
when: on_fail
command: cd desktop && yarn ci:github:add-review
commands:
store-artifacts-and-test-results:
description: Stores artifacts and test results
steps:
- store_test_results:
path: /tmp/test_results
- store_artifacts:
path: /tmp/test_results
- store_artifacts:
path: /tmp/artifacts
jobs:
wp-desktop-assets:
docker:
- image: cimg/node:18.13.0-browsers
<<: *desktop_defaults
environment:
VERSION: << pipeline.git.tag >>
working_directory: ~/wp-calypso
steps:
- checkout
- attach_workspace:
at: ~/wp-calypso
- run: *update-node
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Ensure package.json Version And Tag Match
command: cd desktop/bin && node validate_tag.js $VERSION
- run: *desktop-decrypt-certs
- persist_to_workspace:
root: ~/wp-calypso
paths: *desktop-cache-paths
- run: *desktop-notify-github-failure
wp-desktop-mac:
macos:
xcode: '12.3.0'
shell: /bin/bash --login
working_directory: /Users/distiller/wp-calypso
environment:
CONFIG_ENV: release
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
steps:
- checkout
- attach_workspace:
at: /Users/distiller/wp-calypso
- run: *update-node
- restore_cache: *restore-yarn-cache
- run: *yarn-install
- save_cache: *save-yarn-cache
- run:
name: Build Desktop Mac
no_output_timeout: 45m
environment:
CSC_LINK: resource/certificates/mac.p12
CSC_FOR_PULL_REQUEST: true
USE_HARD_LINKS: 'false'
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
! git diff --name-only origin/trunk...HEAD | grep -E -q 'desktop/package.json|yarn.lock' && ELECTRON_BUILDER_ARGS='-c.mac.target=dir'
# Override SDKROOT and MACOSX_DEPLOYMENT_TARGET to ensure correct SDK configuration:
# https://github.com/Homebrew/homebrew-core/pull/19296#issuecomment-352867571
export SDKROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk'
export MACOSX_DEPLOYMENT_TARGET=11.1
cd desktop && ELECTRON_BUILDER_ARGS=$ELECTRON_BUILDER_ARGS yarn run ci:build-mac
- run:
name: e2e Tests
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm install -g yarn
cd desktop && yarn run test:e2e
- run:
when: always
name: Persist Mac Executable
command: |
# If this isn't a full artifact build, ensure to persist the built application for inspection
if ! ls desktop/release/*.zip &>/dev/null
then
ditto -ck --rsrc --sequesterRsrc desktop/release/mac desktop/release/mac.app.zip
fi
- run:
when: always
name: Clean Up
command: |
rm -rf desktop/release/mac
rm -rf desktop/release/mac-arm64
rm desktop/release/builder-debug.yml
- store_artifacts:
when: always
path: desktop/release
- store_artifacts:
when: always
path: desktop/test/e2e/results/
- persist_to_workspace:
root: ~/wp-calypso
paths:
- desktop/release
- run: *desktop-notify-github-success
- run: *desktop-notify-github-failure
wp-desktop-linux:
docker:
- image: cimg/node:18.13.0-browsers
<<: *desktop_defaults
shell: /bin/bash --login
environment:
CONFIG_ENV: release
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
steps:
- checkout
- attach_workspace:
at: ~/wp-calypso
- run: *update-node
- run:
name: Install Linux deps
command: |
sudo apt update
sudo apt-get install -y libsecret-1-dev
- restore_cache: *restore-yarn-cache
- run: *yarn-install
- save_cache: *save-yarn-cache
- run:
name: Build Desktop Linux
environment:
CSC_LINK: resource/certificates/win.p12
USE_HARD_LINKS: 'false'
command: |
set +e
source $HOME/.nvm/nvm.sh
nvm use
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
! git diff --name-only origin/trunk...HEAD | grep -E -q 'desktop/package.json|desktop/yarn.lock' && ELECTRON_BUILDER_ARGS='-c.linux.target=dir'
cd desktop
ELECTRON_BUILDER_ARGS=$ELECTRON_BUILDER_ARGS yarn run build
- run:
name: e2e Tests
command: |
source $HOME/.nvm/nvm.sh
nvm use
npm install -g yarn
cd desktop && yarn run test:e2e
- run:
when: always
name: Persist Linux Executable
command: |
# If this isn't a full artifact build, ensure to persist the built application for inspection
test -f desktop/release/*.tar.gz || tar -zcf desktop/release/linux-unpacked.tar.gz desktop/release/linux-unpacked
- run:
when: always
name: Clean Up
command: |
set +e
rm -rf desktop/release/github
rm -rf desktop/release/linux-unpacked
rm -rf desktop/release/.icon-set
rm desktop/release/builder-debug.yml
- store_artifacts:
when: always
path: desktop/release
- store_artifacts:
when: always
path: desktop/test/e2e/results/
- persist_to_workspace:
root: ~/wp-calypso
paths:
- desktop/release
wp-desktop-windows:
executor:
name: win/default
working_directory: C:\Users\circleci\wp-calypso
environment:
CONFIG_ENV: release
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
steps:
- checkout
- attach_workspace:
at: C:\Users\circleci\wp-calypso
- run:
name: Install NVM
command: choco install -y nvm
- run:
name: Install Node environment
command: |
$NODE_VERSION = Get-Content .nvmrc
nvm install $NODE_VERSION
nvm use $NODE_VERSION
- run:
name: Install Yarn
command: npm install -g yarn
- run:
name: Verify versions
shell: bash.exe
command: |
node --version
nvm --version
yarn --version
- run:
name: Install Make
command: cinst make
- run:
name: Install Desktop Dependencies
command: yarn
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Build Appx
command: |
# Use make (not yarn/npm directly) for bash-like environment variable substitution
make -f desktop/Makefile build-main WINDOWS_STORE=1
# Note: Windows Store build should be unsigned
make -f desktop/Makefile package ELECTRON_BUILDER_ARGS='--config="electron-builder-appx.json"'
- run:
name: Clean Up Appx
command: |
set +e
rm -rf desktop/config
rm desktop/release/*.yml
rm -rf desktop/release/win-unpacked
rm -rf desktop/release/win-ia32-unpacked
rm desktop/release/builder-debug.yml || true
shell: bash.exe
- when:
condition: << pipeline.git.tag >>
steps:
- run:
name: Import Codesigning Certificate
command: |
# Workaround for Sign Tool "private key filter" bug in Circle's Windows image.
# Ref: https://travis-ci.community/t/codesigning-on-windows/
#
# Fix: Import .p12 into the local certificate store. Sign Tool will use
# package.json's `certificateSubjectName` to find the imported cert.
$env:CSC_LINK='C:\Users\circleci\wp-calypso\desktop\resource\certificates\win.p12'
Import-PfxCertificate -FilePath $env:CSC_LINK -CertStoreLocation Cert:\LocalMachine\Root -Password (ConvertTo-SecureString -String $env:WIN_CSC_KEY_PASSWORD -AsPlainText -Force)
- run:
name: Build NSIS
command: |
# Use make (not yarn/npm directly) for bash-like environment variable substitution
make -f desktop/Makefile build-main
# Codesign release (tagged) builds only
If ( $env:CIRCLE_TAG ) { $env:ARG1='-c.win.certificateSubjectName="Automattic"' }
# Build all artifacts only when project config changes.
# Otherwise only build application executable required for end-to-end testing.
If ( -Not $(git diff --name-only origin/trunk...HEAD | Select-String -Pattern desktop/package.json,desktop/yarn.lock) ) { $env:ARG2='-c.win.target=dir' }
make -f desktop/Makefile package ELECTRON_BUILDER_ARGS=$($env:ARG1,$env:ARG2 -join " ")
- run:
name: Archive Unpacked Directories
command: |
tar -zcf desktop/release/win-unpacked-x64.tar.gz desktop/release/win-unpacked
# Check if win-ia32 build is present before archiving. If this is a full
# artifact build, the win-ia32-unpacked executable will be generated and we can archive it.
If ( $(Test-Path -Path desktop\release\win-ia32-unpacked) ) {
tar -zcf desktop/release/win-unpacked-ia32.tar.gz desktop/release/win-ia32-unpacked
} else {
echo "Skipping tar archive for 'desktop\release\win-ia32-unpacked' (not built)"
}
- run:
when: always
name: Clean Up NSIS
command: |
set +e
rm -rf desktop/release/github
rm -rf desktop/release/win-unpacked
rm -rf desktop/release/win-ia32-unpacked
rm desktop/release/builder-debug.yml || true
shell: bash.exe
- store_artifacts:
when: always
path: desktop\release
- persist_to_workspace:
root: C:\Users\circleci\wp-calypso
paths:
- desktop\release
# Publish all the artifacts generated by the previous wp-desktop- jobs to a
# GitHub release and generate the release notes using the Git commits history
wp-desktop-publish:
docker:
- image: circleci/golang:1.12-node
working_directory: /home/circleci/wp-calypso
environment:
VERSION: << pipeline.git.tag >>
steps:
- checkout
- attach_workspace:
at: /home/circleci/wp-calypso
- run:
name: Install Dependencies
command: go get github.com/tcnksm/ghr
- run:
name: Update wp-desktop repo README
command: |
node desktop/bin/github/update-desktop-repo-readme.js
- run:
name: Publish Github Release
command: |
SHORT_VERSION="${VERSION#desktop-}"
echo "Publishing draft release for wp-desktop $SHORT_VERSION..."
NAME="WP-Desktop ${SHORT_VERSION#?}"
chmod +x desktop/bin/make-changelog.sh
./desktop/bin/make-changelog.sh > desktop/CHANGELOG.md
ghr \
--token "${WP_DESKTOP_SECRET}" \
--username "${CIRCLE_PROJECT_USERNAME}" \
--repository "wp-desktop" \
--commitish "trunk" \
--name "${NAME}" \
--body "$(cat desktop/CHANGELOG.md)" \
--delete \
--draft \
"${SHORT_VERSION}" desktop/release/
echo "Publish complete"
workflows:
version: 2
wp-desktop:
jobs:
- wp-desktop-assets:
filters:
branches:
only:
- trunk
- /circleci.*/
- /release\/.*/
- /desktop\/.*/
# - wp-desktop-mac:
# requires:
# - wp-desktop-assets
# filters:
# branches:
# only:
# - trunk
# - /release\/.*/
# - /desktop\/.*/
- wp-desktop-linux:
requires:
- wp-desktop-assets
filters:
branches:
only:
- trunk
- /circleci.*/
- /release\/.*/
- /desktop\/.*/
- wp-desktop-windows:
requires:
- wp-desktop-assets
filters:
branches:
only:
- trunk
- /circleci.*/
- /release\/.*/
- /desktop\/.*/
wp-desktop-release:
when: << pipeline.git.tag >>
jobs:
- wp-desktop-assets:
filters:
tags:
only: /desktop-v.*/
- wp-desktop-mac:
requires:
- wp-desktop-assets
filters:
tags:
only: /desktop-v.*/
- wp-desktop-linux:
requires:
- wp-desktop-assets
filters:
tags:
only: /desktop-v.*/
- wp-desktop-windows:
requires:
- wp-desktop-assets
filters:
tags:
only: /desktop-v.*/
- wp-desktop-publish:
requires:
- wp-desktop-mac
- wp-desktop-linux
- wp-desktop-windows
filters:
tags:
only: /desktop-v.*/