Skip to content

Commit 697a295

Browse files
committed
ci: use detox for ui test, opt code
1 parent 9c673c2 commit 697a295

File tree

28 files changed

+1770
-1063
lines changed

28 files changed

+1770
-1063
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test
1+
name: CI
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
@@ -74,7 +74,8 @@ jobs:
7474
assets/**
7575
package.json
7676
!example/ios/**
77-
77+
example/e2e/**
78+
7879
- uses: actions/cache@v3
7980
name: Cache node_modules
8081
if: steps.verify-android-changed-files.outputs.files_changed == 'true'
@@ -143,7 +144,7 @@ jobs:
143144
name: app-release-${{ github.sha }}.apk
144145
path: ${{ github.workspace }}/example/android/app-release-${{ github.sha }}.apk
145146

146-
android-test:
147+
android-api-level-test:
147148
runs-on: macos-latest
148149
needs: android-build
149150
name: Android Test
@@ -165,6 +166,7 @@ jobs:
165166
assets/**
166167
package.json
167168
!example/ios/**
169+
example/e2e/**
168170
169171
- uses: actions/cache@v3
170172
name: Cache node_modules
@@ -247,6 +249,7 @@ jobs:
247249
assets/**
248250
package.json
249251
!example/android/**
252+
example/e2e/**
250253
251254
- uses: actions/cache@v3
252255
name: Cache node_modules
@@ -309,7 +312,7 @@ jobs:
309312
310313
ci-complete:
311314
name: Complete CI
312-
needs: [android-build, android-test, ios-build-test]
315+
needs: [android-build, android-api-level-test, ios-build-test]
313316
if: ${{ always() }}
314317
runs-on: ubuntu-latest
315318
steps:

README.MD

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
</div>
88
<div align="center">
99

10-
[![npm version](https://img.shields.io/npm/v/react-native-image-marker.svg?logo=npm)](https://www.npmjs.com/package/react-native-image-marker)
11-
[![npm](https://img.shields.io/npm/dm/react-native-image-marker?logo=npm)](https://www.npmjs.com/package/react-native-image-marker) [![npm](https://img.shields.io/npm/dt/react-native-image-marker.svg?cacheSeconds=88660&logo=npm&label=total%20downloads)](https://www.npmjs.com/package/react-native-image-marker)
12-
[![stars](https://img.shields.io/github/stars/jimmydaddy/react-native-image-marker?style=social)](https://github.com/JimmyDaddy/react-native-image-marker) [![forks](https://img.shields.io/github/forks/jimmydaddy/react-native-image-marker?style=social)](https://github.com/JimmyDaddy/react-native-image-marker/fork)
13-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?logo=github)](https://github.com/JimmyDaddy/react-native-image-marker/pulls) ![license](https://img.shields.io/npm/l/react-native-image-marker)
14-
[![github](https://img.shields.io/badge/github-repo-blue?logo=github)](https://github.com/JimmyDaddy/react-native-image-marker)
15-
[![Native Build and Test](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/native-ci.yml/badge.svg)](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/native-ci.yml)
16-
![platform-iOS](https://img.shields.io/badge/iOS-black?logo=Apple) ![platform-Android](https://img.shields.io/badge/Android-black?logo=Android)
10+
[![npm version](https://img.shields.io/npm/v/react-native-image-marker.svg?logo=npm&style=for-the-badge&label=latest)](https://www.npmjs.com/package/react-native-image-marker)
11+
[![npm](https://img.shields.io/npm/dm/react-native-image-marker?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/react-native-image-marker) [![npm](https://img.shields.io/npm/dt/react-native-image-marker.svg?cacheSeconds=88660&logo=npm&label=total%20downloads&style=for-the-badge)](https://www.npmjs.com/package/react-native-image-marker)
12+
[![stars](https://img.shields.io/github/stars/jimmydaddy/react-native-image-marker?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker) [![forks](https://img.shields.io/github/forks/jimmydaddy/react-native-image-marker?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker/fork)
13+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker/pulls) ![license](https://img.shields.io/npm/l/react-native-image-marker?style=for-the-badge)
14+
[![github](https://img.shields.io/badge/github-repo-blue?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker)
15+
[![CI](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml/badge.svg)](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml)
16+
![platform-iOS](https://img.shields.io/badge/iOS-black?logo=Apple&style=for-the-badge) ![platform-Android](https://img.shields.io/badge/Android-black?logo=Android&style=for-the-badge)
1717
<br/>
1818

1919
</div>

example/.detoxrc.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/** @type {Detox.DetoxConfig} */
2+
module.exports = {
3+
testRunner: {
4+
args: {
5+
'$0': 'jest',
6+
config: 'e2e/jest.config.js'
7+
},
8+
jest: {
9+
setupTimeout: 120000
10+
}
11+
},
12+
apps: {
13+
'ios.debug': {
14+
type: 'ios.app',
15+
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/ImageMarkerExample.app',
16+
build: 'xcodebuild -workspace ios/ImageMarkerExample.xcworkspace -scheme ImageMarkerExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
17+
},
18+
'ios.release': {
19+
type: 'ios.app',
20+
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/ImageMarkerExample.app',
21+
build: 'xcodebuild -workspace ios/ImageMarkerExample.xcworkspace -scheme ImageMarkerExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
22+
},
23+
'android.debug': {
24+
type: 'android.apk',
25+
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
26+
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
27+
reversePorts: [
28+
8081
29+
]
30+
},
31+
'android.release': {
32+
type: 'android.apk',
33+
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
34+
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
35+
}
36+
},
37+
devices: {
38+
simulator: {
39+
type: 'ios.simulator',
40+
device: {
41+
type: 'iPhone 15'
42+
}
43+
},
44+
attached: {
45+
type: 'android.attached',
46+
device: {
47+
adbName: '.*'
48+
}
49+
},
50+
emulator: {
51+
type: 'android.emulator',
52+
device: {
53+
avdName: 'Pixel_XL_API_34'
54+
}
55+
}
56+
},
57+
configurations: {
58+
'ios.sim.debug': {
59+
device: 'simulator',
60+
app: 'ios.debug'
61+
},
62+
'ios.sim.release': {
63+
device: 'simulator',
64+
app: 'ios.release'
65+
},
66+
'android.att.debug': {
67+
device: 'attached',
68+
app: 'android.debug'
69+
},
70+
'android.att.release': {
71+
device: 'attached',
72+
app: 'android.release'
73+
},
74+
'android.emu.debug': {
75+
device: 'emulator',
76+
app: 'android.debug'
77+
},
78+
'android.emu.release': {
79+
device: 'emulator',
80+
app: 'android.release'
81+
}
82+
}
83+
};

