File tree Expand file tree Collapse file tree 7 files changed +43
-9
lines changed
android/src/main/java/com/reactnativecommunity/asyncstorage Expand file tree Collapse file tree 7 files changed +43
-9
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ cache keys:
52
52
brew ios : &key_brew_ios cache-brew-ios-v4-{{ arch }}
53
53
brew android : &key_brew_android cache-brew-android-v4-{{ arch }}
54
54
yarn : &key_yarn cache-yarn-{{ checksum "package.json" }}-{{ arch }}
55
- gradle : &key_gradle cache-gradle-{{ checksum "example/android/gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "package.json" }}-{{ arch }}
55
+ gradle : &key_gradle cache-gradle-v1- {{ checksum "example/android/gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "package.json" }}-{{ arch }}
56
56
pods : &key_pods cache-pods-v1-{{ checksum "example/ios/Podfile" }}-{{ checksum "package.json" }}-{{ arch }}
57
57
58
58
cache :
@@ -216,8 +216,12 @@ jobs:
216
216
name : Bundle JS
217
217
command : yarn bundle:android --dev false
218
218
- run :
219
- name : Build APK
219
+ name : Build APKs
220
220
command : yarn build:e2e:android
221
+ - run :
222
+ name : Build APK with Next storage
223
+ working_directory : example/android
224
+ command : ./gradlew assembleNext --max-workers 2
221
225
- persist_to_workspace :
222
226
root : ~/async_storage
223
227
paths :
@@ -292,6 +296,9 @@ jobs:
292
296
- run :
293
297
name : Run e2e tests
294
298
command : yarn test:e2e:android
299
+ - run :
300
+ name : Run e2e tests for Next storage
301
+ command : yarn detox test -c android.emu.release.next --maxConcurrency 1
295
302
296
303
Release :
297
304
<< : *js_defaults
Original file line number Diff line number Diff line change 3
3
import java .util .ArrayDeque ;
4
4
import java .util .concurrent .Executor ;
5
5
6
- // Adapted from https://android.googlesource.com/platform/frameworks/base.git/+/1488a3a19d4681a41fb45570c15e14d99db1cb66/core/java/android/os/AsyncTask.java#237
6
+ /**
7
+ * Detox is using this implementation detail in its environment setup,
8
+ * so in order for Next storage to work, this class has been made public
9
+ *
10
+ * Adapted from https://android.googlesource.com/platform/frameworks/base.git/+/1488a3a19d4681a41fb45570c15e14d99db1cb66/core/java/android/os/AsyncTask.java#237
11
+ */
7
12
public class SerialExecutor implements Executor {
8
13
private final ArrayDeque <Runnable > mTasks = new ArrayDeque <Runnable >();
9
14
private Runnable mActive ;
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ fun ReadableArray.toEntryList(): List<Entry> {
14
14
val key = keyValue[0 ]
15
15
val value = keyValue[1 ]
16
16
17
- if (key == null || key !is String ) {
17
+ if (key !is String ) {
18
18
when (key) {
19
19
null -> throw AsyncStorageError .keyIsNull()
20
- !is String -> throw AsyncStorageError .keyNotString()
20
+ else -> throw AsyncStorageError .keyNotString()
21
21
}
22
22
}
23
23
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ import kotlinx.coroutines.launch
19
19
class StorageModule (reactContext : ReactContext ) : ReactContextBaseJavaModule(), CoroutineScope {
20
20
override fun getName () = " RNC_AsyncSQLiteDBStorage"
21
21
22
- // this executor is here only to please detox, which relies on internal implementation
23
- // of current Async Storage
22
+ // this executor is not used by the module, but it must exists here due to
23
+ // Detox relying on this implementation detail to run
24
24
@VisibleForTesting
25
25
private val executor = SerialExecutor (Dispatchers .Main .asExecutor())
26
26
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ task fetchDependencies() {
28
28
buildscript {
29
29
ext. kotlinVersion = ' 1.4.21'
30
30
31
+ // Mainly for Detox testing for using Next Storage
32
+ // when building next, force using next storage
33
+ if (gradle. startParameter. getTaskNames(). contains(" assembleNext" )) {
34
+ rootProject. setProperty(" AsyncStorage_useNextStorage" , " true" )
35
+ }
36
+ Boolean nextStorageFlag = rootProject. hasProperty(" AsyncStorage_useNextStorage" ) ? rootProject. properties[" AsyncStorage_useNextStorage" ] == " true" : false
37
+ println (" [Async Storage] Using Next storage: " + nextStorageFlag)
38
+
31
39
repositories {
32
40
google()
33
41
jcenter()
@@ -64,8 +72,14 @@ allprojects {
64
72
keyPassword ' android'
65
73
}
66
74
}
67
-
68
75
androidExtension. buildTypes. release. signingConfig = androidExtension. signingConfigs. test
76
+ androidExtension. buildTypes {
77
+ next {
78
+ initWith release
79
+ matchingFallbacks = [" debug" , " release" ]
80
+ }
81
+ }
82
+
69
83
androidExtension. testBuildType = ' release'
70
84
71
85
androidExtension. sourceSets. androidTest. java. srcDirs + = " $rootDir /app/src/androidTest/java"
Original file line number Diff line number Diff line change 128
128
"device" : {
129
129
"avdName" : " Emu_E2E"
130
130
}
131
+ },
132
+ "android.emu.release.next" : {
133
+ "binaryPath" : " example/android/app/build/outputs/apk/next/app-next.apk" ,
134
+ "testBinaryPath" : " example/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk" ,
135
+ "type" : " android.emulator" ,
136
+ "device" : {
137
+ "avdName" : " Emu_E2E"
138
+ }
131
139
}
132
140
}
133
141
},
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ MAX_RETRIES=60 # wait max 5 minutes for emu to boot
6
6
build_apk () {
7
7
echo
8
8
echo " [Detox e2e] Building APK"
9
- (cd example/android; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2)
9
+ (cd example/android; ./gradlew assembleRelease assembleAndroidTest -PAsyncStorage_useNextStorage=false - DtestBuildType=release --max-workers 2)
10
10
}
11
11
12
12
bundle_js () {
You can’t perform that action at this time.
0 commit comments