Skip to content

Commit

Permalink
feat: android detox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Jun 14, 2024
1 parent dcbdc2c commit 28f64fe
Show file tree
Hide file tree
Showing 25 changed files with 505 additions and 69 deletions.
7 changes: 6 additions & 1 deletion .detoxrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// run iPhone 14 on local machine, iPhone 15 Pro on mac mini
const iOSDevice = process.env.MACMINI ? 'iPhone 15 Pro' : 'iPhone 14';

const reversePorts = [8080, 8081, 9735, 10009, 28334, 28335, 28336, 39388, 43782, 60001];

/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
$0: 'jest',
Expand Down Expand Up @@ -28,12 +31,14 @@ module.exports = {
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build:
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd .. ',
reversePorts,
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
build:
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..',
reversePorts,
},
},
devices: {
Expand All @@ -46,7 +51,7 @@ module.exports = {
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_API_29_AOSP',
avdName: 'Pixel_API_31_AOSP',
},
},
},
Expand Down
290 changes: 290 additions & 0 deletions .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
name: e2e-android

on:
workflow_dispatch:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
E2E_TESTS: 1 # build without transform-remove-console babel plugin
DEBUG: 'lnurl* lnurl server'

jobs:
e2e:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: yarn and gradle caches in /mnt
run: |
rm -rf ~/.yarn
rm -rf ~/.gradle
sudo mkdir -p /mnt/.yarn
sudo mkdir -p /mnt/.gradle
sudo chown -R runner /mnt/.yarn
sudo chown -R runner /mnt/.gradle
ln -s /mnt/.yarn /home/runner/
ln -s /mnt/.gradle /home/runner/
- name: Create artifacts directory on /mnt
run: |
sudo mkdir -p /mnt/artifacts
sudo chown -R runner /mnt/artifacts
- name: Specify node version
uses: actions/setup-node@v4
with:
node-version: 20

- name: Use gradle caches
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Use yarn caches
uses: actions/cache@v4
with:
path: ~/.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Activate enviroment variables
run: cp .env.test.template .env

- name: Yarn Install
run: yarn || yarn
env:
HUSKY: 0

- name: Activate Gradle variables
run: |
cp .github/workflows/gradle.properties ~/.gradle/gradle.properties
patch -p1 -i ./.github/workflows/react-native-quick-crypto.patch
- name: Use specific Java version for sdkmanager to work
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Build
run: yarn e2e:build:android-release || yarn e2e:build:android-release

- name: Kill java processes
run: pkill -9 -f java || true

- name: Run regtest setup
run: |
cd docker
mkdir lnd && chmod 777 lnd
docker-compose pull --quiet
docker compose up -d
- name: Wait for electrum server
timeout-minutes: 10
run: while ! nc -z '127.0.0.1' 60001; do sleep 1; done

- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
profile: 5.1in WVGA
api-level: 31
avd-name: Pixel_API_31_AOSP
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047
arch: x86_64
script: yarn e2e:test:android-release --record-videos all --record-logs all --take-screenshots all --headless -d 200000 -R 3 --artifacts-location /mnt/artifacts
# script: avdmanager list device

- uses: actions/upload-artifact@v4
if: failure()
with:
name: e2e-test-videos
path: /mnt/artifacts/

- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2

