1
1
version : 2
2
2
3
- # Defaults
3
+ # ==============================
4
+ # DEFAULTS FOR JOBS
5
+ # ==============================
6
+
4
7
default job config : &defaults
5
8
working_directory : ~/async_storage
9
+
10
+ checkout step for each job : &addWorkspace
11
+ attach_workspace :
12
+ at : ~/async_storage
13
+
14
+ # ==============================
15
+ # ENVIRONMENT VARIABLES
16
+ # ==============================
17
+
18
+ default config for js : &js_defaults
19
+ << : *defaults
6
20
docker :
7
21
- image : circleci/node:8
8
22
9
- checkout step for each job : &addWorkspace
10
- attach_workspace :
11
- at : ~/
23
+ default config for macOS : &macos_defaults
24
+ << : *defaults
25
+ resource_class : ' medium'
26
+ macos :
27
+ xcode : ' 10.1.0'
28
+
29
+ default config for android apk builds : &android_defaults
30
+ << : *defaults
31
+ docker :
32
+ - image : reactnativecommunity/react-native-android
33
+ resource_class : ' medium'
34
+ working_directory : ~/async_storage
35
+ environment :
36
+ - _JAVA_OPTIONS : ' -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xmx2048m'
37
+ - GRADLE_OPTS : ' -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError -Xmx2048m"'
38
+ - BUILD_THREADS : 2
39
+
40
+ # ==============================
41
+ # CACHE CONFIG
42
+ # ==============================
43
+
44
+ # brew
45
+ save brew cache : &cache_save_brew
46
+ name : Saving Brew cache
47
+ paths :
48
+ - /usr/local/Homebrew
49
+ - ~/Library/Caches/Homebrew
50
+ key : v1-brew-cache-{{ arch }}
51
+
52
+ restore brew cache : &cache_restore_brew
53
+ name : Restoring Brew cache
54
+ keys :
55
+ - v1-brew-cache-{{ arch }}
56
+
57
+ save brew cache for android : &cache_save_brew_android
58
+ name : Saving Brew cache for android
59
+ paths :
60
+ - /usr/local/Homebrew
61
+ - ~/Library/Caches/Homebrew
62
+ key : v1-brew-cache-{{ arch }}-android
63
+
64
+ restore brew cache for android : &cache_restore_brew_android
65
+ name : Restoring Brew cache for android
66
+ keys :
67
+ - v1-brew-cache-{{ arch }}-android
68
+
69
+ # yarn
70
+ save yarn cache : &cache_save_yarn
71
+ name : Saving Yarn cache
72
+ paths :
73
+ - ~/.cache/yarn
74
+ - ~/Library/Detox
75
+ key : v1-yarn-cache-{{ checksum "package.json" }}-{{ arch }}
76
+
77
+ restore yarn cache : &cache_restore_yarn
78
+ name : Restoring Yarn cache
79
+ keys :
80
+ - v1-yarn-cache-{{ checksum "package.json" }}-{{ arch }}
12
81
82
+ # gradle
83
+ save gradle wrapper cache : &cache_save_gradle_wrapper
84
+ name : Saving Gradle Wrapper cache
85
+ paths :
86
+ - ~/.gradle/wrapper
87
+ key : gradle-wrapper-v1-{{ checksum "example/android/gradle/wrapper/gradle-wrapper.properties" }}
88
+
89
+ save gradle build cache : &cache_save_gradle_build
90
+ name : Saving Gradle app/build cache
91
+ paths :
92
+ - ~/.gradle/caches
93
+ key : app-build-gradle-v1-{{ checksum "example/android/app/build.gradle" }}
94
+
95
+ restore gradle wrapper cache : &cache_restore_gradle_wrapper
96
+ name : Restoring Gradle Wrapper cache
97
+ keys :
98
+ - gradle-wrapper-v1-{{ checksum "example/android/gradle/wrapper/gradle-wrapper.properties" }}
99
+
100
+ restore gradle build cache : &cache_restore_gradle_build
101
+ name : Restoring Gradle app/build cache
102
+ keys :
103
+ - app-build-gradle-v1-{{ checksum "example/android/app/build.gradle" }}
104
+
105
+
106
+ # ==============================
107
+ # JOBS
108
+ # ==============================
13
109
14
110
jobs :
15
111
" Setup environment " :
16
- << : *defaults
112
+ << : *js_defaults
17
113
steps :
18
114
- checkout
19
- - restore_cache :
20
- name : Restore node modules
21
- keys :
22
- - node_modules-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
115
+ - restore-cache : *cache_restore_yarn
23
116
- run :
24
117
name : Install dependencies
25
- command : yarn --pure-lockfile --non-interactive
26
- - save_cache :
27
- name : Save node modules
28
- key : node_modules-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
29
- paths :
30
- - node_modules
118
+ command : yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn
119
+ - save-cache : *cache_save_yarn
31
120
- persist_to_workspace :
32
121
root : .
33
122
paths : .
34
123
35
124
" Test: lint " :
36
- << : *defaults
125
+ << : *js_defaults
37
126
steps :
38
127
- *addWorkspace
39
128
- run :
40
129
name : Lint check
41
130
command : yarn test:lint
42
131
43
132
" Test: flow " :
44
- << : *defaults
133
+ << : *js_defaults
45
134
steps :
46
135
- *addWorkspace
47
136
- run :
48
137
name : Flow check
49
138
command : yarn test:flow
50
139
140
+ " Test: iOS e2e " :
141
+ << : *macos_defaults
142
+ steps :
143
+ - *addWorkspace
144
+ - restore-cache : *cache_restore_brew
145
+ - run :
146
+ name : Configure OSX Environment
147
+ command : |
148
+ HOMEBREW_NO_AUTO_UPDATE=1 brew install node@8 >/dev/null
149
+ HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
150
+ HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
151
+ touch .watchmanconfig
152
+ node -v
153
+ - save-cache : *cache_save_brew
154
+ - restore-cache : *cache_restore_yarn
155
+ - run :
156
+ name : Installing Yarn dependencies
157
+ command : yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn
158
+ - save-cache : *cache_save_yarn
159
+ - run :
160
+ name : Build iOS app
161
+ command : yarn build:e2e:ios
162
+
163
+ - run :
164
+ name : Run e2e tests
165
+ command : yarn test:e2e:ios
166
+
167
+ " Build: Android release apk " :
168
+ << : *android_defaults
169
+ steps :
170
+ - *addWorkspace
171
+ - restore-cache : *cache_restore_yarn
172
+ - run :
173
+ name : Installing Yarn dependencies
174
+ command : yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn
175
+ - save-cache : *cache_save_yarn
176
+
177
+ # Gradle
178
+ - restore-cache : *cache_restore_gradle_wrapper
179
+ - restore-cache : *cache_restore_gradle_build
180
+ - run :
181
+ name : Downloading Gradle dependencies
182
+ command : cd example/android && ./gradlew --max-workers 2 fetchDependencies
183
+ - save-cache : *cache_save_gradle_wrapper
184
+ - save-cache : *cache_save_gradle_build
185
+
186
+ # Build and test
187
+ - run :
188
+ name : Build Android apk
189
+ command : cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2
190
+
191
+ - persist_to_workspace :
192
+ root : ~/async_storage
193
+ paths :
194
+ - example/android/app/build/outputs/apk/*
195
+
196
+ " Test: Android e2e " :
197
+ << : *macos_defaults
198
+ steps :
199
+ - *addWorkspace
200
+ - run :
201
+ name : Configure env variables
202
+ command : |
203
+ echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
204
+ echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV
205
+ echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/tools/bin:$PATH"' >> $BASH_ENV
206
+ echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
207
+ echo 'export JAVA_HOME=/Library/Java/Home' >> $BASH_ENV
208
+ source $BASH_ENV
209
+
210
+ # Android tools
211
+ - restore-cache : *cache_restore_brew_android
212
+ - run :
213
+ name : Install Android SDK tools
214
+ command : |
215
+ HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask >/dev/null
216
+ HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk >/dev/null
217
+ HOMEBREW_NO_AUTO_UPDATE=1 brew cask install intel-haxm >/dev/null
218
+ HOMEBREW_NO_AUTO_UPDATE=1 brew install node@8 >/dev/null >/dev/null
219
+ - save-cache : *cache_save_brew_android
220
+
221
+ - run :
222
+ name : Install Android emulator
223
+ shell : /bin/bash -e
224
+ command : |
225
+ yes | sdkmanager "platform-tools" "tools" >/dev/null
226
+ yes | sdkmanager "platforms;android-28" "system-images;android-21;google_apis;x86" >/dev/null
227
+ yes | sdkmanager "emulator" --channel=3 >/dev/null
228
+ yes | sdkmanager "build-tools;28.0.3" >/dev/null
229
+ yes | sdkmanager --licenses >/dev/null
230
+ yes | sdkmanager --list
231
+
232
+ - run :
233
+ name : ADB start/stop
234
+ command : |
235
+ adb start-server
236
+ adb devices
237
+ adb kill-server
238
+ ls -la ~/.android
239
+
240
+ - run :
241
+ name : Create emulator
242
+ command : |
243
+ avdmanager create avd \
244
+ --force \
245
+ -n "Emu_E2E" \
246
+ -k "system-images;android-21;google_apis;x86" \
247
+ -g "google_apis" \
248
+ -d "Nexus 4"
249
+
250
+
251
+
252
+ - run :
253
+ name : Start emulator in background
254
+ background : true
255
+ command : |
256
+ emulator -avd "Emu_E2E" \
257
+ -cores 1 \
258
+ -gpu auto \
259
+ -accel on \
260
+ -memory 1024 \
261
+ -no-audio \
262
+ -no-snapshot \
263
+ -no-boot-anim \
264
+ -no-window \
265
+ -logcat '*:W' | grep -i "ReactNative"
266
+
267
+ - run :
268
+ name : Wait for emulator to boot
269
+ command : yarn build:e2e:android
270
+
271
+ - run :
272
+ name : Wake device
273
+ command : |
274
+ adb shell input keyevent
275
+ adb shell input keyevent 82 &
276
+
277
+ - run :
278
+ name : Run e2e tests
279
+ command : yarn test:e2e:android
280
+
281
+ # ==============================
282
+ # WORK FLOWS
283
+ # ==============================
51
284
workflows :
52
285
version : 2
53
- " Basic check " :
286
+ " Testing " :
54
287
jobs :
55
288
- " Setup environment"
56
289
- " Test: lint " :
57
290
requires :
58
291
- " Setup environment"
59
292
- " Test: flow " :
60
293
requires :
61
- - " Setup environment"
294
+ - " Setup environment"
295
+ - " Test: iOS e2e " :
296
+ requires :
297
+ - " Test: lint"
298
+ - " Test: flow"
299
+ - " Build: Android release apk " :
300
+ requires :
301
+ - " Test: lint"
302
+ - " Test: flow"
303
+ - " Test: Android e2e " :
304
+ requires :
305
+ - " Test: lint"
306
+ - " Test: flow"
307
+ - " Build: Android release apk"
0 commit comments