example/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ android {
100100
targetSdkVersion rootProject.ext.targetSdkVersion
101101
versionCode 1
102102
versionName "1.0"
103+
testBuildType System.getProperty('testBuildType', 'debug')
104+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
103105
}
104106

105107
splits {
@@ -134,6 +136,7 @@ android {
134136
signingConfig signingConfigs.release
135137
minifyEnabled enableProguardInReleaseBuilds
136138
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
139+
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
137140
}
138141
}
139142

@@ -174,6 +177,10 @@ dependencies {
174177
testImplementation 'junit:junit:4.13.2'
175178
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
176179
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
180+
androidTestImplementation('com.wix:detox:+')
181+
implementation 'androidx.appcompat:appcompat:1.1.0'
182+
implementation project(':react-native-vector-icons')
177183
}
178184

179185
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
186+
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.imagemarkerexample;
2+
3+
import com.wix.detox.Detox;
4+
import com.wix.detox.config.DetoxConfig;
5+
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import androidx.test.ext.junit.runners.AndroidJUnit4;
11+
import androidx.test.filters.LargeTest;
12+
import androidx.test.rule.ActivityTestRule;
13+
14+
@RunWith(AndroidJUnit4.class)
15+
@LargeTest
16+
public class DetoxTest {
17+
@Rule // (2)
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
DetoxConfig detoxConfig = new DetoxConfig();
23+
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
24+
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
25+
detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);
26+
27+
Detox.runTests(mActivityRule, detoxConfig);
28+
}
29+
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
android:icon="@mipmap/ic_launcher"
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:allowBackup="false"
11+
android:networkSecurityConfig="@xml/network_security_config"
12+
android:usesCleartextTraffic="true"
1113
android:theme="@style/AppTheme">
1214
<activity
1315
android:name=".MainActivity"

example/android/app/src/main/java/com/imagemarkerexample/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.facebook.react.defaults.DefaultReactNativeHost;
1010
import com.facebook.soloader.SoLoader;
1111
import java.util.List;
12+
import com.oblador.vectoricons.VectorIconsPackage;
1213

1314
public class MainApplication extends Application implements ReactApplication {
1415

@@ -25,6 +26,7 @@ protected List<ReactPackage> getPackages() {
2526
List<ReactPackage> packages = new PackageList(this).getPackages();
2627
// Packages that cannot be autolinked yet can be added manually here, for example:
2728
// packages.add(new MyReactNativePackage());
29+
packages.add(new VectorIconsPackage());
2830
return packages;
2931
}
3032

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<domain-config cleartextTrafficPermitted="true">
4+
<domain includeSubdomains="true">10.0.2.2</domain>
5+
<domain includeSubdomains="true">localhost</domain>
6+
</domain-config>
7+
</network-security-config>

example/android/build.gradle

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

3+
34
buildscript {
4-
ext {
5+
def kotlin_version = project.properties["ImageMarkerExample_kotlinVersion"]
6+
ext {
57
buildToolsVersion = "33.0.0"
68
minSdkVersion = 24
79
compileSdkVersion = 33
810
targetSdkVersion = 33
911

1012
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
1113
ndkVersion = "23.1.7779620"
14+
kotlinVersion = "$kotlin_version"
1215
}
1316
repositories {
1417
google()
@@ -18,9 +21,28 @@ buildscript {
1821
maven { url "https://repository.jboss.org/maven2" }
1922
maven { url 'https://maven.google.com' }
2023
maven { url 'https://maven.fabric.io/public' }
24+
maven {
25+
url("$rootDir/../node_modules/detox/Detox-android")
26+
}
2127
}
2228
dependencies {
2329
classpath('com.android.tools.build:gradle:7.4.2')
2430
classpath("com.facebook.react:react-native-gradle-plugin")
31+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
32+
}
33+
}
34+
35+
allprojects {
36+
repositories {
37+
google()
38+
mavenCentral()
39+
jcenter()
40+
maven { url 'https://dl.google.com/dl/android/maven2' }
41+
maven { url "https://repository.jboss.org/maven2" }
42+
maven { url 'https://maven.google.com' }
43+
maven { url 'https://maven.fabric.io/public' }
44+
maven {
45+
url("$rootDir/../node_modules/detox/Detox-android")
2546
}
47+
}
2648
}

example/android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ newArchEnabled=false
4242
# Use this property to enable or disable the Hermes JS engine.
4343
# If set to false, you will be using JSC instead.
4444
hermesEnabled=true
45+
46+
ImageMarkerExample_kotlinVersion=1.7.0
47+

0 commit comments

Comments
 (0)