-
-
Notifications
You must be signed in to change notification settings - Fork 229
190 lines (168 loc) · 7.37 KB
/
device-tests-android.yml
File metadata and controls
190 lines (168 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Android Device Tests
on:
push:
branches:
- main
- release/*
pull_request:
paths:
# Core SDK (transitive dependency of all mobile packages)
- 'src/Sentry/**'
- 'src/Sentry.Extensions.Logging/**'
# Mobile-specific packages
- 'src/Sentry.Maui/**'
- 'src/Sentry.Maui.CommunityToolkit.Mvvm/**'
- 'src/Sentry.Bindings.Android/**'
- 'src/Sentry.Bindings.Cocoa/**'
- 'src/Sentry.Android.AssemblyReader/**'
# Device test app and test projects that run on device
- 'test/Sentry.Maui.Device.TestApp/**'
- 'test/Sentry.Tests/**'
- 'test/Sentry.Extensions.Logging.Tests/**'
- 'test/Sentry.Maui.Tests/**'
- 'test/Sentry.Maui.CommunityToolkit.Mvvm.Tests/**'
- 'test/Sentry.Android.AssemblyReader.Tests/**'
- 'test/Sentry.Testing/**'
# Integration tests
- 'integration-test/android.Tests.ps1'
- 'integration-test/ios.Tests.ps1'
- 'integration-test/net9-maui/**'
# Scripts, native modules, and CI
- 'scripts/device-test.ps1'
- 'scripts/device-test-utils.ps1'
- 'modules/sentry-native/**'
- '.github/workflows/device-tests-android.yml'
- '.github/actions/**'
workflow_dispatch:
jobs:
build:
name: Build (${{ matrix.tfm }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tfm: [net9.0, net10.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@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
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 (${{ matrix.tfm }})
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: device-test-android-${{ matrix.tfm }}
if-no-files-found: error
path: test/Sentry.Maui.Device.TestApp/bin/Release/${{ matrix.tfm }}-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: [net9.0, net10.0]
# Must be 34+ for new apps and app updates as of August 31, 2024.
# See https://apilevels.com/
api-level: [34, 36]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
# We don't need the Google APIs, but the default images are not available for 32+
ANDROID_EMULATOR_TARGET: google_apis
ANDROID_EMULATOR_RAM_SIZE: 2048M
ANDROID_EMULATOR_ARCH: x86_64
ANDROID_EMULATOR_DISK_SIZE: 4096M
ANDROID_EMULATOR_OPTIONS: -no-snapshot-save -no-window -accel on -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Download test app artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: device-test-android-${{ matrix.tfm }}
path: bin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1
# Cached AVD setup per https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md
- name: Run Tests
id: first-test-run
continue-on-error: true
timeout-minutes: 40
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
with: &android-emulator-test
api-level: ${{ matrix.api-level }}
target: ${{ env.ANDROID_EMULATOR_TARGET }}
force-avd-creation: false
ram-size: ${{ env.ANDROID_EMULATOR_RAM_SIZE }}
arch: ${{ env.ANDROID_EMULATOR_ARCH }}
disk-size: ${{ env.ANDROID_EMULATOR_DISK_SIZE }}
emulator-options: ${{ env.ANDROID_EMULATOR_OPTIONS }}
disable-animations: false
script: pwsh scripts/device-test.ps1 android -Run -Tfm ${{ matrix.tfm }}
- name: Retry Tests (if previous failed to run)
if: steps.first-test-run.outcome == 'failure'
timeout-minutes: 40
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
with: *android-emulator-test
- name: Setup Environment
uses: ./.github/actions/environment
- name: Select Java 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: ${{ runner.os == 'Windows' && runner.arch == 'ARM64' && 'microsoft' || 'temurin' }}
java-version: '17'
- name: Checkout github-workflows
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: getsentry/github-workflows
ref: 95603f4efe938315ff0dd427a1f2bb40b1889a92 # 3.2.0
path: modules/github-workflows
- name: Run Integration Tests
id: first-integration-test-run
continue-on-error: true
timeout-minutes: 40
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
with: &android-emulator-integration-test
api-level: ${{ matrix.api-level }}
target: ${{ env.ANDROID_EMULATOR_TARGET }}
force-avd-creation: false
ram-size: ${{ env.ANDROID_EMULATOR_RAM_SIZE }}
arch: ${{ env.ANDROID_EMULATOR_ARCH }}
disk-size: ${{ env.ANDROID_EMULATOR_DISK_SIZE }}
emulator-options: ${{ env.ANDROID_EMULATOR_OPTIONS }}
disable-animations: false
script: pwsh integration-test/android.Tests.ps1 -dotnet_version ${{ matrix.tfm }}
- name: Retry Integration Tests (if previous failed to run)
if: steps.first-integration-test-run.outcome == 'failure'
timeout-minutes: 40
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
with: *android-emulator-integration-test
- name: Upload results
if: success() || failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: device-test-android-${{ matrix.api-level }}-${{ matrix.tfm }}-results
path: |
test_output
integration-test/mobile-app/test_output