Skip to content

Remove xharness from macOS pipeline (#21) #123

Remove xharness from macOS pipeline (#21)

Remove xharness from macOS pipeline (#21) #123

name: Run UI Tests Android
on:
push:
branches: [ "main" ]
paths-ignore:
- "**.md"
pull_request:
branches: [ "main" ]
env:
BUILD_CONFIGURATION: Release
CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-android/com.companyname.uitesthelperssample-Signed.apk
CSPROJ_TO_TEST: samples/UITests.Android/UITests.Android.csproj
APP_ID: com.companyname.uitesthelperssample
TARGET_FRAMEWORK: net8.0-android
TEST_EMULATOR_NAME: UITestEmu
ANDROID_EMULATOR_IMAGE: system-images;android-33;default;x86_64
SCREENCAPTURE_FOLDER: samples/UITests.Android/bin/Debug/net8.0
ARTIFACTS_PATH: ${{ github.workspace }}/output
jobs:
ui-test-android:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Restore Workload
run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }}
- name: Publish APK
run: dotnet publish ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }}
- name: Boot Android emulator
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install '${{ env.ANDROID_EMULATOR_IMAGE }}'
echo "no" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/avdmanager create avd --name ${{ env.TEST_EMULATOR_NAME }} --package '${{ env.ANDROID_EMULATOR_IMAGE }}' --force
${ANDROID_HOME}/tools/emulator -avd ${{ env.TEST_EMULATOR_NAME }} -gpu guest -memory 2048 -no-snapshot -no-audio -no-boot-anim -no-window -partition-size 4096 &
# The device is now booting, or close to be booted
# We just wait until the sys.boot_completed property is set to 1.
while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ;
do
echo "Still waiting for boot.."
sleep 10;
done
- name: Install App
run: adb install ${{ env.APP_TO_TEST }}
- name: Install Appium
run: |
npm install -g appium
appium driver install uiautomator2
- name: Run UI Tests
run: dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: logs-and-screenshots
path: |
${{ env.ARTIFACTS_PATH }}/**/*.*
${{ env.SCREENCAPTURE_FOLDER }}/*.png