# - name: Clean docker
# if: ${{ always() }}
# run: |
# cd docker && docker compose down -v
# id: 0 or "tv_1080p"
# Name: Android TV (1080p)
# OEM : Google
# Tag : android-tv
# ---------
# id: 1 or "tv_4k"
# Name: Android TV (4K)
# OEM : Google
# Tag : android-tv
# ---------
# id: 2 or "tv_720p"
# Name: Android TV (720p)
# OEM : Google
# Tag : android-tv
# ---------
# id: 3 or "automotive_1024p_landscape"
# Name: Automotive (1024p landscape)
# OEM : Google
# Tag : android-automotive-playstore
# ---------
# id: 4 or "Galaxy Nexus"
# Name: Galaxy Nexus
# OEM : Google
# ---------
# id: 5 or "desktop_large"
# Name: Large Desktop
# OEM : Google
# Tag : android-desktop
# ---------
# id: 6 or "desktop_medium"
# Name: Medium Desktop
# OEM : Google
# Tag : android-desktop
# ---------
# id: 7 or "Nexus 10"
# Name: Nexus 10
# OEM : Google
# ---------
# id: 8 or "Nexus 4"
# Name: Nexus 4
# OEM : Google
# ---------
# id: 9 or "Nexus 5"
# Name: Nexus 5
# OEM : Google
# ---------
# id: 10 or "Nexus 5X"
# Name: Nexus 5X
# OEM : Google
# ---------
# id: 11 or "Nexus 6"
# Name: Nexus 6
# OEM : Google
# ---------
# id: 12 or "Nexus 6P"
# Name: Nexus 6P
# OEM : Google
# ---------
# id: 13 or "Nexus 7 2013"
# Name: Nexus 7
# OEM : Google
# ---------
# id: 14 or "Nexus 7"
# Name: Nexus 7 (2012)
# OEM : Google
# ---------
# id: 15 or "Nexus 9"
# Name: Nexus 9
# OEM : Google
# ---------
# id: 16 or "Nexus One"
# Name: Nexus One
# OEM : Google
# ---------
# id: 17 or "Nexus S"
# Name: Nexus S
# OEM : Google
# ---------
# id: 18 or "pixel"
# Name: Pixel
# OEM : Google
# ---------
# id: 19 or "pixel_2"
# Name: Pixel 2
# OEM : Google
# ---------
# id: 20 or "pixel_2_xl"
# Name: Pixel 2 XL
# OEM : Google
# ---------
# id: 21 or "pixel_3"
# Name: Pixel 3
# OEM : Google
# ---------
# id: 22 or "pixel_3_xl"
# Name: Pixel 3 XL
# OEM : Google
# OEM : Generic
# ---------
# id: 47 or "4in WVGA (Nexus S)"
# Name: 4" WVGA (Nexus S)
# OEM : Generic
# ---------
# id: 48 or "4.65in 720p (Galaxy Nexus)"
# Name: 4.65" 720p (Galaxy Nexus)
# OEM : Generic
# ---------
# id: 49 or "4.7in WXGA"
# Name: 4.7" WXGA
# OEM : Generic
# ---------
# id: 50 or "5.1in WVGA"
# Name: 5.1" WVGA
# OEM : Generic
# ---------
# id: 51 or "5.4in FWVGA"
# Name: 5.4" FWVGA
# OEM : Generic
# ---------
# id: 52 or "6.7in Foldable"
# Name: 6.7" Horizontal Fold-in
# OEM : Generic
# ---------
# id: 53 or "7in WSVGA (Tablet)"
# Name: 7" WSVGA (Tablet)
# OEM : Generic
# ---------
# id: 54 or "7.4in Rollable"
# Name: 7.4" Rollable
# OEM : Generic
# ---------
# id: 55 or "7.6in Foldable"
# Name: 7.6" Fold-in with outer display
# OEM : Generic
# ---------
# id: 56 or "8in Foldable"
# Name: 8" Fold-out
# OEM : Generic
# ---------
# id: 57 or "10.1in WXGA (Tablet)"
# Name: 10.1" WXGA (Tablet)
# OEM : Generic
# ---------
# id: 58 or "13.5in Freeform"
# Name: 13.5" Freeform
# OEM : Generic
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jobs:

- uses: actions/upload-artifact@v4
if: failure()
# if: ${{ always() }}
with:
name: e2e-test-videos
path: ./artifacts/
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BITKIT_UPLOAD_STORE_FILE=debug.keystore
BITKIT_UPLOAD_STORE_PASSWORD=android
BITKIT_UPLOAD_KEY_ALIAS=androiddebugkey
BITKIT_UPLOAD_KEY_PASSWORD=android
13 changes: 13 additions & 0 deletions .github/workflows/react-native-quick-crypto.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/react-native-quick-crypto/android/build.gradle b/node_modules/react-native-quick-crypto/android/build.gradle
index 2ac6c0db..57afa566 100644
--- a/node_modules/react-native-quick-crypto/android/build.gradle
+++ b/node_modules/react-native-quick-crypto/android/build.gradle
@@ -94,6 +94,8 @@ android {
""
]
doNotStrip '**/*.so'
+ pickFirst 'META-INF/com.android.tools/proguard/coroutines.pro'
+ pickFirst 'META-INF/proguard/coroutines.pro'
}

buildTypes {
9 changes: 9 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ android {
versionName "1.0.1"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

signingConfigs {
Expand Down Expand Up @@ -112,6 +114,7 @@ android {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
packagingOptions {
Expand All @@ -123,10 +126,16 @@ android {
pickFirst 'lib/x86_64/liblog.so'
pickFirst 'lib/armeabi-v7a/liblog.so'
pickFirst 'lib/arm64-v8a/liblog.so'

pickFirst 'lib/arm64-v8a/libjsi.so'
pickFirst 'lib/armeabi-v7a/libjsi.so'
pickFirst 'lib/x86/libjsi.so'
pickFirst 'lib/x86_64/libjsi.so'
}
}

dependencies {
androidTestImplementation('com.wix:detox:+')
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation files("../../node_modules/@synonymdev/react-native-ldk/android/libs/LDK-release.aar")
Expand Down
Loading

0 comments on commit 28f64fe

Please sign in to comment.