Files
react-native-firebase/.github/workflows/tests_e2e.yml
Mike Hardy 70305ef0f9 Add Android E2E logging, delay tap input stream (#4075)
* Turn up logging for detox to isolate E2E flakiness
* Compress android emulator log before upload, bump action versions
* Sleep long enough for app to come up before sending stream of taps
2020-08-12 15:07:25 -05:00

227 lines
7.7 KiB
YAML

name: Testing E2E
on:
pull_request:
branches:
- '**'
push:
branches:
- master
jobs:
# ------------------
# Android
# ------------------
android:
name: Android
runs-on: macos-latest
timeout-minutes: 60
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2-beta
# Yarn cache directory on macOS GH Action virtual environment isn't empty;
# -> https://github.com/actions/virtual-environments/issues/427
# -> https://github.com/actions/cache/issues/187
- name: Clean Yarn cache directory
run: yarn cache clean
# Gradle cache directory on macOS GH Action virtual environment isn't empty;
# -> https://github.com/actions/virtual-environments/issues/427
- name: Clean Gradle cache directory
run: rm -rf ~/.gradle/caches
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
name: Yarn Cache
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}-v1
- uses: actions/cache@v2
name: Gradle Cache
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-v1
- name: Yarn Install
run: |
export DETOX_DISABLE_POSTINSTALL=1
yarn --no-audit --prefer-offline
- name: Setup JDK8
uses: actions/setup-java@v1
with:
java-version: '8'
architecture: 'x64'
- name: Build Android App
run: cd tests/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug -Dorg.gradle.daemon=false
- name: Download Emulator Image
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-28;google_apis;x86_64"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestingAVD --device "Nexus 5X" -k 'system-images;android-28;google_apis;x86_64' -g google_apis
$ANDROID_HOME/emulator/emulator -list-avds
- name: Start Android Emulator
timeout-minutes: 15
continue-on-error: true
run: |
echo "Starting emulator"
nohup $ANDROID_HOME/emulator/emulator -avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
$ANDROID_HOME/platform-tools/adb devices
$ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0.0
echo "Emulator started"
- name: Detox Test
timeout-minutes: 40
# Prebuild the bundle so that's fast when the app starts.
# Detox uses Espresso to choreograph steps in reaction to UI events, so we need to send a stream of taps.
# But if you send them before the app is ready, there is a chance react-native comes alive with an ACTION_UP and no ACTION_DOWN, which hangs everything.
# So we wait 180 seconds, which seems to be enough for the app to come up.
run: |
nohup yarn run tests:packager:jet &
printf 'Waiting for packager to come online'
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do
printf '.'
sleep 2
done
echo "Packager is online!"
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&inlineSourceMap=true"
nohup sh -c "sleep 180 && until false; do $ANDROID_HOME/platform-tools/adb shell input tap 100 800; sleep 0.1; done" &
nohup sh -c "$ANDROID_HOME/platform-tools/adb logcat '*:D' > adb-log.txt" &
cd tests
./node_modules/.bin/nyc ./node_modules/.bin/detox test --loglevel trace --configuration android.emu.debug --cleanup
shell: bash
- name: Submit Coverage
run: |
./node_modules/.bin/codecov
shell: bash
- name: Compress Emulator Log
if: always()
run: |
gzip -9 adb-log.txt
shell: bash
- name: Upload Logs
uses: actions/upload-artifact@v2
if: always()
with:
name: adb_logs
path: adb-log.txt.gz
# ------------------
# iOS
# ------------------
ios:
name: iOS
runs-on: macos-latest
timeout-minutes: 35
env:
# Use the latest version of xcode for rnfirebase
# See link below for available versions;
# -> https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md#xcode
DEVELOPER_DIR: /Applications/Xcode_11.4.app
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2-beta
# Yarn cache directory on macOS GH Action virtual environment isn't empty;
# -> https://github.com/actions/virtual-environments/issues/427
# -> https://github.com/actions/cache/issues/187
- name: Clean Yarn cache directory
run: yarn cache clean
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
name: Yarn Cache
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}-v1
- uses: actions/cache@v2
name: Cache Pods
with:
path: tests/ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}-v1
- uses: actions/cache@v2
name: Detox Framework Cache
with:
path: ~/Library/Detox/ios
key: ${{ runner.os }}-detox-framework-cache-${{ env.DEVELOPER_DIR }}
- name: Yarn Install
run: yarn --no-audit --prefer-offline
- name: Pod Install
run: |
gem update cocoapods xcodeproj
cd tests/ios
pod install
shell: bash
- name: Build iOS App
run: |
export SKIP_BUNDLING=1
export RCT_NO_LAUNCH_PACKAGER=1
cd tests
./node_modules/.bin/detox build --configuration ios.ci
shell: bash
- name: Install applesimutils
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
brew tap wix/brew
brew install applesimutils
applesimutils --list
shell: bash
- name: Detox Test
timeout-minutes: 20
run: |
nohup yarn run tests:packager:jet &
printf 'Waiting for packager to come online'
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do
printf '.'
sleep 2
done
echo "Packager is online!"
cd tests
./node_modules/.bin/nyc ./node_modules/.bin/detox test --configuration ios.ci --cleanup
shell: bash
- name: Submit Coverage
run: |
./node_modules/.bin/codecov
shell: bash
# - name: Upload App
# uses: actions/upload-artifact@v1
# with:
# name: ios_app
# path: tests/ios/build/Build/Products/Debug-iphonesimulator/testing.app