-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
does the native compiles, checks the bundler and runs the app at least
- Loading branch information
Showing
1 changed file
with
294 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
name: Testing E2E | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths-ignore: | ||
- '**/*.md' | ||
|
||
push: | ||
paths-ignore: | ||
- '**/*.md' | ||
|
||
jobs: | ||
# ------------------ | ||
# Android | ||
# ------------------ | ||
android: | ||
name: Android | ||
runs-on: macos-latest | ||
timeout-minutes: 60 | ||
env: | ||
EMULATOR_COMMAND: "-avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim -nojni -memory 2048 -timezone 'Europe/London' -cores 2" | ||
EMULATOR_EXECUTABLE: qemu-system-x86_64-headless | ||
steps: | ||
- uses: styfle/cancel-workflow-action@0.6.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 50 | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v2-beta | ||
|
||
- 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 | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: yarn example:install | ||
|
||
- name: Verify JDK 1.8 | ||
# OpenJDK1.8 is the default in GitHub macOS 10.15 runner, setup is not required | ||
# Run a check that exits with error unless it is 1.8 version to future-proof against unexpected upgrades | ||
run: java -fullversion 2>&1 | grep '1.8' | ||
shell: bash | ||
|
||
- name: Build Android App | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: yarn example:android:build | ||
|
||
- name: Pre-fetch Javascript bundle | ||
# Prebuild the bundle so that's fast when the app starts. | ||
run: | | ||
nohup yarn example:packager & | ||
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! Preparing javascript bundle..." | ||
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&inlineSourceMap=true" | ||
echo "...javascript bundle ready." | ||
- name: Download Emulator Image | ||
# This can fail on network request, wrap with retry | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-30;google_apis;x86_64" | ||
|
||
- name: Create Emulator | ||
run: echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestingAVD --device "Nexus 5X" -k 'system-images;android-30;google_apis;x86_64' -g google_apis | ||
|
||
# These Emulator start steps are the current best practice to do retries on multi-line commands with persistent (nohup) processes | ||
- name: Start Android Emulator | ||
id: emu1 | ||
timeout-minutes: 5 | ||
continue-on-error: true | ||
run: | | ||
echo "Starting emulator" | ||
nohup $ANDROID_HOME/emulator/emulator $EMULATOR_COMMAND & | ||
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done' | ||
- name: Start Android Emulator Retry 1 | ||
id: emu2 | ||
if: steps.emu1.outcome=='failure' | ||
timeout-minutes: 5 | ||
continue-on-error: true | ||
run: | | ||
echo "Starting emulator, second attempt" | ||
$ANDROID_HOME/platform-tools/adb devices | ||
sudo killall -9 $EMULATOR_EXECUTABLE || true | ||
sleep 2 | ||
nohup $ANDROID_HOME/emulator/emulator $EMULATOR_COMMAND & | ||
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done' | ||
- name: Start Android Emulator Retry 2 | ||
id: emu3 | ||
if: steps.emu2.outcome=='failure' | ||
timeout-minutes: 5 | ||
continue-on-error: true | ||
run: | | ||
echo "Starting emulator, third attempt" | ||
$ANDROID_HOME/platform-tools/adb devices | ||
sudo killall -9 $EMULATOR_EXECUTABLE || true | ||
sleep 2 | ||
nohup $ANDROID_HOME/emulator/emulator $EMULATOR_COMMAND & | ||
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done' | ||
- name: Emulator Status | ||
if: always() | ||
run: | | ||
if ${{ steps.emu1.outcome=='success' || steps.emu2.outcome=='success' || steps.emu3.outcome=='success' }}; then | ||
echo "Emulator Started" | ||
else | ||
exit 1 | ||
fi | ||
- name: E2E Test | ||
# Detox uses Espresso to choreograph steps in reaction to UI events, so we need to send a stream of taps. | ||
timeout-minutes: 40 | ||
run: | | ||
$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 | ||
nohup sh -c "until false; do $ANDROID_HOME/platform-tools/adb shell input tap 100 800; sleep 0.2; done" & | ||
nohup sh -c "$ANDROID_HOME/platform-tools/adb logcat '*:D' > adb-log.txt" & | ||
yarn example:android | ||
shell: bash | ||
|
||
# - name: Submit Coverage | ||
# # This can fail on timeouts etc, wrap with retry | ||
# uses: nick-invision/retry@v2 | ||
# with: | ||
# timeout_minutes: 10 | ||
# retry_wait_seconds: 60 | ||
# max_attempts: 3 | ||
# command: curl https://codecov.io/bash -o codecov.sh && bash ./codecov.sh | ||
|
||
- name: Compress Emulator Log | ||
if: always() | ||
run: gzip -9 adb-log.txt | ||
shell: bash | ||
|
||
- name: Upload Emulator Log | ||
uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: adb_logs | ||
path: adb-log.txt.gz | ||
|
||
# ------------------ | ||
# iOS | ||
# ------------------ | ||
ios: | ||
name: iOS | ||
runs-on: macos-latest | ||
# TODO matrix across APIs, at least 10 and 13 (lowest to highest) | ||
timeout-minutes: 40 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
steps: | ||
- uses: styfle/cancel-workflow-action@0.6.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 50 | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v2-beta | ||
|
||
- uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: latest-stable | ||
|
||
- 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: example/ios/Pods | ||
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}-v1 | ||
|
||
- name: Yarn Install | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: yarn example:install | ||
|
||
- name: Pod Install | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: yarn example:install:pods | ||
|
||
- name: Build iOS App | ||
run: | | ||
export SKIP_BUNDLING=1 | ||
export RCT_NO_LAUNCH_PACKAGER=1 | ||
yarn example:ios:build | ||
shell: bash | ||
|
||
- name: Install applesimutils | ||
uses: nick-invision/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
retry_wait_seconds: 60 | ||
max_attempts: 3 | ||
command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew && HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils && applesimutils --list | ||
|
||
- name: Pre-fetch Javascript bundle | ||
run: | | ||
nohup yarn example:packager & | ||
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! Preparing bundle..." | ||
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&inlineSourceMap=true" | ||
echo "...javascript bundle ready" | ||
- name: Create Simulator Log | ||
# With a little delay so the detox test below has time to spawn it, missing the first part of boot is fine | ||
# If you boot the simulator separately from detox, some other race fails and detox testee never sends ready to proxy | ||
continue-on-error: true | ||
run: nohup sh -c "sleep 30 && xcrun simctl spawn booted log stream --level debug --style compact > simulator.log 2>&1 &" | ||
|
||
- name: E2E Test | ||
timeout-minutes: 30 | ||
continue-on-error: true | ||
run: yarn example:ios | ||
|
||
- name: Compress Simulator Log | ||
if: always() | ||
run: gzip -9 simulator.log | ||
|
||
- name: Upload Simulator Log | ||
uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: simulator_logs | ||
path: simulator.log.gz | ||
|
||
# - name: Submit Coverage | ||
# # This can fail on timeouts etc, wrap with retry | ||
# uses: nick-invision/retry@v2 | ||
# with: | ||
# timeout_minutes: 10 | ||
# retry_wait_seconds: 60 | ||
# max_attempts: 3 | ||
# command: curl https://codecov.io/bash -o codecov.sh && bash ./codecov.sh |