Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
react-native: react-native-community/react-native@8.0.1
Use react-native
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
An example of how to build, test, and release the Android app
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
version: '2.1'
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: bundle exec fastlane android release
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/android_build:
build_type: release
requires:
- analyse_js
- rn/android_test:
requires:
- rn/android_build
- fastlane_release:
requires:
- rn/android_test
A full setup with a Javascript test job, leading to Detox build and test jobs, and finally releasing the apps using a Fastlane command
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
version: '2.1'
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor:
name: rn/linux_js
node_version: '16'
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_android_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: echo
name: Run Fastlane
fastlane_ios_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: echo 1
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/android_build:
build_type: debug
name: build_android_debug
project_path: android
requires:
- analyse_js
- rn/android_build:
build_type: release
name: build_android_release
project_path: android
requires:
- analyse_js
- rn/android_test:
detox_configuration: android.emu.release
requires:
- build_android_release
- rn/ios_build:
build_configuration: Release
device: iPhone 11
name: build_ios_release
node_version: '12'
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- rn/ios_build_and_test:
build_configuration: Release
detox_configuration: ios.sim.release
device: iPhone 11
node_version: '12'
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- fastlane_android_release:
requires:
- rn/android_test
- fastlane_ios_release:
requires:
- rn/ios_build_and_test
An example of how to build, test, and release the iOS app
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
version: '2.1'
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: bundle exec fastlane ios release
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/ios_build:
build_configuration: Release
device: iPhone 11
name: build_ios_release
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- rn/ios_build_and_test:
build_configuration: Release
detox_configuration: ios.sim.release
device: iPhone 11
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- fastlane_release:
requires:
- rn/ios_build_and_test
Builds the Android app at the given path with the given build types.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
assemble_android_test | Configure the android tests to run. Defaults to assembleAndroidTest | No | assembleAndroidTest | string |
attach_workspace | Boolean for whether or not to attach to an existing workspace. Default is true. | No | true | boolean |
build_cache | Should we cache after Gradle build? Defaults to true | No | true | boolean |
build_image_version | React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags | No | '5.1' | string |
build_type | The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app. | No | debug | string |
checkout | Boolean for whether or not to checkout as a first step. Default is false. | No | false | boolean |
gradle_options | Gradle command options. Note that setting this will override the default options so you might need to supply those as well. | No | >- -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError" | string |
on_after_initialize | A custom command to run right after yarn install. | No | '' | string |
persist_to_workspace | Should this job persist files to a workspace? Defaults to true | No | true | boolean |
project_path | The path to the root of the Android project you want to build, relative to the root of the repository. | No | ./android | string |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
store_artifacts | Store this job store files as job artifacts? Defaults to true | No | true | boolean |
workspace_root | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). | No | . | string |
yarn_cache | Should we cache after yarn install? Defaults to true | No | true | boolean |
Tests the Android app on the given device, with the given Detox configuration. You should have already built the correct Android APK (including the androidTest APK) and have both persisted to the worksapce.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
build_tools_version | The version of the Android build tools to install. Defaults to '28.0.3'. | No | 28.0.3 | string |
detox_configuration | The Detox configuration to test. Defaults to 'android.emu.release'. | No | android.emu.release | string |
detox_loglevel | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". | No | warn | enum |
device_name | The name of the AVD. You use this name to tell which device to run tests on. Defaults to 'TestingAVD'. | No | TestingAVD | string |
homebrew_cache | Should we cache after brew install? Defaults to true | No | true | boolean |
homebrew_update | Should we run brew update? Defaults to true | No | true | boolean |
logcat_grep | ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters. Defaults to 'com.reactnativecommunity'. | No | com.reactnativecommunity | string |
node_version | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). | No | '16' | string |
on_after_emulator_start | A custom command to run right after the android emulator starts. | No | '' | string |
on_after_initialize | A custom command to run right after yarn install. | No | '' | string |
platform_version | The version of android to run on the emulator. Defaults to 'android-28'. | No | android-28 | string |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
should_on_after_emulator_start | Set this to true if you want to run a custom shell command right after the android emulator starts. Provide the command in on_after_emulator_start command. | No | false | boolean |
should_on_after_initialize | Set this to true if you want to run a custom shell command right after yarn install. Provide the command in on_after_initialize command. | No | false | boolean |
start_metro | If we should start the Metro packager in the background for this job. | No | false | boolean |
store_artifact_path | Stores detox artifacts at CircleCI | No | '' | string |
workspace_root | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). | No | . | string |
xcode_version | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions | No | 12.5.1 | string |
yarn_cache | Should we cache after yarn install? Defaults to true | No | true | boolean |
Builds the iOS app at the given path with the given build scheme
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
attach_workspace | Boolean for whether or not to attach to an existing workspace. Default is true. | No | true | boolean |
build_configuration | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. | No | Debug | string |
checkout | Boolean for whether or not to checkout as a first step. Default is false. | No | false | boolean |
derived_data_path | The path to the directory to place the derived data, relative to the root of the repository. | No | ios/build | string |
device | The type of device you want to build for. | No | iPhone 11 | string |
homebrew_cache | Should we cache after brew install? Defaults to true | No | true | boolean |
homebrew_update | Should we run brew update? Defaults to true | No | true | boolean |
node_version | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). | No | '16' | string |
on_after_initialize | A custom command to run right after yarn install. | No | '' | string |
pod_cache | Save and restore the CocoaPods cache? Defaults to true | No | true | boolean |
pod_install_directory | The location of the "ios" directory for `pod install`. Will skip `pod install` if missing. | No | '' | string |
project_path | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. | Yes | - | string |
project_type | If the iOS app is built using a project file (*.xcodeproj) or a workspace. | No | project | enum |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
scheme | The scheme to use. | Yes | - | string |
start_metro | If we should start the Metro packager in the background for this job. | No | false | boolean |
workspace_root | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). | No | . | string |
xcode_version | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions | No | 12.5.1 | string |
xcodebuild_cache | Should we cache after Xcode build? Defaults to true | No | true | boolean |
yarn_cache | Should we cache after yarn install? Defaults to true | No | true | boolean |
yarn_cache_folder | The path to the yarn cache folder | No | /tmp/yarn | string |
Builds the iOS app at the given path with the given build scheme and configuration and then runs the tests with the Detox configuration given.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
attach_workspace | Boolean for whether or not to attach to an existing workspace. Default is true. | No | true | boolean |
build_configuration | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. | No | Debug | string |
checkout | Boolean for whether or not to checkout as a first step. Default is false. | No | false | boolean |
derived_data_path | The path to the directory to place the derived data, relative to the root of the repository. | No | ios/build | string |
detox_configuration | The Detox configuration to test. | No | ios.sim.release | string |
detox_loglevel | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". | No | warn | enum |
device | The type of device you want to build for. | No | iPhone 11 | string |
homebrew_cache | Should we cache after brew install? Defaults to true | No | true | boolean |
homebrew_update | Should we run brew update? Defaults to true | No | true | boolean |
node_version | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). | No | '16' | string |
on_after_initialize | A custom command to run right after yarn install. | No | '' | string |
pod_cache | Save and restore the CocoaPods cache? Defaults to true | No | true | boolean |
pod_install_directory | The location of the "ios" directory for `pod install`. Will skip `pod install` if missing. | No | '' | string |
project_path | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. | Yes | - | string |
project_type | If the iOS app is built using a project file (*.xcodeproj) or a workspace. | No | project | enum |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
scheme | The scheme to use. | Yes | - | string |
start_metro | If we should start the Metro packager in the background for this job. | No | false | boolean |
store_artifact_path | Stores detox artifacts at CircleCI | No | '' | string |
workspace_root | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory). | No | . | string |
xcode_version | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions | No | 12.5.1 | string |
xcodebuild_cache | Should we cache after Xcode build? Defaults to true | No | true | boolean |
yarn_cache | Should we cache after yarn install? Defaults to true | No | true | boolean |
yarn_cache_folder | The path to the yarn cache folder | No | /tmp/yarn | string |
Builds the Android app at the given path with the given build types. This should be run only after installing dependencies.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
assemble_android_test | Configure the android tests to run. Defaults to assembleAndroidTest but you might want to set to app:assembleAndroidTest if that works for your project | No | assembleAndroidTest | string |
build_type | The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app. | No | debug | string |
cache | Save and restore the caches? Defaults to true | No | true | boolean |
project_path | The path to the root of the Android project you want to build, relative to the root of the repository. | No | ./android | string |
Installs and starts an Android emulator with the given version and name.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
build_tools_version | The version of the Android build tools to install. | No | 28.0.3 | string |
device_name | The name of the AVD. You use this name to tell which device to run tests on. | No | TestingAVD | string |
logcat_grep | ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters. | No | com.reactnativecommunity | string |
platform_version | The version of android to run on the emulator. Usually in the form of "android-28". | No | android-28 | string |
Bundles all JS files.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
asset_dest | The location to output assets to. | Yes | - | string |
bundle_output | The location to output the bundle to. | Yes | - | string |
dev | If we should bundle in dev mode. Defaults to "false" | No | false | boolean |
entry_file | The entry file for the bundle. Defaults to "index.js". | No | index.js | string |
platform | The platform to build for. Usually one of "ios" or "android". | Yes | - | string |
Builds the app with the given Detox configuration, as specified in package.json.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
configuration | The Detox configuration to build. | Yes | - | string |
Tests the app with the given Detox configuration, as specified in package.json.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
configuration | The Detox configuration to test. | Yes | - | string |
loglevel | The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace". | No | warn | enum |
Builds the iOS app at the given path with the given build scheme and configuration. This should be run only after installing NPM dependencies.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
build_configuration | The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app. | No | Debug | string |
cache | Save and restore the build cache? Defaults to true | No | true | boolean |
derived_data_path | The path to the directory to place the derived data, relative to the root of the repository. | No | ios/build | string |
device | The type of device you want to build for. | No | iPhone 11 | string |
project_path | The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository. | Yes | - | string |
project_type | If the iOS app is built using a project file (*.xcodeproj) or a workspace. | No | project | enum |
scheme | The scheme to use. | Yes | - | string |
Starts an iOS simulator with the given name.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
background | Should ios simulator boot in background? | No | true | boolean |
device | The type of device you want to start. | No | iPhone 11 | string |
Update Android NDK
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
version | - | No | 22.1.7171670 | string |
install pods
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
cache | Save and restore the cache? Defaults to true | No | true | boolean |
pod_install_command | The command to run to install pods | No | pod install | string |
pod_install_directory | The location of the "ios" directory | No | ios | string |
Installs the required packages to build and test Android and iOS applications on the MacOS executor. You need to run this before running any other command on those executors.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
android | Should we set up the Android build environment? Defaults to true | No | true | boolean |
detox | Should we set up Detox? Defaults to true | No | true | boolean |
homebrew_cache | Should we cache after brew install? Defaults to true | No | true | boolean |
homebrew_update | Should we run brew update? Defaults to true | No | true | boolean |
node_version | The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1"). | No | '16' | string |
Install Javascript dependencies using Yarn. This command correctly configures the cache for any number of package.json and yarn.lock files.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
cache | Save and restore the build cache? Defaults to true | No | true | boolean |
cache_folder | The path to the yarn cache folder. Defaults to /tmp/yarn | No | /tmp/yarn | string |
yarn_install_directory | The working directory to run install at. Defaults to yarn's current working directory | No | '' | string |
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
build_image_version | React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags | No | '5.1' | string |
gradle_options | Gradle command options. Note that setting this will override the default options so you might need to supply those as well. | No | >- -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError" | string |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
node_version | The version of Node to use. This can be a full SemVer point release (such as 16.15.2), or just the minor release (such as 18.2), or a version alias. See https://circleci.com/developer/images/image/cimg/node#image-tags | No | '16.15' | string |
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
resource_class | Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class | No | medium | string |
xcode_version | The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions | No | 12.5.1 | string |
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Orb for building and testing React Native projects.
display:
source_url: https://github.com/react-native-community/react-native-circleci-orb
commands:
android_build:
description: Builds the Android app at the given path with the given build types. This should be run only after installing dependencies.
parameters:
assemble_android_test:
default: assembleAndroidTest
description: Configure the android tests to run. Defaults to assembleAndroidTest but you might want to set to app:assembleAndroidTest if that works for your project
type: string
build_type:
default: debug
description: The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app.
type: string
cache:
default: true
description: Save and restore the caches? Defaults to true
type: boolean
project_path:
default: ./android
description: The path to the root of the Android project you want to build, relative to the root of the repository.
type: string
steps:
- when:
condition: <<parameters.cache>>
steps:
- run:
command: |
mkdir -p ~/.tmp/checksumfiles
find . -type f -name 'build.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/build.gradle
find . -type f -name 'settings.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/settings.gradle
name: Create cache checksum files
- restore_cache:
keys:
- gradle-wrapper-{{ arch }}-{{ checksum "<<parameters.project_path>>/gradle/wrapper/gradle-wrapper.properties" }}-{{ .Environment.CACHE_VERSION }}
- restore_cache:
keys:
- gradle-home-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/build.gradle" }}-{{ checksum "~/.tmp/checksumfiles/settings.gradle" }}-{{ .Environment.CACHE_VERSION }}
- restore_cache:
keys:
- gradle-build-cache-{{ .Revision }}
name: Restoring Gradle Build caches
- run:
command: |
[ -d ~/gradle-build-caches ] &&
[ -n "$(ls -A ~/gradle-build-caches)" ] &&
rm -rf ~/.gradle/caches/build-cache-* &&
mkdir -p ~/.gradle/caches/ &&
mv ~/gradle-build-caches/* ~/.gradle/caches/ || true
name: Dispersing Gradle Build caches for restoring
- run:
command: cd <<parameters.project_path>> && chmod +x gradlew && ./gradlew --max-workers 2 downloadDependencies
name: Downloading Gradle Dependencies
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
key: gradle-wrapper-{{ arch }}-{{ checksum "<<parameters.project_path>>/gradle/wrapper/gradle-wrapper.properties" }}-{{ .Environment.CACHE_VERSION }}
name: Saving Gradle wrapper cache
paths:
- ~/.gradle/wrapper/
- save_cache:
key: gradle-home-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/build.gradle" }}-{{ checksum "~/.tmp/checksumfiles/settings.gradle" }}-{{ .Environment.CACHE_VERSION }}
name: Saving Gradle home cache
paths:
- ~/.gradle/caches/
- run:
command: cd <<parameters.project_path>> && chmod +x gradlew && ./gradlew --build-cache --max-workers 2 --continue assemble<<parameters.build_type>> <<parameters.assemble_android_test>> -DtestBuildType=<<parameters.build_type>> --stacktrace
name: Build Android APK
- when:
condition: <<parameters.cache>>
steps:
- run:
command: |
mkdir -p ~/gradle-build-caches
[ -d ~/.gradle/caches ] &&
[ -n "$(ls -Ad ~/.gradle/caches/build-cache-* 2>/dev/null)" ] &&
rm -rf ~/gradle-build-caches/* &&
mv ~/.gradle/caches/build-cache-* ~/gradle-build-caches || true
name: Collecting Gradle Build caches for saving
when: always
- save_cache:
key: gradle-build-cache-{{ .Revision }}
name: Saving Gradle Build caches
paths:
- ~/gradle-build-caches
when: always
android_emulator_start:
description: Installs and starts an Android emulator with the given version and name.
parameters:
build_tools_version:
default: 28.0.3
description: The version of the Android build tools to install.
type: string
device_name:
default: TestingAVD
description: The name of the AVD. You use this name to tell which device to run tests on.
type: string
logcat_grep:
default: com.reactnativecommunity
description: ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters.
type: string
platform_version:
default: android-28
description: The version of android to run on the emulator. Usually in the form of "android-28".
type: string
steps:
- run:
command: |
yes | sdkmanager "platform-tools" "tools" >/dev/null
yes | sdkmanager "platforms;<<parameters.platform_version>>" "system-images;<<parameters.platform_version>>;default;x86_64" >/dev/null
yes | sdkmanager "emulator" --channel=3 >/dev/null
yes | sdkmanager "build-tools;<<parameters.build_tools_version>>" >/dev/null
yes | sdkmanager --licenses >/dev/null
yes | sdkmanager --list
name: Install Android Emulator
shell: /bin/bash -e
- run:
command: |
adb start-server
adb devices
adb kill-server
ls -la ~/.android
name: ADB Start Stop
- run:
command: avdmanager create avd --force --name <<parameters.device_name>> --package "system-images;<<parameters.platform_version>>;default;x86_64" --tag default --device pixel
name: Create Android Emulator
- run:
background: true
command: |
$ANDROID_HOME/emulator/emulator @<<parameters.device_name>> -version
$ANDROID_HOME/emulator/emulator @<<parameters.device_name>> -cores 1 -gpu auto -accel on -memory 1024 -no-audio -no-snapshot -no-boot-anim -no-window -logcat *:W | grep -i 'ReactNative\|<<parameters.logcat_grep>>'
name: Start Android Emulator (background)
- run:
command: |
export BOOT=""
echo "Waiting for AVD to finish booting"
export PATH=$(dirname $(dirname $(command -v android)))/platform-tools:$PATH
until [[ "$BOOT" =~ "1" ]]; do
sleep 5
export BOOT=$(adb -e shell getprop sys.boot_completed 2>&1)
done
sleep 15
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
echo "Android Virtual Device is now ready."
name: Wait for AVD to be ready
no_output_timeout: 5m
bundle:
description: Bundles all JS files.
parameters:
asset_dest:
description: The location to output assets to.
type: string
bundle_output:
description: The location to output the bundle to.
type: string
dev:
default: false
description: If we should bundle in dev mode. Defaults to "false"
type: boolean
entry_file:
default: index.js
description: The entry file for the bundle. Defaults to "index.js".
type: string
platform:
description: The platform to build for. Usually one of "ios" or "android".
type: string
steps:
- run:
command: react-native bundle --platform <<parameters.platform>> --bundle-output <<parameters.bundle_output>> --assets-dest <<parameters.asset_dest>> --entry-file <<parameters.entry_file>> --dev <<parameters.dev>>
name: Bundle React Native JS
detox_build:
description: Builds the app with the given Detox configuration, as specified in package.json.
parameters:
configuration:
description: The Detox configuration to build.
type: string
steps:
- run:
command: detox build -c <<parameters.configuration>>
name: Detox Build
detox_test:
description: Tests the app with the given Detox configuration, as specified in package.json.
parameters:
configuration:
description: The Detox configuration to test.
type: string
loglevel:
default: warn
description: The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace".
enum:
- fatal
- error
- warn
- info
- verbose
- trace
type: enum
steps:
- run:
command: detox test -c <<parameters.configuration>> -l <<parameters.loglevel>> --headless
name: Detox Test
ios_build:
description: Builds the iOS app at the given path with the given build scheme and configuration. This should be run only after installing NPM dependencies.
parameters:
build_configuration:
default: Debug
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
cache:
default: true
description: Save and restore the build cache? Defaults to true
type: boolean
derived_data_path:
default: ios/build
description: The path to the directory to place the derived data, relative to the root of the repository.
type: string
device:
default: iPhone 11
description: The type of device you want to build for.
type: string
project_path:
description: The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository.
type: string
project_type:
default: project
description: If the iOS app is built using a project file (*.xcodeproj) or a workspace.
enum:
- project
- workspace
type: enum
scheme:
description: The scheme to use.
type: string
steps:
- when:
condition: <<parameters.cache>>
steps:
- restore_cache:
keys:
- ios-build-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ .Environment.CACHE_VERSION }}
name: Restoring iOS Build caches
- run:
command: export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -<<parameters.project_type>> <<parameters.project_path>> -destination 'platform=iOS Simulator,name=<<parameters.device>>' -scheme '<<parameters.scheme>>' -parallelizeTargets -configuration <<parameters.build_configuration>> -derivedDataPath <<parameters.derived_data_path>> -UseModernBuildSystem=YES | xcpretty -k
name: Build iOS App
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
key: ios-build-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ .Environment.CACHE_VERSION }}
name: Saving iOS Build Cache
paths:
- <<parameters.derived_data_path>>/Build
when: always
ios_simulator_start:
description: Starts an iOS simulator with the given name.
parameters:
background:
default: true
description: Should ios simulator boot in background?
type: boolean
device:
default: iPhone 11
description: The type of device you want to start.
type: string
steps:
- run:
background: <<parameters.background>>
command: xcrun simctl boot "<<parameters.device>>" || true
name: Start iOS simulator (background)
metro_start:
description: Starts the Metro packager.
steps:
- run:
background: true
command: react-native start
name: Start Metro Packager (Background)
ndk_update:
description: Update Android NDK
parameters:
version:
default: 22.1.7171670
type: string
steps:
- run:
command: sdkmanager "ndk;<<parameters.version>>"
name: Update Android NDK
pod_install:
description: install pods
parameters:
cache:
default: true
description: Save and restore the cache? Defaults to true
type: boolean
pod_install_command:
default: pod install
description: The command to run to install pods
type: string
pod_install_directory:
default: ios
description: The location of the "ios" directory
type: string
steps:
- when:
condition: <<parameters.cache>>
steps:
- restore_cache:
keys:
- '{{ .Environment.CACHE_VERSION }}-cache-pods-{{ checksum "<<parameters.pod_install_directory>>/Podfile.lock" }}'
- run:
command: |
cd <<parameters.pod_install_directory>> && eval <<parameters.pod_install_command>> && cd -
name: Install CocoaPods
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
key: '{{ .Environment.CACHE_VERSION }}-cache-pods-{{ checksum "<<parameters.pod_install_directory>>/Podfile.lock" }}'
paths:
- <<parameters.pod_install_directory>>/Pods
setup_macos_executor:
description: Installs the required packages to build and test Android and iOS applications on the MacOS executor. You need to run this before running any other command on those executors.
parameters:
android:
default: true
description: Should we set up the Android build environment? Defaults to true
type: boolean
detox:
default: true
description: Should we set up Detox? Defaults to true
type: boolean
homebrew_cache:
default: true
description: Should we cache after brew install? Defaults to true
type: boolean
homebrew_update:
default: true
description: Should we run brew update? Defaults to true
type: boolean
node_version:
default: "16"
description: The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1").
type: string
steps:
- run:
command: |
echo 'export PATH="$PATH:/usr/local/opt/node@<<parameters.node_version>>/bin:~/.yarn/bin:~/project/node_modules/.bin:~/project/example/node_modules/.bin"' >> $BASH_ENV
echo 'export ANDROID_HOME="/usr/local/share/android-commandlinetools"' >> $BASH_ENV
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-commandlinetools"' >> $BASH_ENV
echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> $BASH_ENV
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> $BASH_ENV
source $BASH_ENV
name: Configure Environment Variables
- when:
condition: <<parameters.homebrew_cache>>
steps:
- restore_cache:
key: brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }}
- run:
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
source ~/.bashrc
command -v nvm
nvm install <<parameters.node_version>>
nvm alias default <<parameters.node_version>>
name: Install node@<<parameters.node_version>>
- run:
command: node --version
name: Verify node version
- when:
condition: <<parameters.homebrew_update>>
steps:
- run:
command: brew update >/dev/null
name: Update brew
- when:
condition: <<parameters.android>>
steps:
run:
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install android-commandlinetools >/dev/null
name: Configure Android Build Environment
- when:
condition: <<parameters.detox>>
steps:
run:
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
name: Configure Detox Environment
- when:
condition: <<parameters.homebrew_cache>>
steps:
- save_cache:
key: brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }}
paths:
- ~/Library/Caches/Homebrew
yarn_install:
description: Install Javascript dependencies using Yarn. This command correctly configures the cache for any number of package.json and yarn.lock files.
parameters:
cache:
default: true
description: Save and restore the build cache? Defaults to true
type: boolean
cache_folder:
default: /tmp/yarn
description: The path to the yarn cache folder. Defaults to /tmp/yarn
type: string
yarn_install_directory:
default: ""
description: The working directory to run install at. Defaults to yarn's current working directory
type: string
steps:
- when:
condition: <<parameters.cache>>
steps:
- run:
command: |
mkdir -p ~/.tmp/checksumfiles
find . -type f -name 'package.json' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/package.json
find . -type f -name 'yarn.lock' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/yarn.lock
name: Create cache checksum file
- restore_cache:
keys:
- yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ .Environment.CACHE_VERSION }}
- when:
condition:
equal:
- ""
- <<parameters.yarn_install_directory>>
steps:
- run:
command: yarn install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>
name: Yarn Install
- unless:
condition:
equal:
- ""
- <<parameters.yarn_install_directory>>
steps:
- run:
command: yarn --cwd <<parameters.yarn_install_directory>> install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>
name: Yarn Install (<<parameters.yarn_install_directory>>)
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
key: yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ .Environment.CACHE_VERSION }}
paths:
- <<parameters.cache_folder>>
executors:
linux_android:
docker:
- image: reactnativecommunity/react-native-android:<<parameters.build_image_version>>
environment:
- GRADLE_OPTS: <<parameters.gradle_options>>
parameters:
build_image_version:
default: "5.1"
description: React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags
type: string
gradle_options:
default: -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError"
description: Gradle command options. Note that setting this will override the default options so you might need to supply those as well.
type: string
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
resource_class: <<parameters.resource_class>>
linux_js:
docker:
- image: cimg/node:<<parameters.node_version>>
parameters:
node_version:
default: "16.15"
description: The version of Node to use. This can be a full SemVer point release (such as 16.15.2), or just the minor release (such as 18.2), or a version alias. See https://circleci.com/developer/images/image/cimg/node#image-tags
type: string
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
resource_class: <<parameters.resource_class>>
macos:
macos:
xcode: <<parameters.xcode_version>>
parameters:
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
xcode_version:
default: 12.5.1
description: The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
type: string
resource_class: <<parameters.resource_class>>
jobs:
android_build:
description: Builds the Android app at the given path with the given build types.
executor:
build_image_version: <<parameters.build_image_version>>
gradle_options: <<parameters.gradle_options>>
name: linux_android
resource_class: <<parameters.resource_class>>
parameters:
assemble_android_test:
default: assembleAndroidTest
description: Configure the android tests to run. Defaults to assembleAndroidTest
type: string
attach_workspace:
default: true
description: Boolean for whether or not to attach to an existing workspace. Default is true.
type: boolean
build_cache:
default: true
description: Should we cache after Gradle build? Defaults to true
type: boolean
build_image_version:
default: "5.1"
description: React Native Android build image version. For available veresions, see https://hub.docker.com/r/reactnativecommunity/react-native-android/tags
type: string
build_type:
default: debug
description: The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app.
type: string
checkout:
default: false
description: Boolean for whether or not to checkout as a first step. Default is false.
type: boolean
gradle_options:
default: -Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError"
description: Gradle command options. Note that setting this will override the default options so you might need to supply those as well.
type: string
on_after_initialize:
default: ""
description: A custom command to run right after yarn install.
type: string
persist_to_workspace:
default: true
description: Should this job persist files to a workspace? Defaults to true
type: boolean
project_path:
default: ./android
description: The path to the root of the Android project you want to build, relative to the root of the repository.
type: string
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
store_artifacts:
default: true
description: Store this job store files as job artifacts? Defaults to true
type: boolean
workspace_root:
default: .
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
yarn_cache:
default: true
description: Should we cache after yarn install? Defaults to true
type: boolean
steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach_workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- yarn_install:
cache: <<parameters.yarn_cache>>
- when:
condition: <<parameters.on_after_initialize>>
steps:
- run:
command: <<parameters.on_after_initialize>>
name: on_after_initialize
- android_build:
assemble_android_test: <<parameters.assemble_android_test>>
build_type: <<parameters.build_type>>
cache: <<parameters.build_cache>>
project_path: <<parameters.project_path>>
- when:
condition: <<parameters.persist_to_workspace>>
steps:
- persist_to_workspace:
paths:
- <<parameters.project_path>>/app/build/outputs/apk
root: .
- when:
condition: <<parameters.store_artifacts>>
steps:
- store_artifacts:
path: <<parameters.project_path>>/app/build/outputs/apk
android_test:
description: Tests the Android app on the given device, with the given Detox configuration. You should have already built the correct Android APK (including the androidTest APK) and have both persisted to the worksapce.
executor:
name: macos
resource_class: <<parameters.resource_class>>
xcode_version: <<parameters.xcode_version>>
parameters:
build_tools_version:
default: 28.0.3
description: The version of the Android build tools to install. Defaults to '28.0.3'.
type: string
detox_configuration:
default: android.emu.release
description: The Detox configuration to test. Defaults to 'android.emu.release'.
type: string
detox_loglevel:
default: warn
description: The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace".
enum:
- fatal
- error
- warn
- info
- verbose
- trace
type: enum
device_name:
default: TestingAVD
description: The name of the AVD. You use this name to tell which device to run tests on. Defaults to 'TestingAVD'.
type: string
homebrew_cache:
default: true
description: Should we cache after brew install? Defaults to true
type: boolean
homebrew_update:
default: true
description: Should we run brew update? Defaults to true
type: boolean
logcat_grep:
default: com.reactnativecommunity
description: ADB logs will be shown in the "Start Android Emulator" commands, but we filter it using grep to avoid noise. You can specify additional strings to grep for. Make sure you escape special characters. Defaults to 'com.reactnativecommunity'.
type: string
node_version:
default: "16"
description: The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1").
type: string
on_after_emulator_start:
default: ""
description: A custom command to run right after the android emulator starts.
type: string
on_after_initialize:
default: ""
description: A custom command to run right after yarn install.
type: string
platform_version:
default: android-28
description: The version of android to run on the emulator. Defaults to 'android-28'.
type: string
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
should_on_after_emulator_start:
default: false
description: Set this to true if you want to run a custom shell command right after the android emulator starts. Provide the command in on_after_emulator_start command.
type: boolean
should_on_after_initialize:
default: false
description: Set this to true if you want to run a custom shell command right after yarn install. Provide the command in on_after_initialize command.
type: boolean
start_metro:
default: false
description: If we should start the Metro packager in the background for this job.
type: boolean
store_artifact_path:
default: ""
description: Stores detox artifacts at CircleCI
type: string
workspace_root:
default: .
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
xcode_version:
default: 12.5.1
description: The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
type: string
yarn_cache:
default: true
description: Should we cache after yarn install? Defaults to true
type: boolean
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- setup_macos_executor:
homebrew_cache: <<parameters.homebrew_cache>>
homebrew_update: <<parameters.homebrew_update>>
node_version: <<parameters.node_version>>
- yarn_install:
cache: <<parameters.yarn_cache>>
- when:
condition: <<parameters.should_on_after_initialize>>
steps:
- run:
command: <<parameters.on_after_initialize>>
name: on_after_initialize
- when:
condition: <<parameters.start_metro>>
steps:
- metro_start
- android_emulator_start:
build_tools_version: <<parameters.build_tools_version>>
device_name: <<parameters.device_name>>
logcat_grep: <<parameters.logcat_grep>>
platform_version: <<parameters.platform_version>>
- when:
condition: <<parameters.should_on_after_emulator_start>>
steps:
- run:
command: <<parameters.on_after_emulator_start>>
name: on_after_emulator_start
- detox_test:
configuration: <<parameters.detox_configuration>>
loglevel: <<parameters.detox_loglevel>>
- when:
condition: <<parameters.store_artifact_path>>
steps:
- store_artifacts:
path: <<parameters.store_artifact_path>>
ios_build:
description: Builds the iOS app at the given path with the given build scheme
executor:
name: macos
resource_class: <<parameters.resource_class>>
xcode_version: <<parameters.xcode_version>>
parameters:
attach_workspace:
default: true
description: Boolean for whether or not to attach to an existing workspace. Default is true.
type: boolean
build_configuration:
default: Debug
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
checkout:
default: false
description: Boolean for whether or not to checkout as a first step. Default is false.
type: boolean
derived_data_path:
default: ios/build
description: The path to the directory to place the derived data, relative to the root of the repository.
type: string
device:
default: iPhone 11
description: The type of device you want to build for.
type: string
homebrew_cache:
default: true
description: Should we cache after brew install? Defaults to true
type: boolean
homebrew_update:
default: true
description: Should we run brew update? Defaults to true
type: boolean
node_version:
default: "16"
description: The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1").
type: string
on_after_initialize:
default: ""
description: A custom command to run right after yarn install.
type: string
pod_cache:
default: true
description: Save and restore the CocoaPods cache? Defaults to true
type: boolean
pod_install_directory:
default: ""
description: The location of the "ios" directory for `pod install`. Will skip `pod install` if missing.
type: string
project_path:
description: The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository.
type: string
project_type:
default: project
description: If the iOS app is built using a project file (*.xcodeproj) or a workspace.
enum:
- project
- workspace
type: enum
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
scheme:
description: The scheme to use.
type: string
start_metro:
default: false
description: If we should start the Metro packager in the background for this job.
type: boolean
workspace_root:
default: .
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
xcode_version:
default: 12.5.1
description: The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
type: string
xcodebuild_cache:
default: true
description: Should we cache after Xcode build? Defaults to true
type: boolean
yarn_cache:
default: true
description: Should we cache after yarn install? Defaults to true
type: boolean
yarn_cache_folder:
default: /tmp/yarn
description: The path to the yarn cache folder
type: string
steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach_workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- setup_macos_executor:
android: false
detox: false
homebrew_cache: <<parameters.homebrew_cache>>
homebrew_update: <<parameters.homebrew_update>>
node_version: <<parameters.node_version>>
- yarn_install:
cache: <<parameters.yarn_cache>>
cache_folder: <<parameters.yarn_cache_folder>>
- when:
condition: <<parameters.on_after_initialize>>
steps:
- run:
command: <<parameters.on_after_initialize>>
name: on_after_initialize
- when:
condition: <<parameters.start_metro>>
steps:
- metro_start
- when:
condition: <<parameters.pod_install_directory>>
steps:
- pod_install:
cache: <<parameters.pod_cache>>
pod_install_directory: <<parameters.pod_install_directory>>
- ios_build:
build_configuration: <<parameters.build_configuration>>
cache: <<parameters.xcodebuild_cache>>
derived_data_path: <<parameters.derived_data_path>>
device: <<parameters.device>>
project_path: <<parameters.project_path>>
project_type: <<parameters.project_type>>
scheme: <<parameters.scheme>>
ios_build_and_test:
description: Builds the iOS app at the given path with the given build scheme and configuration and then runs the tests with the Detox configuration given.
executor:
name: macos
resource_class: <<parameters.resource_class>>
xcode_version: <<parameters.xcode_version>>
parameters:
attach_workspace:
default: true
description: Boolean for whether or not to attach to an existing workspace. Default is true.
type: boolean
build_configuration:
default: Debug
description: The build configuration to use. This is normally either "Debug" or "Release" but you may have custom build configuration configured for your app.
type: string
checkout:
default: false
description: Boolean for whether or not to checkout as a first step. Default is false.
type: boolean
derived_data_path:
default: ios/build
description: The path to the directory to place the derived data, relative to the root of the repository.
type: string
detox_configuration:
default: ios.sim.release
description: The Detox configuration to test.
type: string
detox_loglevel:
default: warn
description: The Detox logging level to use. Must be one of "fatal", "error", "warn", "info", "verbose", or "trace".
enum:
- fatal
- error
- warn
- info
- verbose
- trace
type: enum
device:
default: iPhone 11
description: The type of device you want to build for.
type: string
homebrew_cache:
default: true
description: Should we cache after brew install? Defaults to true
type: boolean
homebrew_update:
default: true
description: Should we run brew update? Defaults to true
type: boolean
node_version:
default: "16"
description: The version of Node to use. This can be either a major version ("8"), a major and minor ("8.4"), or a fully qualified version ("8.4.1").
type: string
on_after_initialize:
default: ""
description: A custom command to run right after yarn install.
type: string
pod_cache:
default: true
description: Save and restore the CocoaPods cache? Defaults to true
type: boolean
pod_install_directory:
default: ""
description: The location of the "ios" directory for `pod install`. Will skip `pod install` if missing.
type: string
project_path:
description: The path to the Xcode project (*.xcodeproj) or the Xcode workspace (*.xcworkspace) that you want to build, relative to the root of the repository.
type: string
project_type:
default: project
description: If the iOS app is built using a project file (*.xcodeproj) or a workspace.
enum:
- project
- workspace
type: enum
resource_class:
default: medium
description: Changes the resource class of the executor. Requires a support request to enable the resource_class parameter. See https://circleci.com/docs/2.0/configuration-reference/#resource_class
type: string
scheme:
description: The scheme to use.
type: string
start_metro:
default: false
description: If we should start the Metro packager in the background for this job.
type: boolean
store_artifact_path:
default: ""
description: Stores detox artifacts at CircleCI
type: string
workspace_root:
default: .
description: Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory).
type: string
xcode_version:
default: 12.5.1
description: The version of Xcode to use. See here for the list of supported versions https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
type: string
xcodebuild_cache:
default: true
description: Should we cache after Xcode build? Defaults to true
type: boolean
yarn_cache:
default: true
description: Should we cache after yarn install? Defaults to true
type: boolean
yarn_cache_folder:
default: /tmp/yarn
description: The path to the yarn cache folder
type: string
steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- when:
condition: <<parameters.attach_workspace>>
steps:
- attach_workspace:
at: <<parameters.workspace_root>>
- setup_macos_executor:
android: false
homebrew_cache: <<parameters.homebrew_cache>>
homebrew_update: <<parameters.homebrew_update>>
node_version: <<parameters.node_version>>
- ios_simulator_start:
device: <<parameters.device>>
- yarn_install:
cache: <<parameters.yarn_cache>>
cache_folder: <<parameters.yarn_cache_folder>>
- when:
condition: <<parameters.on_after_initialize>>
steps:
- run:
command: <<parameters.on_after_initialize>>
name: on_after_initialize
- when:
condition: <<parameters.start_metro>>
steps:
- metro_start
- when:
condition: <<parameters.pod_install_directory>>
steps:
- pod_install:
cache: <<parameters.pod_cache>>
pod_install_directory: <<parameters.pod_install_directory>>
- ios_build:
build_configuration: <<parameters.build_configuration>>
cache: <<parameters.xcodebuild_cache>>
derived_data_path: <<parameters.derived_data_path>>
device: <<parameters.device>>
project_path: <<parameters.project_path>>
project_type: <<parameters.project_type>>
scheme: <<parameters.scheme>>
- detox_test:
configuration: <<parameters.detox_configuration>>
loglevel: <<parameters.detox_loglevel>>
- when:
condition: <<parameters.store_artifact_path>>
steps:
- store_artifacts:
path: <<parameters.store_artifact_path>>
examples:
android:
description: An example of how to build, test, and release the Android app
usage:
version: "2.1"
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: bundle exec fastlane android release
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/android_build:
build_type: release
requires:
- analyse_js
- rn/android_test:
requires:
- rn/android_build
- fastlane_release:
requires:
- rn/android_test
full:
description: A full setup with a Javascript test job, leading to Detox build and test jobs, and finally releasing the apps using a Fastlane command
usage:
version: "2.1"
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor:
name: rn/linux_js
node_version: "16"
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_android_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: echo
name: Run Fastlane
fastlane_ios_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: echo 1
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/android_build:
build_type: debug
name: build_android_debug
project_path: android
requires:
- analyse_js
- rn/android_build:
build_type: release
name: build_android_release
project_path: android
requires:
- analyse_js
- rn/android_test:
detox_configuration: android.emu.release
requires:
- build_android_release
- rn/ios_build:
build_configuration: Release
device: iPhone 11
name: build_ios_release
node_version: "12"
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- rn/ios_build_and_test:
build_configuration: Release
detox_configuration: ios.sim.release
device: iPhone 11
node_version: "12"
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- fastlane_android_release:
requires:
- rn/android_test
- fastlane_ios_release:
requires:
- rn/ios_build_and_test
ios:
description: An example of how to build, test, and release the iOS app
usage:
version: "2.1"
orbs:
rn: react-native-community/react-native@1.0.0
jobs:
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: yarn eslint
name: Run ESLint
- run:
command: yarn flow
name: Flow
- run:
command: yarn jest
name: Jest
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
paths: .
root: .
fastlane_release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
command: bundle exec fastlane ios release
name: Run Fastlane
workflows:
test:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- rn/ios_build:
build_configuration: Release
device: iPhone 11
name: build_ios_release
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- rn/ios_build_and_test:
build_configuration: Release
detox_configuration: ios.sim.release
device: iPhone 11
project_path: ios/Example.xcodeproj
requires:
- analyse_js
scheme: Example
- fastlane_release:
requires:
- rn/ios_build_and_test