Created
November 20, 2019 14:45
-
-
Save edvinasbartkus/4c09d85ac6f2a2f9eec9d9c8deac5e61 to your computer and use it in GitHub Desktop.
Running Detox tests for Android on Github Actions Workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android | |
on: [push] | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
with: | |
fetch-depth: 1 | |
- name: Node | |
uses: actions/setup-node@v1 | |
- name: Use specific Java version for sdkmanager to work | |
uses: joschi/setup-jdk@v1 | |
with: | |
java-version: 'openjdk8' | |
architecture: 'x64' | |
- name: Download Android Emulator Image | |
run: | | |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-29;google_apis;x86" | |
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name emu --device "Nexus 5X" -k 'system-images;android-29;google_apis;x86' | |
$ANDROID_HOME/emulator/emulator -list-avds | |
- name: Install node_modules | |
run: | | |
yarn install --frozen-lockfile | |
- name: Build for detox | |
run: | | |
yarn build-detox-android | |
- name: Android Emulator | |
timeout-minutes: 10 | |
continue-on-error: true | |
run: | | |
echo "Starting emulator" | |
nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window & | |
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82' | |
$ANDROID_HOME/platform-tools/adb devices | |
echo "Emulator started" | |
- name: Android Detox | |
run: yarn start & yarn test-detox-android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"build-detox-android": "detox build -c android.emu.debug", | |
"test-detox-android": "detox test -c android.emu.debug" | |
}, | |
"detox": { | |
"configurations": { | |
"android.emu.debug": { | |
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", | |
"build": | |
"cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..", | |
"type": "android.emulator", | |
"name": "emu" | |
} | |
} | |
} | |
} |
😅 just went through this... you are correct. my apologies.
the magnitude of time seems in the favor of even downloading/installing given a ~12min build workflow.
I might end up using a self-hosted runner, unsure yet.
Complication with/Lack of KVM related deps on the Linux host drove me to just use a Mac runner for now, will try to circle back if I find a Linux path for this.
Thanks for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@coip yes, I am aware of this. I did try to use Linux for Android Detox. However, I have encountered an issue that was not easily fixable.
If I remember correctly, the problem was that $ANDROID_HOME/tools/bin/sdkmanager and $ANDROID_HOME/tools/bin/adkmanager did not exist. It would require to install Android Build Tools from scratch and it would cause other issues.
I will try to revisit this and maybe this can be optimized.