replace macos with ubuntu and cache VM #1
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
on: | |
workflow_call: | |
inputs: | |
unity-version: | |
required: true | |
type: string | |
api-level: | |
required: true | |
type: string | |
try: | |
required: true | |
type: number | |
# Map the workflow outputs to job outputs | |
outputs: | |
outcome: | |
description: | |
value: ${{ jobs.run.outputs.outcome }} | |
jobs: | |
run: | |
name: try-${{ inputs.try }} | |
runs-on: ubuntu-latest | |
env: | |
ARTIFACTS_PATH: samples/IntegrationTest/test-artifacts/ | |
HOMEBREW_NO_INSTALL_CLEANUP: 1 | |
defaults: | |
run: | |
shell: pwsh | |
# Map the job outputs to step outputs | |
outputs: | |
outcome: ${{ steps.smoke-test.outcome }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download test app artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: testapp-Android-compiled-${{ inputs.unity-version }} | |
path: samples/IntegrationTest/Build | |
# Not required for MacOS. | |
- 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 | |
# outputs variables: api-level, label, target | |
- name: Configure Android Settings | |
id: config | |
run: | | |
# Setup API Level | |
$apiLevel = '${{ inputs.api-level }}' | |
if ( $apiLevel -eq 'latest') | |
{ | |
# Gets the latest API level that isn't in Beta/Alpha | |
$response = (Invoke-WebRequest -UseBasicParsing -Uri "https://developer.android.com/studio/releases/platforms").Content | |
$result = [regex]::Match($response, " \(API level (?<model>\d+)\)") | |
$apiLevel = $result.Groups["model"].Value | |
Write-Output "Latest API is $apiLevel" | |
$label = "$apiLevel (latest)" | |
} | |
else | |
{ | |
Write-Output "Current API is $apiLevel" | |
} | |
# Setup Arch and Target | |
$target = $apiLevel -ge 30 ? 'google_apis' : 'default' | |
Write-Output "Current Target is $target" | |
"target=$target" >> $env:GITHUB_OUTPUT | |
"api-level=$apiLevel" >> $env:GITHUB_OUTPUT | |
"label=$($label ?? $apiLevel)" >> $env:GITHUB_OUTPUT | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ steps.config.outputs.api-level }} | |
- name: create Android Emulator Image | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected] | |
with: | |
api-level: ${{ steps.config.outputs.api-level }} | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
ram-size: 2048M | |
arch: x86_64 | |
cores: 3 | |
disk-size: 4096M | |
script: echo "Generated AVD snapshot for caching." | |
- name: Android API ${{ steps.config.outputs.label }} emulator setup + Smoke test | |
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected] | |
id: smoke-test | |
timeout-minutes: 40 | |
continue-on-error: true | |
with: | |
api-level: ${{ steps.config.outputs.api-level }} | |
target: ${{ steps.config.outputs.target }} | |
force-avd-creation: false | |
ram-size: 2048M | |
arch: x86_64 | |
cores: 3 | |
emulator-boot-timeout: 1800 | |
disk-size: 4096M # Some runs have out of storage error when installing the smoke test. | |
emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: pwsh ./scripts/smoke-test-android.ps1 -IsIntegrationTest -WarnIfFlaky | |
- name: Upload artifacts on failure | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: testapp-android-logs-${{ inputs.api-level }}-${{ inputs.unity-version }}-${{ inputs.try }} | |
path: ${{ env.ARTIFACTS_PATH }} | |
retention-days: 14 |