Skip to content

Build Variables Source Generator #5575

Build Variables Source Generator

Build Variables Source Generator #5575

name: Android Device Tests
on:
push:
branches:
- main
- release/*
pull_request:
paths-ignore:
- "**.md"
jobs:
build:
name: Build (${{ matrix.tfm }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tfm: [net8.0, net9.0]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
steps:
- name: Cancel Previous Runs
if: github.ref_name != 'main' && !startsWith(github.ref_name, 'release/')
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # Tag: 0.12.1
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Environment
uses: ./.github/actions/environment
- name: Build Native Dependencies
uses: ./.github/actions/buildnative
- name: Build Android Test App
run: pwsh ./scripts/device-test.ps1 android -Build -Tfm ${{ matrix.tfm }}
- name: Upload Android Test App (net8.0)
if: matrix.tfm == 'net8.0'
uses: actions/upload-artifact@v4
with:
name: device-test-android-net8.0
if-no-files-found: error
path: test/Sentry.Maui.Device.TestApp/bin/Release/net8.0-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk
- name: Upload Android Test App (net9.0)
if: matrix.tfm == 'net9.0'
uses: actions/upload-artifact@v4
with:
name: device-test-android-net9.0
if-no-files-found: error
path: test/Sentry.Maui.Device.TestApp/bin/Release/net9.0-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk
android:
needs: [build]
name: Run Android API-${{ matrix.api-level }} Test (${{ matrix.tfm }})
# Requires a "larger runner", for nested virtualization support
runs-on: ubuntu-latest-4-cores
strategy:
fail-fast: false
matrix:
tfm: [net8.0, net9.0]
# We run against both an older and a newer API
api-level: [27, 33]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
steps:
# See https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-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
- name: Checkout
uses: actions/checkout@v4
- name: Download test app artifact
uses: actions/download-artifact@v4
with:
name: device-test-android-${{ matrix.tfm }}
path: bin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # pin@v3
# Cached AVD setup per https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md
- name: Run Tests
timeout-minutes: 40
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # Tag: v2.34.0
with:
api-level: ${{ matrix.api-level }}
# We don't need the Google APIs, but the default images are not available for 32+
target: ${{ matrix.api-level >= 32 && 'google_apis' || 'default' }}
force-avd-creation: false
ram-size: 2048M
arch: x86_64
disk-size: 4096M
emulator-options: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: pwsh scripts/device-test.ps1 android -Run -Tfm ${{ matrix.tfm }}
- name: Upload results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: device-test-android-${{ matrix.api-level }}-${{ matrix.tfm }}-results
path: test_output