Skip to content

Commit

Permalink
test loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserfaraazkhan committed Jun 21, 2024
1 parent ebf8753 commit 241891a
Showing 1 changed file with 144 additions and 88 deletions.
232 changes: 144 additions & 88 deletions .github/workflows/e2e-detox-android-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,102 +145,158 @@ jobs:
# name: android-build-apk-${{ github.run_id }}
# path: "android/app/build/outputs/apk/**/app-*.apk"

e2e-android-on-mac:
name: android-detox-e2e-${{ matrix.runId }}-${{ matrix.deviceName }}-${{ matrix.deviceOsVersion }}
continue-on-error: true
runs-on: macos-13
timeout-minutes: 40
needs:
- generate-specs
# - build-android-apk
# e2e-android-on-mac:
# name: android-detox-e2e-${{ matrix.runId }}-${{ matrix.deviceName }}-${{ matrix.deviceOsVersion }}
# continue-on-error: true
# runs-on: macos-13
# timeout-minutes: 40
# needs:
# - generate-specs
# # - build-android-apk
# strategy:
# fail-fast: false
# matrix: ${{fromJson(needs.generate-specs.outputs.specs)}}
# steps:
# - name: Checkout
# uses: actions/checkout@v1
# with:
# fetch-depth: 1

# - name: ci/prepare-node-deps
# uses: ./.github/actions/prepare-node-deps

# - name: Install Sharp CLI for faster image generation during prebuild
# run: npm install --global sharp-cli

# - name: Start React Native Metro Server
# run: npm run start &

# - name: Install Detox Dependencies
# run: cd detox && npm i

# - name: Install Java
# uses: actions/setup-java@v4
# with:
# java-version: "17"
# distribution: "adopt"
# cache: "gradle"

# - name: Create destination path
# run: mkdir -p android/app/build/outputs/apk

# - name: Download artifact
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# curl -L -H "Authorization: token $GITHUB_TOKEN" \
# -H "Accept: application/vnd.github.v3+json" \
# https://api.github.com/repos/mattermost/mattermost-mobile/actions/artifacts/1578521977/zip \
# --output android/app/build/outputs/apk/artifact.zip

# - name: Unzip artifact
# run: unzip android/app/build/outputs/apk/artifact.zip -d android/app/build/outputs/apk

# - name: Cleanup
# run: rm android/app/build/outputs/apk/artifact.zip

# - name: Launch Android Emulator
# run: |
# echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-31;google_apis;x86_64'
# echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n android_emulator -k 'system-images;android-31;google_apis;x86_64' --force --device "pixel_6"
# echo "Emulator created successfully"
# nohup $ANDROID_HOME/emulator/emulator -avd android_emulator -no-snapshot -netdelay none -netspeed full -no-audio -no-boot-anim -accel on -gpu swiftshader_indirect -qemu -m 4096 > /dev/null 2>&1 &
# $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 input keyevent 82
# $ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0
# $ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0
# $ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0
# sleep 60
# screencapture emulator-macos-13.jpg
# $ANDROID_HOME/platform-tools/adb exec-out screencap -p > emulator-macos-13.png

# - uses: actions/upload-artifact@v3
# with:
# name: Android-Emulator-Screenshots
# path: emulator-macos-13.jpg

# - uses: actions/upload-artifact@v3
# with:
# name: Android-Emulator-Screenshots
# path: emulator-macos-13.jpg.png

# - name: Run Android Detox E2E Tests on macOS
# run: |
# cd detox && npm run e2e:android-test -- ${{ matrix.specs }}

# - name: Upload Android Test Report
# if: always()
# uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
# with:
# name: android-results-${{ matrix.runId }}
# path: detox/artifacts

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-specs.outputs.specs)}}
matrix:
os: ['macos-12']
try: ['0', '1', '2']

steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: ci/prepare-node-deps
uses: ./.github/actions/prepare-node-deps

- name: Install Sharp CLI for faster image generation during prebuild
run: npm install --global sharp-cli

