Skip to content

Commit

Permalink
(PC-18251) fix(e2e): add android GitHub action poc
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Kopriwa committed Oct 31, 2022
1 parent e4544e6 commit 1e3c833
Showing 1 changed file with 123 additions and 8 deletions.
131 changes: 123 additions & 8 deletions .github/workflows/e2e-android-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOT >> ~/.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 <<EOT >> 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

0 comments on commit 1e3c833

Please sign in to comment.