Update build-app.yml for Azure Pipelines #847
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: Build [Android] | |
on: | |
workflow_dispatch: # To trigger manual build | |
pull_request: | |
push: | |
branches: | |
- master | |
concurrency: | |
group: android-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-app: | |
name: Build android apk | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out Git repository # clone the repo to local ci workspace | |
uses: actions/checkout@v2 | |
- name: Setup JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: 'zulu' | |
cache: 'gradle' | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
- uses: actions/cache@v2 | |
name: Cache Node Modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node_modules- | |
- name: Install yarn dependencies | |
run: | | |
yarn install --frozen-lockfile | |
- name: Build android app | |
run: | | |
yarn detox:build:android | |
- name: Upload apk files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android-apks | |
path: android/app/build/outputs/apk/* | |
test-android-apk: | |
name: Test android app | |
runs-on: macos-latest | |
needs: | |
- build-app | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: android/app/build/outputs/apk | |
name: android-apks | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
cache: 'yarn' | |
cache-dependency-path: '**/yarn.lock' | |
- uses: actions/cache@v2 | |
name: Cache Node Modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node_modules- | |
- name: AVD cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ runner.ios }} | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 29 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
profile: 5.1in WVGA | |
avd-name: 5.1_WVGA | |
script: echo "Generated AVD snapshot for caching." | |
- name: Install yarn dependencies | |
run: | | |
yarn install --frozen-lockfile | |
- name: Test android app | |
uses: reactivecircus/android-emulator-runner@v2 | |
env: | |
DETOX_DEFAULT_LOGIN_EMAIL: ${{ secrets.DETOX_DEFAULT_LOGIN_EMAIL }} | |
DETOX_DEFAULT_LOGIN_PASSWORD: ${{ secrets.DETOX_DEFAULT_LOGIN_PASSWORD }} | |
with: | |
api-level: 29 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
profile: 5.1in WVGA | |
avd-name: 5.1_WVGA | |
script: yarn detox:test:android --retries=3 --artifacts-location ./artifacts/ | |
- name: Upload detox artifacts | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: detox-android-artifacts | |
path: artifacts | |
- name: Upload demo artifacts | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: detox-demo-android | |
path: artifacts/✓ App Demo/test.mp4 | |