- name: Start React Native Metro Server
run: npm run start &

- name: Install Detox Dependencies
run: cd detox && npm i

- name: Install Java
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
cache: "gradle"

- name: Create destination path
run: mkdir -p android/app/build/outputs/apk

- name: Download artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -L -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/mattermost/mattermost-mobile/actions/artifacts/1578521977/zip \
--output android/app/build/outputs/apk/artifact.zip
- name: Unzip artifact
run: unzip android/app/build/outputs/apk/artifact.zip -d android/app/build/outputs/apk

- name: Cleanup
run: rm android/app/build/outputs/apk/artifact.zip

- name: Launch Android Emulator
run: |
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-31;google_apis;x86_64'
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n android_emulator -k 'system-images;android-31;google_apis;x86_64' --force --device "pixel_6"
echo "Emulator created successfully"
nohup $ANDROID_HOME/emulator/emulator -avd android_emulator -no-snapshot -netdelay none -netspeed full -no-audio -no-boot-anim -accel on -gpu swiftshader_indirect -qemu -m 4096 > /dev/null 2>&1 &
$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 input keyevent 82
$ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0
$ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0
$ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0
sleep 60
screencapture emulator-macos-13.jpg
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > emulator-macos-13.png
- uses: actions/upload-artifact@v3
with:
name: Android-Emulator-Screenshots
path: emulator-macos-13.jpg

- uses: actions/upload-artifact@v3
with:
name: Android-Emulator-Screenshots
path: emulator-macos-13.jpg.png

- name: Run Android Detox E2E Tests on macOS
run: |
cd detox && npm run e2e:android-test -- ${{ matrix.specs }}
- name: Upload Android Test Report
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: android-results-${{ matrix.runId }}
path: detox/artifacts
- run: system_profiler SPHardwareDataType
- run: |
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-30;google_apis;x86'
for (( i=0; i<2; i++ )); do
# create and start emulator with specific SDK
emulator_name='emulator'$i
echo -e $(date) "$debugTag Create AVD $emulator_name "
if [[ "`uname -m`" == "arm64" ]]; then
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n $emulator_name -k "system-images;android-30;google_apis;arm64-v8a" -d pixel_6 --force
echo qq
else
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n $emulator_name -k "system-images;android-30;google_apis;x86" -d pixel_6 --force
fi
echo -e $(date) "$debugTag Check hardware acceleration "
$ANDROID_HOME/emulator/emulator -accel-check
echo -e $(date) "$debugTag Boot AVD $emulator_name "
# wait for AVD boot finished
if [[ "`uname -m`" == "arm64" ]]; then
$ANDROID_HOME/emulator/emulator -avd $emulator_name -cores 2 -memory 2048 -accel on -noaudio -no-snapshot -no-boot-anim &
else
nohup $ANDROID_HOME/emulator/emulator -avd $emulator_name -cores 2 -memory 5120 -accel on -gpu swiftshader_indirect -noaudio -no-snapshot -no-boot-anim &
fi
echo -e $(date) "$debugTag Wait for AVD boot finished "
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
echo -e $(date) "$debugTag Emulator started"
echo -e $(date) "Access emulator with adb"
"$ANDROID_HOME/platform-tools/adb" shell ls 2>/dev/null > ls.log
echo -e $(date) "Stop emulator "
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
sleep 30
done
sleep 30
screencapture emulator-macos-13.jpg
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > emulator-macos-13.png
- uses: actions/upload-artifact@v3
with:
name: Android-Emulator-Screenshots
path: emulator-${{ matrix.os }}-${{ matrix.try }}.jpg
- uses: actions/upload-artifact@v3
with:
name: Android-Emulator-Screenshots
path: emulator-${{ matrix.os }}-${{ matrix.try }}.png

download-e2e-results:
runs-on: ubuntu-22.04
needs:
- generate-specs
- e2e-android-on-mac
# - e2e-android-on-mac
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down

0 comments on commit 241891a

Please sign in to comment.