-
-
Save Grohden/2ea8975d51754117ea15977338d89293 to your computer and use it in GitHub Desktop.
trigger: | |
- none | |
pool: | |
vmImage: 'ubuntu-latest' | |
variables: | |
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn | |
GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle | |
steps: | |
- task: NodeTool@0 | |
inputs: | |
versionSpec: '12.9.1' | |
displayName: 'Install Node' | |
- task: Cache@2 | |
inputs: | |
key: 'gradle | "$(Agent.OS)"' | |
restoreKeys: gradle | |
path: $(GRADLE_USER_HOME) | |
displayName: 'Gradle build cache' | |
- task: Cache@2 | |
inputs: | |
key: 'yarn | "$(Agent.OS)" | yarn.lock' | |
restoreKeys: | | |
yarn | "$(Agent.OS)" | |
yarn | |
path: $(YARN_CACHE_FOLDER) | |
displayName: 'Cache Yarn packages' | |
- script: yarn --frozen-lockfile | |
displayName: 'Install dependencies' | |
- task: Cache@2 | |
inputs: | |
key: 'AVD_IMAGES_29' | |
path: '$(ANDROID_HOME)/system-images' | |
cacheHitVar: 'AVD_IMAGES_RESTORED' | |
continueOnError: true | |
condition: succeededOrFailed() | |
displayName: 'Caching System Images for AVD' | |
- script: | | |
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 | |
condition: ne(variables.AVD_IMAGES_RESTORED, 'true') | |
displayName: 'Download Android Emulator Image' | |
- script: yarn detox:build | |
displayName: 'Build detox' | |
- script: | | |
echo "Starting emulator" | |
nohup $ANDROID_HOME/emulator/emulator -avd emu -no-snapshot -no-audio -no-boot-anim -accel auto -gpu auto -qemu -lcd-density 420 > /dev/null 2>&1 & | |
$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" | |
displayName: 'Android Emulator' | |
- script: yarn detox:run | |
displayName: 'Detox test' |
trigger: | |
- none | |
pool: | |
vmImage: 'macos-latest' | |
variables: | |
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn | |
steps: | |
- task: NodeTool@0 | |
inputs: | |
versionSpec: '12.9.1' | |
displayName: 'Install Node' | |
- task: Cache@2 | |
inputs: | |
key: 'yarn | "$(Agent.OS)" | yarn.lock' | |
restoreKeys: | | |
yarn | "$(Agent.OS)" | |
yarn | |
path: $(YARN_CACHE_FOLDER) | |
displayName: 'Cache Yarn packages' | |
- script: yarn --frozen-lockfile | |
displayName: 'Install dependencies' | |
- script: | | |
yarn codegen | |
yarn type-check | |
displayName: 'Codegen and type-check' | |
- task: CocoaPods@0 | |
inputs: | |
workingDirectory: 'ios' | |
forceRepoUpdate: false | |
- script: | | |
brew tap wix/brew | |
brew install applesimutils | |
displayName: 'Install Detox Tools' | |
- script: | | |
yarn detox:build | |
displayName: 'Build detox' | |
- script: | | |
yarn detox:test | |
displayName: 'Detox test' |
You are a god among men, worked on macOs-latest out of the box with minor tweaks.
@badsyntax you're right, it doesn't work on non macos agents.. I recall myself trying the android/ubuntu-latest one only to find out it doesn't support emulator... so I switched to macos one
Now I would consider trying the official docker image for RN in the android one (I don't recall how to use azure devops in depth anymore so I won't be updating this gists XD)
@asenmitrev
thank you, I'm really glad I can help other devs ❤️
Could you share which parameters are you passing to avdmanager and emulator tools? In my case, it gets stuck on adb wait-for-device
I am using macOs-latest image
@tomasfly I'm sorry, I'm not using azure since some months after posting this
You can however try to boot the emulator without the nohup part and look at the logs
The emulator would not complete the boot sequence for me on ubuntu, it just forever hanged, and I had to use a macos agent for android.
The docs also state: