Adding more comprehensive tests #111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: XHarness Android Test | |
on: | |
pull_request: | |
push: | |
branches: [ main, 'releases/**' ] | |
release: | |
types: [ published ] | |
jobs: | |
android: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- name: Linux | |
os: ubuntu-22.04 | |
gpu: swiftshader_indirect | |
- name: macOS | |
os: macos-13 | |
gpu: guest | |
name: Android (${{ matrix.platform.name }}) | |
runs-on: ${{ matrix.platform.os }} | |
env: | |
TEST_TARGET_FRAMEWORK: net8.0-android | |
TEST_RUNTIME_IDENTIFIER: android-x64 | |
TEST_CONFIGURATION: Release | |
TEST_EMULATOR_NAME: XHarnessEmulator | |
TEST_EMULATOR_IMAGE: system-images;android-34;google_apis;x86_64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Required Tools | |
uses: ./.github/workflows/setup-tools | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'microsoft' | |
java-version: '21' | |
- name: Install Android SDK Packages | |
run: dotnet android sdk install --package 'platform-tools' --package 'emulator' --package '${{ env.TEST_EMULATOR_IMAGE }}' | |
- name: Create Emulator | |
run: dotnet android avd create --name ${{ env.TEST_EMULATOR_NAME }} --sdk '${{ env.TEST_EMULATOR_IMAGE }}' --force | |
- name: Enable KVM | |
if: runner.os == 'Linux' | |
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: Start Emulator | |
run: dotnet android avd start --name ${{ env.TEST_EMULATOR_NAME }} --gpu ${{ matrix.platform.gpu }} --wait-boot --no-window --no-snapshot --no-audio --no-boot-anim | |
- name: Publish App | |
run: | | |
dotnet publish sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj \ | |
-f ${{ env.TEST_TARGET_FRAMEWORK }} \ | |
-r ${{ env.TEST_RUNTIME_IDENTIFIER }} \ | |
-c ${{ env.TEST_CONFIGURATION }} \ | |
-p:TestingMode=XHarness \ | |
-p:AndroidSdkDirectory=$ANDROID_SDK_ROOT \ | |
/bl:./artifacts/logs/msbuild-publish.binlog | |
- name: Run Tests | |
run: | | |
for i in $(seq 1 3) | |
do | |
dotnet xharness android test \ | |
--timeout="00:05:00" \ | |
--launch-timeout=00:10:00 \ | |
--package-name com.companyname.devicetestingkitapp.devicetests \ | |
--instrumentation devicerunners.xharness.maui.XHarnessInstrumentation \ | |
--app sample/test/DeviceTestingKitApp.DeviceTests/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/publish/com.companyname.devicetestingkitapp.devicetests-Signed.apk \ | |
--output-directory artifacts \ | |
&& code=0 && break || code=$? && sleep 15 | |
done | |
exit $code | |
- name: Shutdown the Emulator | |
run: dotnet xharness android adb -- emu kill | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: Test Results - ${{ matrix.platform.name }} | |
path: ./artifacts |