Skip to content

Commit

Permalink
separate scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sirkev committed Jun 14, 2024
1 parent 87f52ef commit 0066001
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 23 deletions.
53 changes: 30 additions & 23 deletions .github/workflows/appium_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
jobs:
appium_test:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [ 28 ]
target: [ default ]
permissions:
contents: write
steps:
Expand All @@ -25,27 +29,6 @@ jobs:
java-version: '17'


- name: Set up NodeJS 18
uses: actions/setup-node@v4
with:
node-version: '18.19.0'

# Run Android Emulator
- name: Run Android Emulator
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 -n test_device -k 'system-images;android-28;google_apis;x86_64' --force
echo $ANDROID_HOME/emulator/emulator -list-avds
echo "Starting emulator"
nohup $ANDROID_HOME/emulator/emulator -avd test_device -no-snapshot > /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; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
echo "Emulator started"
# Use HTTPS repos

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
Expand All @@ -57,5 +40,29 @@ jobs:
- name: Install flutter dependencies
run: flutter pub get

- name: Install and Run Appium Server
uses: moatazeldebsy/[email protected]
- name: Set up NodeJS 18
uses: actions/setup-node@v4
with:
node-version: '18.19.0'

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run Android Emulator
- name: Install the Emulator
run: |
chmod +x ./scripts/RunAppiumServer.sh
./scripts/RunAppiumServer.sh
shell: bash

- name: Run Appium Tests
uses: reactivecircus/[email protected]
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
profile: pixel 6a
script: ./gradlew connectedCheck
26 changes: 26 additions & 0 deletions scripts/RunAppiumServer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# This script sets up Appium for iOS (XCUITest), Android (uiautomator2), and Flutter testing environments.
# It installs the latest version of Appium globally using npm, then installs drivers for XCUITest,
# Espresso, and Flutter. Finally, it starts Appium in the background and logs its output to a file named "appium.log".

# Exit immediately if a command exits with a non-zero status.
set -ex

# Install the latest version of Appium globally.
npm install -g appium@next

# Install the XCUITest driver for iOS testing.
appium driver install xcuitest

# Install the Espresso driver for Android testing.
appium driver install uiautomator2

# Install the Flutter driver for Flutter testing.
appium driver install --source=npm appium-flutter-driver

# Display the installed version of Appium.
appium -v

# Start Appium in the background, redirecting both stdout and stderr to /dev/null to suppress output,
# but also log everything to a file named "appium.log".
appium --log appium.log &>/dev/null &
23 changes: 23 additions & 0 deletions scripts/emulator-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#https://docs.travis-ci.com/user/languages/android/
#https://developer.android.com/training/testing/continuous-integration#:~:text=The%20CI%20system%20detects%20a,or%20emulator%20images%20if%20needed.
#!/bin/bash

set -e #stop immediately if any error happens

avd_name=$1

if [[ -z "$avd_name" ]]; then
avd_name="avd29"
fi

#check if emulator works well
emulator -version

# create virtual device, default using Android 9 Pie image (API Level 28)
echo no | avdmanager create avd -n avd28 -k "system-images;android-29;google_apis;x86_64"

# start the emulator
emulator -avd avd28 -no-audio -no-window -no-accel &

# show connected virtual device
adb devices
30 changes: 30 additions & 0 deletions scripts/install-android-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e #stop immediately if any error happens

# Install Open JDK SDK
sudo apt update
sudo apt install openjdk-8-jdk -y
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64
sudo apt-get install android-sdk

java -version

# Install SDK Manager
# you can find this file at https://developer.android.com/studio/index.html#downloads android studio downloads section (command line tools only)
cd ~ && wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
ANDROID_HOME=/opt/androidsdk
mkdir -p $ANDROID_HOME
sudo apt install unzip -y && unzip sdk-tools-linux-4333796.zip -d $ANDROID_HOME

echo "export ANDROID_HOME=$ANDROID_HOME" >> ~/.bashrc
echo 'export SDK=$ANDROID_HOME' >> ~/.bashrc
echo 'export PATH=$SDK/emulator:$SDK/tools:$SDK/tools/bin:$SDK/platform-tools:$PATH' >> ~/.bashrc
source ~/.bashrc

# Install Android Image version 29
yes | sudo sdkmanager "platform-tools" "platforms;android-29" "emulator"
yes | sudo sdkmanager "system-images;android-29;google_apis;x86_64"
emulator -version

echo "INSTALL ANDROID SDK DONE!"

0 comments on commit 0066001

Please sign in to comment.