Release/2.1.1 #203
Workflow file for this run
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
name: e2e-android | |
on: | |
pull_request: | |
jobs: | |
e2e: | |
runs-on: macos-latest | |
timeout-minutes: 60 | |
env: | |
TURBO_CACHE_DIR: .turbo/android-e2e | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup | |
- name: Cache turborepo for Android | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TURBO_CACHE_DIR }} | |
key: ${{ runner.os }}-turborepo-e2e-android-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-turborepo-e2e-android- | |
- name: Check turborepo cache for Android | |
run: | | |
TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") | |
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then | |
echo "turbo_cache_hit=1" >> $GITHUB_ENV | |
fi | |
- name: Install JDK | |
if: env.turbo_cache_hit != 1 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Finalize Android SDK | |
if: env.turbo_cache_hit != 1 | |
run: | | |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" | |
- name: Cache Gradle | |
if: env.turbo_cache_hit != 1 | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/wrapper | |
~/.gradle/caches | |
key: ${{ runner.os }}-gradle-e2e-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-e2e- | |
# -- Micro -- | |
- name: Cache Micro | |
id: cache-micro | |
uses: actions/cache@v3 | |
with: | |
path: micro.jar | |
key: ${{ runner.os }}-micro | |
- name: Get micro | |
if: steps.cache-micro.outputs.cache-hit != 'true' | |
run: curl -o micro.jar -L https://github.com/snowplow-incubator/snowplow-micro/releases/download/micro-1.7.2/snowplow-micro-1.7.2.jar | |
- name: Run Micro in background | |
run: java -jar micro.jar & | |
- name: Wait on Micro endpoint | |
timeout-minutes: 2 | |
run: while ! nc -z '0.0.0.0' 9090; do sleep 1; done | |
- name: Prepare example for Micro | |
working-directory: example/src | |
run: perl -i -pe "s/^.*collectorEndpoint =\K.*/ \'http:\/\/10.0.2.2:9090\'\;/" App.js | |
# -- Emulator -- | |
- name: Get AOSP system image and create Android virtual device | |
run: | | |
echo 'y' | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "system-images;android-28;default;x86_64" | |
echo 'no' | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd --force --name Pixel_API_28_AOSP -d pixel --package "system-images;android-28;default;x86_64" | |
- name: Start Android emulator | |
timeout-minutes: 10 | |
run: | | |
echo "Starting emulator.." | |
nohup $ANDROID_HOME/emulator/emulator -avd Pixel_API_28_AOSP -no-audio -no-snapshot -no-window & | |
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82' | |
$ANDROID_HOME/platform-tools/adb devices | |
echo "Emulator started!" | |
# -- Test -- | |
- name: Detox Jest android | |
id: dj | |
run: | | |
yarn turbo run e2e:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" | |
- name: Log events if Detox-Jest failed | |
id: eventlog | |
if: ${{ failure() && steps.dj.outcome == 'failure' }} | |
run: | | |
echo "{ \"all\": $(curl -s -o - 'http://0.0.0.0:9090/micro/all'), \ | |
\"bad\": $(curl -s -o - 'http://0.0.0.0:9090/micro/bad'), \ | |
\"good\": $(curl -s -o - 'http://0.0.0.0:9090/micro/good') }"\ | |
| jq '.' > android-events-micro.json | |
- name: Upload events artifact if Detox-Jest failed | |
if: ${{ failure() && steps.dj.outcome == 'failure' && steps.eventlog.outcome == 'success' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: android-events-artifact | |
path: android-events-micro.json | |
# -- Cleanup -- | |
- name: Stop gradle daemon | |
run: gradle --stop |