Skip to content

Commit

Permalink
[SDK-3508] Fix Integration Test CI for Android (#282)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Hobbs <steve.hobbs@okta.com>
Co-authored-by: Rita Zerrizuela <zeta@widcket.com>
  • Loading branch information
3 people committed Jul 11, 2023
1 parent 6e25f10 commit f165559
Show file tree
Hide file tree
Showing 11 changed files with 5,536 additions and 143 deletions.
125 changes: 81 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ orbs:
flutter: circleci/flutter@2
browser-tools: circleci/browser-tools@1
codecov: codecov/codecov@3
node: circleci/node@5
local-android:
orbs:
android: circleci/android@2
Expand All @@ -19,38 +20,10 @@ orbs:
sed -i "s/YOUR_AUTH0_DOMAIN/$AUTH0_DOMAIN/" .env
sed -i "s/YOUR_AUTH0_CLIENT_ID/$AUTH0_CLIENT_ID/" .env
sed -i "s/YOUR_AUTH0_CUSTOM_SCHEME/$AUTH0_CUSTOM_SCHEME/" .env
mv android/app/src/main/res/values/strings.xml.example android/app/src/main/res/values/strings.xml
sed -i "s/YOUR_AUTH0_DOMAIN/$AUTH0_DOMAIN/" android/app/src/main/res/values/strings.xml
mv android/local.properties.ci android/local.properties
working_directory: ./auth0_flutter/example
run-smoke-tests:
description: Runs the Android smoke tests
parameters:
android_simulator:
type: string
steps:
- android/accept-licenses
- android/create-avd:
avd-name: auth0_sample_avd
system-image: << parameters.android_simulator >>
install: true
- android/start-emulator:
avd-name: auth0_sample_avd
no-window: true
restore-gradle-cache-prefix: v1a
post-emulator-launch-assemble-command: ""
post-emulator-wait-steps:
- run:
name: Disable Chrome welcome prompt
command: adb shell 'echo "chrome --disable-fre --no-default-browser-check --no-first-run" > /data/local/tmp/chrome-command-line'
- run:
name: Enable ADB root
command: adb root
- android/run-tests:
max-tries: 1
working-directory: ./auth0_flutter/example/android
parameters:
flutter_version:
type: string
Expand All @@ -64,6 +37,8 @@ jobs:
- flutter/install_sdk_and_pub:
app-dir: ./auth0_flutter
version: << pipeline.parameters.flutter_version >>
- flutter/install_pub:
app-dir: ./auth0_flutter
- browser-tools/install-chrome
- run:
name: Analyze App Facing Package
Expand Down Expand Up @@ -105,6 +80,8 @@ jobs:
- flutter/install_sdk_and_pub:
app-dir: ./auth0_flutter
version: << pipeline.parameters.flutter_version >>
- flutter/install_pub:
app-dir: ./auth0_flutter
- android/restore-gradle-cache
- android/restore-build-cache
- local-android/prepare-config
Expand Down Expand Up @@ -133,13 +110,10 @@ jobs:
upload_name: Auth0 Flutter Android
flags: auth0_flutter_android
smoke_test_android:
parameters:
android_simulator:
type: string
executor:
name: android/android-machine
resource-class: xlarge
tag: 2022.06.1
machine:
image: android:2022.12.1
# To optimize build times, we recommend "large" and above for Android-related jobs
resource_class: xlarge
steps:
- run:
name: Guard Smoke Tests
Expand All @@ -152,14 +126,76 @@ jobs:
app-dir: ./auth0_flutter
version: << pipeline.parameters.flutter_version >>
- local-android/prepare-config
- node/install:
node-version: '18.16.0'
install-yarn: true
- run:
name: Build Android app
command: flutter build apk
name: Setup Appium Test
working_directory: ./appium-test
command: yarn
- run:
name: Setup Appium driver
command: APPIUM_SKIP_CHROMEDRIVER_INSTALL=1 npx --yes appium@next driver install uiautomator2
- run:
name: Start appium
command: npx --yes appium@next #Appium recommends this until v2 is released
background: true
- run:
name: Generate cache key
command: |
find . -name 'build.gradle' | sort | xargs cat |
shasum | awk '{print $1}' > /tmp/gradle_cache_seed
- restore_cache:
key: gradle-v1-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }}
- run:
name: Gradle Wrapper
working_directory: ./auth0_flutter/example/android
command: gradle wrapper
- run:
name: Build Android Example App
command: |
flutter clean
flutter build apk --split-per-abi
working_directory: ./auth0_flutter/example
- local-android/run-smoke-tests:
android_simulator: << parameters.android_simulator >>
- android/save-gradle-cache:
cache-prefix: v1a
- run:
name: Create avd
command: |
SYSTEM_IMAGES="system-images;android-29;google_apis_playstore;x86_64"
sdkmanager "$SYSTEM_IMAGES"
echo "no" | avdmanager --verbose create avd -n test -k "$SYSTEM_IMAGES"
- run:
name: Launch emulator
command: |
emulator -avd test -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
background: true
- run:
name: Wait for emulator to start
command: |
circle-android wait-for-boot
- run:
name: Disable emulator animations and Chrome terms page
command: |
adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0
adb shell am set-debug-app --persistent com.android.chrome
adb shell 'echo "chrome --disable-fre --no-default-browser-check --no-first-run" > /data/local/tmp/chrome-command-line'
- run:
name: Record screen
command: |
adb emu screenrecord start --time-limit 300 ./recording_video.webm
- run:
name: Run Appium Tests
command: USER_EMAIL=$USER_EMAIL USER_PASSWORD=$USER_PASSWORD node test.js
working_directory: ./appium-test
- save_cache:
key: gradle-v1-{{ arch }}-{{ checksum "/tmp/gradle_cache_seed" }}
paths:
- ~/.gradle/caches
- ~/.gradle/wrapper
- store_artifacts:
path: ./recording_video.webm
when: on_fail
test_ios:
parameters:
ios_version:
Expand All @@ -183,8 +219,10 @@ jobs:
name: Install Rosetta
command: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- flutter/install_sdk_and_pub:
app-dir: ./auth0_flutter/example
app-dir: ./auth0_flutter
version: << pipeline.parameters.flutter_version >>
- flutter/install_pub:
app-dir: ./auth0_flutter/example
- flutter/install_ios_gem:
app-dir: ./auth0_flutter/example
- flutter/install_ios_pod:
Expand Down Expand Up @@ -225,11 +263,10 @@ workflows:
requires:
- test_flutter_package
- smoke_test_android:
android_simulator: system-images;android-29;google_apis;x86
requires:
- test_flutter_package
- test_ios:
ios_version: "16.2"
ios_simulator: iPhone 14
requires:
- test_flutter_package
- test_flutter_package
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

# Global coverage
coverage/

appium-test/node_modules/*
Loading

0 comments on commit f165559

Please sign in to comment.