From 1e3c83308c018968e0a38df64d32da3753cd3368 Mon Sep 17 00:00:00 2001 From: Dimitri Kopriwa Date: Mon, 31 Oct 2022 12:38:22 +0200 Subject: [PATCH] (PC-18251) fix(e2e): add android GitHub action poc --- .github/workflows/e2e-android-native.yml | 131 +++++++++++++++++++++-- 1 file changed, 123 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-android-native.yml b/.github/workflows/e2e-android-native.yml index 1c7cbfd1cfd..f0c82b87163 100644 --- a/.github/workflows/e2e-android-native.yml +++ b/.github/workflows/e2e-android-native.yml @@ -3,14 +3,129 @@ name: Tests e2e Android Native on: workflow_dispatch: inputs: - tbd: - description: "tbd" - required: false - type: string + environment: + type: environment + description: Select the environment jobs: - tbd: - runs-on: ubuntu-latest + e2e-android-native: +# runs-on: ubuntu-latest + runs-on: macos-latest + strategy: + matrix: + api-level: [27, 29, 31] + target: [default, google_apis] + environment: ${{ inputs.environment }} steps: - - name: Hello World - run: echo "Hello World" + - uses: actions/checkout@v3 + + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + + - name: AVD cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + + - uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 11 + cache: 'maven' + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Install dependencies + run: yarn + + - name: Setup sentry credentials + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + run: | + cat <> ~/.sentryclirc + [defaults] + url=https://sentry.passculture.team/ + org=sentry + project=application-native + + [auth] + token=$SENTRY_AUTH_TOKEN + EOT + + - name: Setup android keystore for ${{ inputs.environment }} environment + env: + ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} + ANDROID_KEYSTORE_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_STORE_PASSWORD }} + ANDROID_KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }} + run: | + mkdir -p android/keystores + echo ${ANDROID_KEYSTORE} | base64 -di > android/keystores/${{ inputs.environment }}.keystore + cat <> android/keystores/${{ inputs.environment }}.keystore.properties + keyAlias=passculture + storeFile=${{ inputs.environment }}.keystore + storePassword=${ANDROID_KEYSTORE_STORE_PASSWORD} + keyPassword=${ANDROID_KEYSTORE_KEY_PASSWORD} + EOT + + - name: Setup android Google services config + env: + ANDROID_GOOGLE_SERVICES_JSON: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON }} + run: echo ${ANDROID_GOOGLE_SERVICES_JSON} > android/app/google-services.json + + - name: Build Android app for ${{ inputs.environment }} environment + run: | + . <(cat fastlane/.env.${{ inputs.environment }} | grep ANDROID_GRADLE_TASK) + ./android/gradlew ${ANDROID_GRADLE_TASK} -p android + + + - name: Install and run Appium 2 in the background + run: | + npm install -g appium@next + appium driver install uiautomator2 + appium & + + + - 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: ${{ matrix.api-level }} + target: ${{ matrix.target }} + force-avd-creation: false + arch: x86_64 + profile: Nexus 6 + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." + + - name: Run e2e Android tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + force-avd-creation: false + arch: x86_64 + profile: Nexus 6 + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + script: . <(cat fastlane/.env.${{ inputs.environment }} | grep ANDROID_FILE_PATH) && . <(cat .env.testing | grep ANDROID_APP_ID) && ANDROID_APK_PATH=${ANDROID_FILE_PATH} ANDROID_APP_ID=${ANDROID_APP_ID} yarn test:e2e:android:native + +# - name: Run e2e Android tests +# run: | +# . <(cat fastlane/.env.${{ inputs.environment }} | grep ANDROID_FILE_PATH) +# . <(cat .env.testing | grep ANDROID_APP_ID) +# ANDROID_APK_PATH=${ANDROID_FILE_PATH} ANDROID_APP_ID=${ANDROID_APP_ID} yarn test:e2e:android:native