Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Detox Android on CircleCI #465

Merged
merged 10 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ aliases:
orbs:
node: circleci/[email protected]
browser-tools: circleci/[email protected]
android: circleci/[email protected]

executors:
default:
Expand Down Expand Up @@ -210,6 +211,36 @@ jobs:
name: Run Detox on iOS
command: yarn e2e:ios
- save-cache-detox-app
test-android:
parameters:
react-native-version:
type: string
executor:
name: android/android-machine
resource-class: large
tag: 2023.11.1
working_directory: ~/react-native-url-polyfill/platforms/react-native/<< parameters.react-native-version >>
steps:
- attach-workspace
- install-node
- install-yarn-dependencies
- run:
name: List available SDKs
command: sdkmanager --list
- android/create-avd:
avd-name: TestingAVD
install: true
system-image: system-images;android-34;default;x86_64
- android/start-emulator:
avd-name: TestingAVD
no-window: true
post-emulator-launch-assemble-command: ''
restore-gradle-cache-prefix: v1a
- run:
name: Run Detox
command: yarn e2e:android
- android/save-gradle-cache:
cache-prefix: v1a
test-hermes-android:
parameters:
react-native-version:
Expand Down Expand Up @@ -292,16 +323,10 @@ workflows:
requires:
- lint
- test-js
- test-hermes-ios:
matrix:
parameters:
react-native-version: ['0.68']
requires:
- test-ios-<< matrix.react-native-version >>
- test-hermes-android:
- test-android:
matrix:
parameters:
react-native-version: ['0.68']
react-native-version: ['0.68', '0.72']
requires:
- lint
- test-js
Expand All @@ -312,3 +337,15 @@ workflows:
# requires:
# - lint
# - test-js
- test-hermes-ios:
matrix:
parameters:
react-native-version: ['0.68']
requires:
- test-ios-<< matrix.react-native-version >>
- test-hermes-android:
matrix:
parameters:
react-native-version: ['0.68']
requires:
- test-android-<< matrix.react-native-version >>
2 changes: 1 addition & 1 deletion platforms/detox/.detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_3a_API_34_extension_level_7_arm64-v8a',
avdName: 'TestingAVD',
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions platforms/react-native/0.68/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ android {
}
}
}

testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

if (isNewArchitectureEnabled()) {
Expand Down Expand Up @@ -260,6 +263,9 @@ android {
}

dependencies {
androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.1.0'

implementation fileTree(dir: "libs", include: ["*.jar"])

//noinspection GradleDynamicVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.detox;

import com.wix.detox.Detox;
import com.wix.detox.config.DetoxConfig;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void runDetoxTests() {
DetoxConfig detoxConfig = new DetoxConfig();
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);

Detox.runTests(mActivityRule, detoxConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
<provider
android:name="com.facebook.react.modules.blob.BlobProvider"
android:authorities="@string/blob_provider_authority"
android:exported="false"
/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand All @@ -22,5 +23,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="com.facebook.react.modules.blob.BlobProvider"
android:authorities="@string/blob_provider_authority"
android:exported="false"
/>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Detox</string>
<string name="blob_provider_authority">com.detox.blobs</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
5 changes: 5 additions & 0 deletions platforms/react-native/0.68/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os

buildscript {
ext {
kotlinVersion = '1.6.21'
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
Expand All @@ -25,6 +26,7 @@ buildscript {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:4.1.2")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -47,6 +49,9 @@ allprojects {
excludeGroup "com.facebook.react"
}
}
maven {
url "$rootDir/../node_modules/detox/Detox-android"
}
google()
maven { url 'https://www.jitpack.io' }
}
Expand Down
3 changes: 3 additions & 0 deletions platforms/react-native/0.68/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"build:ios": "detox build --configuration ios.sim.release",
"test:ios": "detox test --configuration ios.sim.release --cleanup",
"e2e:ios": "yarn build:ios && yarn test:ios",
"build:android": "detox build --configuration android.emu.release",
"test:android": "detox test --configuration android.emu.release",
"e2e:android": "yarn build:android && yarn test:android",
"postinstall": "patch-package"
},
"dependencies": {
Expand Down
Loading