Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update appium dependencies and add android CI tests #410

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ updates:
schedule:
interval: "weekly"
allow:
- dependency-name: "org.seleniumhq.selenium:selenium-java"
- dependency-name: "org.seleniumhq.selenium:selenium-java"
- dependency-name: "io.appium:java-client"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TESTAR release
name: TESTAR distribution release

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: TESTAR Docker release

on:
push:
Expand All @@ -11,20 +11,26 @@ jobs:
steps:
- name: Check out the TESTAR_dev repo
uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Prepare tar distribution of TESTAR with Gradle
run: ./gradlew distTar

- name: Build the testar chromedriver docker image
run: docker build -t testartool/testar-chromedriver:latest .

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push TESTAR docker image to Docker Hub
run: docker push testartool/testar-chromedriver:latest
106 changes: 106 additions & 0 deletions .github/workflows/start_emu_headless.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash

# https://github.com/amrsa1/android-emulator-workflow

BL='\033[0;34m'
G='\033[0;32m'
RED='\033[0;31m'
YE='\033[1;33m'
NC='\033[0m' # No Color

emulator_name=${EMULATOR_NAME}

function check_hardware_acceleration() {
if [[ "$HW_ACCEL_OVERRIDE" != "" ]]; then
hw_accel_flag="$HW_ACCEL_OVERRIDE"
else
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS-specific hardware acceleration check
HW_ACCEL_SUPPORT=$(sysctl -a | grep -E -c '(vmx|svm)')
else
# generic Linux hardware acceleration check
HW_ACCEL_SUPPORT=$(grep -E -c '(vmx|svm)' /proc/cpuinfo)
fi

if [[ $HW_ACCEL_SUPPORT == 0 ]]; then
hw_accel_flag="-accel off"
else
hw_accel_flag="-accel on"
fi
fi

echo "$hw_accel_flag"
}

hw_accel_flag=$(check_hardware_acceleration)

function launch_emulator () {
adb devices | grep emulator | cut -f1 | xargs -I {} adb -s "{}" emu kill
options="@${emulator_name} -no-window -no-snapshot -screen no-touch -noaudio -memory 2048 -no-boot-anim ${hw_accel_flag} -camera-back none"
if [[ "$OSTYPE" == *linux* ]]; then
echo "${OSTYPE}: emulator ${options} -gpu off"
nohup emulator $options -gpu off &
fi
if [[ "$OSTYPE" == *darwin* ]] || [[ "$OSTYPE" == *macos* ]]; then
echo "im here"
echo "${OSTYPE}: emulator ${options} -gpu swiftshader_indirect"
nohup emulator $options -gpu swiftshader_indirect &
fi

if [ $? -ne 0 ]; then
echo "Error launching emulator"
return 1
fi
}

function check_emulator_status () {
printf "${G}==> ${BL}Checking emulator booting up status 🧐${NC}\n"
start_time=$(date +%s)
spinner=( "⠹" "⠺" "⠼" "⠶" "⠦" "⠧" "⠇" "⠏" )
i=0
# Get the timeout value from the environment variable or use the default value of 300 seconds (5 minutes)
timeout=${EMULATOR_TIMEOUT:-300}

while true; do
result=$(adb shell getprop sys.boot_completed 2>&1)

if [ "$result" == "1" ]; then
printf "\e[K${G}==> \u2713 Emulator is ready : '$result' ${NC}\n"
adb devices -l
adb shell input keyevent 82
break
elif [ "$result" == "" ]; then
printf "${YE}==> Emulator is partially Booted! 😕 ${spinner[$i]} ${NC}\r"
else
printf "${RED}==> $result, please wait ${spinner[$i]} ${NC}\r"
i=$(( (i+1) % 8 ))
fi

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -gt $timeout ]; then
printf "${RED}==> Timeout after ${timeout} seconds elapsed 🕛.. ${NC}\n"
break
fi
sleep 4
done
};

function disable_animation() {
adb shell "settings put global window_animation_scale 0.0"
adb shell "settings put global transition_animation_scale 0.0"
adb shell "settings put global animator_duration_scale 0.0"
};

function hidden_policy() {
adb shell "settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1"
};

launch_emulator
sleep 2
check_emulator_status
sleep 1
disable_animation
sleep 1
hidden_policy
sleep 1
39 changes: 39 additions & 0 deletions .github/workflows/test-macos-chromedriver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: macOS TESTAR Chromedriver CI tests

on:
pull_request:
branches: [ master ]

jobs:
macos:
runs-on: macos-latest
timeout-minutes: 10
continue-on-error: true

strategy:
fail-fast: false
matrix:
java: [ '11', '17', '21' ]

steps:
- uses: actions/checkout@v4
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Prepare TESTAR protocols
run: ./gradlew init_workflow_test

- name: Build TESTAR with Gradle
run: ./gradlew build

