Azure devops detox run tests for ios and android

Home   »   Azure devops detox run tests for ios and android

trigger:
- none

pool:
  vmImage: 'ubuntu-latest'

variables:
  YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
  GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle

steps:
- task: [email protected]
  inputs:
    versionSpec: '12.9.1'
  displayName: 'Install Node'

- task: [email protected]
  inputs:
    key: 'gradle | "$(Agent.OS)"'
    restoreKeys: gradle
    path: $(GRADLE_USER_HOME)
  displayName: 'Gradle build cache'

- task: [email protected]
  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: [email protected]
  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: [email protected]
  inputs:
    versionSpec: '12.9.1'
  displayName: 'Install Node'

- task: [email protected]
  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: [email protected]
  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'

Leave a Reply

Your email address will not be published.