Skip to content

Commit

Permalink
android emulator (#62)
Browse files Browse the repository at this point in the history
### To be filled by the PR creator:

* A brief description of the changes made - 

* Do we have clean latest run report (Docker or Browserstack) attached
with this PR?
  * [ ] Yes
  * [ ] No (Please explain why)

* Does the PR contain changes to any core file?
  * [ ] Yes (Needs approval from at least 1 people)
  * [ ] No

* Is it
  * [ ] New Testcase
  * [ ] Fix


### To be filled by the PR reviewer:

* [ ] Verify the attached run report passed in GitHub Actions (Docker or
Browserstack run)

* General
    * [ ] Use the best strategy to locate the elements
    * [ ] Comments wherever the code is not readable by itself
    * [ ] Use of the right data structure for the use case
    * [ ] Reuse logic/functionality as much as possible
    * [ ] Cleanup of any test data that is generated by the tests
    * [ ] No static waits
  • Loading branch information
Tauqir Sarwar authored Mar 22, 2024
2 parents 9faa169 + a18aedc commit 2c0b190
Showing 1 changed file with 51 additions and 74 deletions.
125 changes: 51 additions & 74 deletions .github/workflows/docker_android_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Install and Run Appium Server
id: setup_appium
if: steps.setup_java.outcome == 'success'
if: steps.co_code.outcome == 'success'
run: |
npm install -g appium
Expand All @@ -46,32 +46,61 @@ jobs:
sleep 10
appium -v
- name: Run Android Emulator
id: run_emulator
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: 30
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -grpc-use-jwt -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
target: default
arch: x86_64
script: echo "Generated AVD"
- name: Create Android emulator
id: create_emulator
if: steps.install_driver.outcome == 'success'
run: |
brew install intel-haxm
# Install AVD files
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;default;x86_64'
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses
# Create emulator
$ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_29_AOSP -d pixel --package 'system-images;android-27;default;x86_64'
$ANDROID_HOME/emulator/emulator -list-avds
if false; then
emulator_config=~/.android/avd/Pixel_API_29_AOSP.avd/config.ini
sed -i .bak 's/hw.lcd.density=.*/hw.lcd.density=480/' "$emulator_config"
sed -i .bak 's/hw.lcd.height=.*/hw.lcd.height=2220/' "$emulator_config"
sed -i .bak 's/hw.lcd.width=.*/hw.lcd.width=1080/' "$emulator_config"
# Or, add new config
if ! grep -q "hw.lcd.density" "$emulator_config"; then
echo "hw.lcd.density=480" >> "$emulator_config"
fi
if ! grep -q "hw.lcd.height" "$emulator_config"; then
echo "hw.lcd.height=2220" >> "$emulator_config"
fi
if ! grep -q "hw.lcd.width" "$emulator_config"; then
echo "hw.lcd.width=1080" >> "$emulator_config"
fi
echo "Emulator settings ($emulator_config)"
cat "$emulator_config"
fi
- name: Run Android Emulator Again
id: run_emulator_again
if: steps.run_emulator.outcome == 'success'
- name: Start Android emulator
id: start_emulator
if: steps.create_emulator.outcome == 'success'
run: |
echo "Running Emulator Again"
cd ~/Library/Android/sdk/emulator
sleep 5
./emulator -list-avds
sleep 5
./emulator -avd test -no-snapshot-save -no-window -grpc-use-jwt -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
echo "Starting emulator and waiting for boot to complete...."
ls -la $ANDROID_HOME/emulator
nohup $ANDROID_HOME/tools/emulator -avd Pixel_API_29_AOSP -gpu host -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do echo "wait..."; sleep 1; done; input keyevent 82'
echo "Emulator has finished booting"
$ANDROID_HOME/platform-tools/adb devices
sleep 30
screencapture screenshot.jpg
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > emulator.png
- name: Check out code
id: co_code
if: steps.start_emulator.outcome == 'success'
uses: actions/checkout@v4

- name: Setup dependencies
id: setup_dependencies
if: steps.run_emulator_again.outcome == 'success'
if: steps.co_code.outcome == 'success'
run: |
sh setup_install.sh
Expand Down Expand Up @@ -133,58 +162,6 @@ jobs:
sleep 10
appium -v
# - name: Android Emulator Runner Without SDK Setup
# uses: RandyLutcavich/[email protected]

# - name: AVD cache
# uses: actions/cache@v4
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-test
#
# - name: Run Android Emulator
# id: run_emulator
# if: steps.setup_dependencies.outcome == 'success'
# uses: ReactiveCircus/android-emulator-runner@v2
# with:
# api-level: 30
# force-avd-creation: false
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# target: default
# arch: x86_64
# script: echo "Generated AVD Started"
#
# - name: Run Android Emulator Again
# id: run_emulator_again
# if: steps.run_emulator.outcome == 'success'
# run: |
# echo "Running Emulator Again"
# cd ~/Library/Android/sdk/emulator
# ./emulator -list-avds
# ./emulator -avd test -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none

# - name: set up JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
#
# - name: Setup Android SDK
# uses: android-actions/setup-android@v3
#
# - name: Create Android emulator
# run: |
# sdkmanager --install "system-images;android-31;google_apis;x86_64"
# echo "no" | avdmanager --verbose create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-31;google_apis;x86_64'
#
# - name: Launch Emulator
# run: |
# $ANDROID_SDK_ROOT/emulator/emulator -avd testAVD

- name: Create Android emulator
run: |
brew install intel-haxm
Expand Down

0 comments on commit 2c0b190

Please sign in to comment.