- name: Prepare installed distribution of TESTAR with Gradle
run: ./gradlew installDist

- name: Run webdriver protocol and detect SuspiciousTag
run: ./gradlew runTestWebdriverSuspiciousTagMacOS
121 changes: 121 additions & 0 deletions .github/workflows/test-ubuntu-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Ubuntu TESTAR Android CI tests

on:
pull_request:
branches: [ master ]

env:
ANDROID_ARCH: x86_64
ANDROID_TARGET: google_apis_playstore
API_LEVEL: 33
ANDROID_BUILD_TOOLS_VERSION: 33.0.2
ANDROID_SDK_PACKAGES: system-images;android-33;google_apis_playstore;x86_64 platforms;android-33 build-tools;33.0.2 platform-tools emulator
EMULATOR_TIMEOUT: 350
EMULATOR_NAME: nexus

jobs:
android:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
java: [ '11' ]

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}

# https://github.com/marketplace/actions/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
- name: Enable KVM group perms
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

# https://github.com/amrsa1/android-emulator-workflow
- name: Add avdmanager and sdkmanager to system PATH
run: |
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH

- name: Install SDK
run: |
yes Y | sdkmanager --licenses
sdkmanager --install ${ANDROID_SDK_PACKAGES}

- name: Build emulator
run: |
echo "no" | avdmanager --verbose create avd --force -n $EMULATOR_NAME --abi "${ANDROID_TARGET}/${ANDROID_ARCH}" -k "system-images;android-${API_LEVEL};${ANDROID_TARGET};${ANDROID_ARCH}"

- name: Launch emulator
run: |
chmod +x ./.github/workflows/start_emu_headless.sh
EMULATOR_TIMEOUT=$EMULATOR_TIMEOUT EMULATOR_NAME=$EMULATOR_NAME ./.github/workflows/start_emu_headless.sh

# https://github.com/TESTARtool/TESTAR_dev/wiki/TESTAR-and-Appium-for-Mobile-Systems#installing-appium
- name: Install Appium
run: |
npm i -g appium@next
appium --version
appium driver install uiautomator2
appium driver list --installed

- name: Start Appium Server
run: |
appium --relaxed-security --session-override --base-path /wd/hub &

- name: Test Appium Connection
run: |
MAX_WAIT=30
INTERVAL=1
echo "Waiting for Appium to be fully up and running..."

for i in $(seq 1 $MAX_WAIT); do
if [ "$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:4723/wd/hub/status)" -eq 200 ]; then
echo "Appium is up and running."
exit 0
fi
sleep $INTERVAL
done

echo "Appium did not start within $MAX_WAIT seconds."
exit 1

# Build and run TESTAR
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Prepare TESTAR protocols
run: ./gradlew init_workflow_test

- name: Build TESTAR with Gradle
run: ./gradlew build

- name: Prepare installed distribution of TESTAR with Gradle
run: ./gradlew installDist

- name: Run TESTAR android generic protocol
run: ./gradlew runTestAndroidGenericOk
- name: Save runTestAndroidGenericOk HTML report artifact
uses: actions/upload-artifact@v4
# Only upload GitHub Actions results if this task fails (Can be replaced with 'if: always()')
#if: failure()
with:
name: Java${{ matrix.java }}-runTestAndroidGenericOk-artifact
path: D:/a/TESTAR_dev/TESTAR_dev/testar/target/install/testar/bin/android_ok

- name: Run TESTAR android generic protocol with suspicious message
run: ./gradlew runTestAndroidGenericSuspiciousTag
- name: Save runTestAndroidGenericSuspiciousTag HTML report artifact
uses: actions/upload-artifact@v4
# Only upload GitHub Actions results if this task fails (Can be replaced with 'if: always()')
#if: failure()
with:
name: Java${{ matrix.java }}-runTestAndroidGenericSuspiciousTag-artifact
path: D:/a/TESTAR_dev/TESTAR_dev/testar/target/install/testar/bin/android_suspicious
44 changes: 44 additions & 0 deletions .github/workflows/test-ubuntu-chromedriver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Ubuntu TESTAR Chromedriver CI tests

on:
pull_request:
branches: [ master ]

jobs:
linux:
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true

strategy:
fail-fast: false
matrix:
java: [ '11', '17', '21' ]

steps:
- uses: actions/checkout@v4
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Prepare TESTAR protocols
run: ./gradlew init_workflow_test

- name: Build TESTAR with Gradle
run: ./gradlew build

- name: Prepare installed distribution of TESTAR with Gradle
run: ./gradlew installDist

- name: Install dependencies
run: |
sudo apt-get update
sudo apt install -y xvfb x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 xdotool

- name: Run webdriver protocol and detect SuspiciousTag
run: xvfb-run ./gradlew runTestWebdriverSuspiciousTagUbuntu
Loading
Loading