-
Notifications
You must be signed in to change notification settings - Fork 58
/
config.yml
479 lines (466 loc) · 18.4 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
version: 2.1
commands:
npm-install:
parameters:
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install
command: |
echo "Node version: $(node --version)"
npm ci --prefer-offline --no-audit
- save_cache:
name: Save NPM Cache
key: npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- src/i18n-cache
- ~/.local/share/pnpm/store/v3
- ~/Library/pnpm/store/v3
npm-install-full:
parameters:
additional-flags:
type: string
default: ""
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "gutenberg/package-lock.json" }}
- npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install Full
command: |
echo "Node version: $(node --version)"
npm install --no-audit
- save_cache:
name: Save NPM Cache
key: npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- ~/.npm
- src/i18n-cache
- ~/.local/share/pnpm/store/v3
- ~/Library/pnpm/store/v3
npm-install-e2e-tests:
parameters:
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install (E2E Tests)
command: |
echo "Node version: $(node --version)"
npm ci --prefer-offline --no-audit --ignore-scripts
npm ci --prefix gutenberg --prefer-offline --no-audit
checkout-shallow:
steps:
- run:
name: Checkout (Shallow)
command: |
#!/bin/sh
set -e
# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi
SSH_CONFIG_DIR="$HOME/.ssh"
echo "Using SSH Config Dir '$SSH_CONFIG_DIR'"
git --version
mkdir -p "$SSH_CONFIG_DIR"
chmod 0700 "$SSH_CONFIG_DIR"
printf "%s" 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
' >> "$SSH_CONFIG_DIR/known_hosts"
chmod 0600 "$SSH_CONFIG_DIR/known_hosts"
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile='$SSH_CONFIG_DIR/known_hosts'"
# use git+ssh instead of https
git config --global url."ssh://[email protected]".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
if [ -e "$HOME/project/.git" ] ; then
echo 'Fetching into existing repository'
existing_repo='true'
cd "$HOME/project"
git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true
else
echo 'Cloning git repository'
existing_repo='false'
mkdir -p "$HOME/project"
cd "$HOME/project"
git clone --depth 1 --no-checkout "$CIRCLE_REPOSITORY_URL" .
fi
echo 'Fetching from remote repository'
if [ -n "$CIRCLE_TAG" ]; then
git fetch --depth 1 --force --tags origin "refs/tags/$CIRCLE_TAG"
else
git fetch --depth 1 --force origin "$CIRCLE_SHA1"
fi
if [ -n "$CIRCLE_TAG" ]; then
echo 'Checking out tag'
git checkout --force "$CIRCLE_TAG"
git reset --hard "$CIRCLE_SHA1"
else
echo 'Checking out branch'
git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1"
git --no-pager log --no-color -n 1 --format='HEAD is now at %h %s'
fi
checkout-submodules:
steps:
- run:
name: Checkout Submodules
command: git submodule update --init --recursive --depth 1
add-jest-reporter-dir:
steps:
- run:
name: Create reports directory
command: mkdir reports && mkdir reports/test-results
add-jest-snapshot-dir:
steps:
- run:
name: Create snapshots directory
command: mkdir __device-tests__/image-snapshots/diff
install-node-version:
steps:
- run:
name: Install newer nvm
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
if [ -z "${NVM_DIR}" ] ; then
echo 'Default NVM_DIR to .nvm in home'
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
fi
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use' >> $BASH_ENV
- run:
name: Install node version specified in .nvmrc using nvm
command: |
nvm install
# Set the installed version as the default one
nvm alias default $(nvm current)
# Enforce to use the default version in the rest of workflow
echo 'nvm use default' >> $BASH_ENV
parameters:
android-docker-image:
type: string
default: "cimg/android:2023.07-node"
linux-machine-image:
type: string
# Latest supported ubuntu image from https://circleci.com/docs/2.0/configuration-reference/#available-machine-images
default: "ubuntu-2004:2022.10.1"
jobs:
checks:
parameters:
platform:
type: string
default: ""
check-tests:
type: boolean
default: false
check-correctness:
type: boolean
default: false
machine:
image: << pipeline.parameters.linux-machine-image >>
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- when:
condition: <<parameters.check-correctness>>
steps:
- npm-install-full
- unless:
condition: <<parameters.check-correctness>>
steps:
- npm-install
- add-jest-reporter-dir
- run:
name: Set Environment Variables
command: |
echo 'export CHECK_CORRECTNESS=<<parameters.check-correctness>>' >> $BASH_ENV
echo 'export CHECK_TESTS=<<parameters.check-tests>>' >> $BASH_ENV
echo 'export TEST_RN_PLATFORM=<<parameters.platform>>' >> $BASH_ENV
- run:
name: Run Checks
command: bin/ci-checks-js.sh
environment:
JEST_JUNIT_OUTPUT_FILE: "reports/test-results/android-test-results.xml"
- store_test_results:
path: ./reports/test-results
android-build:
machine:
image: << pipeline.parameters.linux-machine-image >>
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- run: node -v
- npm-install
- run: npm run test:e2e:bundle:android
- run:
name: Build apk
command: |
docker run --rm -it \
--volume $(pwd):/home/circleci/project \
--workdir /home/circleci/project \
--env JAVA_OPTS='-Xms512m -Xmx2g' \
--env GRADLE_OPTS='-Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError"' \
<< pipeline.parameters.android-docker-image >> \
/bin/bash -c "sudo chown -R circleci:circleci . && npm run core test:e2e:build-app:android"
- run:
name: Upload apk to sauce labs
command: |
source bin/sauce-pre-upload.sh
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location \
--request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
--form 'payload=@"./gutenberg/packages/react-native-editor/android/app/build/outputs/apk/debug/app-debug.apk"' \
--form "name=Gutenberg-$SAUCE_FILENAME.apk" \
--form 'description="Gutenberg"'
android-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
machine:
image: << pipeline.parameters.linux-machine-image >>
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- run: node -v
- npm-install-e2e-tests
- add-jest-snapshot-dir
- run: mkdir /home/circleci/test-results
- run:
name: Run Device Tests
command: npm run device-tests<<parameters.is-canary>>
no_output_timeout: 1200
environment:
TEST_RN_PLATFORM: android
TEST_ENV: sauce
JEST_JUNIT_OUTPUT_FILE: "/home/circleci/test-results/android-test-results.xml"
- store_test_results:
path: /home/circleci/test-results
android-native-unit-tests:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
docker:
- image: << pipeline.parameters.android-docker-image >>
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- npm-install
- run:
name: Run Android native-editor unit tests
command: cd gutenberg/packages/react-native-editor/android && ./gradlew testDebug
- run:
name: Run Android native-bridge unit tests
command: cd gutenberg/packages/react-native-bridge/android && ./gradlew test
ios-build:
macos:
xcode: "13.4.1"
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- npm-install
- run:
name: Set Environment Variables
command: |
echo 'export TEST_RN_PLATFORM=ios' >> $BASH_ENV
echo 'export TEST_ENV=sauce' >> $BASH_ENV
- run:
name: Prepare build cache key
command: find gutenberg/package-lock.json gutenberg/packages/react-native-editor/ios gutenberg/packages/react-native-aztec/ios gutenberg/packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt
- restore_cache:
name: Restore Build Cache
keys:
- ios-build-cache-{{ checksum "ios-checksums.txt" }}
- restore_cache:
name: Restore Dependencies Cache
keys:
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}
- dependencies-v6-
- run:
name: Build (if needed)
command: test -e gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app || npm run core test:e2e:build-app:ios
- save_cache:
name: Save Dependencies Cache
key: dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- gutenberg/packages/react-native-editor/ios/Pods
- ~/Library/Caches/CocoaPods
- ~/.cocoapods/repos/trunk
- gutenberg/packages/react-native-editor/ios/vendor
- run:
name: Bundle iOS
command: npm run test:e2e:bundle:ios
- run:
name: Generate .app file for testing
command: WORK_DIR=$(pwd) && cd ./gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator && zip -r $WORK_DIR/gutenberg/packages/react-native-editor/ios/GutenbergDemo.app.zip GutenbergDemo.app
- run:
name: Upload .app to sauce labs
command: |
source bin/sauce-pre-upload.sh
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location \
--request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
--form 'payload=@"./gutenberg/packages/react-native-editor/ios/GutenbergDemo.app.zip"' \
--form "name=Gutenberg-$SAUCE_FILENAME.app.zip" \
--form 'description="Gutenberg"'
- run:
name: Prepare build cache
command: rm gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle
- save_cache:
name: Save Build Cache
key: ios-build-cache-{{ checksum "ios-checksums.txt" }}
paths:
- gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
ios-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
is-ipad:
type: string
default: ""
macos:
xcode: "13.4.1"
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- npm-install-e2e-tests
- add-jest-reporter-dir
- add-jest-snapshot-dir
- run:
name: Set Environment Variables
command: |
echo 'export TEST_RN_PLATFORM=ios' >> $BASH_ENV
echo 'export TEST_ENV=sauce' >> $BASH_ENV
- run:
name: Run Device Tests
command: |
npm run device-tests<<parameters.is-canary>><<parameters.is-ipad>>
no_output_timeout: 1200
environment:
JEST_JUNIT_OUTPUT_FILE: "reports/test-results/ios-test-results.xml"
- store_test_results:
path: ./reports/test-results
workflows:
gutenberg-mobile:
jobs:
- checks:
name: Check Correctness
check-correctness: true
- checks:
name: Test iOS
platform: ios
check-tests: true
- checks:
name: Test Android
platform: android
check-tests: true
- ios-build:
name: iOS Build
- android-build:
name: Android Build
- ios-device-checks:
name: Test iOS on Device - Canaries
is-canary: "-canary"
requires: [ "Test iOS", "iOS Build" ]
- android-device-checks:
name: Test Android on Device - Canaries
is-canary: "-canary"
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
- android-native-unit-tests:
name: Android Native Unit Tests
# For regular branches the full test suite is optional.
- Optional UI Tests:
type: approval
filters:
branches:
ignore:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
- ios-device-checks:
name: Test iOS on Device - Full (Manually triggered)
requires: [ "Optional UI Tests", "Test iOS", "iOS Build" ]
filters:
branches:
ignore:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
- ios-device-checks:
name: Test iOS on Device - iPad (Manually triggered)
is-ipad: "-ipad"
requires: [ "Optional UI Tests", "Test iOS", "iOS Build" ]
filters:
branches:
ignore:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
- android-device-checks:
name: Test Android on Device - Full (Manually triggered)
requires: [ "Optional UI Tests", "Test Android", "Android Native Unit Tests", "Android Build" ]
filters:
branches:
ignore:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
# For `trunk`, Dependabot, and release branches we always run the full test suite.
- ios-device-checks:
name: Test iOS on Device - Full
post-to-slack: true
requires: [ "Test iOS", "iOS Build" ]
filters:
branches:
only:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
- ios-device-checks:
name: Test iOS on Device - iPad
is-ipad: "-ipad"
post-to-slack: true
requires: [ "Test iOS", "iOS Build" ]
filters:
branches:
only:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/
- android-device-checks:
name: Test Android on Device - Full
post-to-slack: true
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
filters:
branches:
only:
- trunk
- /^dependabot/submodules/.*/
- /^release.*/