Repository navigation
130 lines (127 loc) · 5.09 KB
/
Copy pathandroid-device.yml
File metadata and controls
130 lines (127 loc) · 5.09 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
name: Android device tests
on:
workflow_call:
inputs:
api:
required: true
type: number
enabled:
type: boolean
default: true
permissions:
contents: read
jobs:
device:
name: Device tests
# Keep the required caller / Device tests check even when change scope skips this suite.
if: inputs.enabled
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
ANDROID_SERIAL: emulator-5554
MEGAPROXY_ANDROID_ABI: x86_64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
cache: gradle
- uses: actions/setup-go@v7
with:
go-version-file: native/go.mod
cache-dependency-path: native/go.sum
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4.10"
bundler-cache: true
- uses: android-actions/setup-android@v4
with:
packages: platform-tools
log-accepted-android-sdk-licenses: false
- name: Enable hardware acceleration
run: |
test -e /dev/kvm
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: Install SDK and check acceleration
env:
DEVICE_API: ${{ inputs.api }}
run: |
packages=('emulator' 'platform-tools' 'platforms;android-36' 'build-tools;36.0.0' 'ndk;29.0.14206865' "system-images;android-$DEVICE_API;google_apis;x86_64")
if ! sdkmanager "${packages[@]}"; then
echo 'SDK installation failed; retrying once.' >&2
sdkmanager "${packages[@]}"
fi
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/29.0.14206865" >> "$GITHUB_ENV"
"$ANDROID_HOME/emulator/emulator" -accel-check
- name: Build debug and instrumentation APKs
run: bundle exec fastlane android device_test_build
- name: Run real Android tests
id: device_tests
continue-on-error: true
uses: reactivecircus/android-emulator-runner@v2.38.0
with: &device_test_options
api-level: ${{ inputs.api }}
target: google_apis
arch: x86_64
avd-name: megaproxy-device
profile: pixel_5
force-avd-creation: false
# Stream kernel failures independently of ADB. Combining this with -logcat
# makes API 35 assign two serial devices to stdio and abort before boot.
emulator-options: -accel on -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -show-kernel
disable-animations: true
script: |
mkdir -p test-results/android-api${{ inputs.api }}
touch test-results/android-api${{ inputs.api }}/runner-started
bundle exec fastlane android device_tests api:${{ inputs.api }}
- name: Collect runner diagnostics
if: ${{ !cancelled() && steps.device_tests.outcome == 'failure' }}
env:
DEVICE_API: ${{ inputs.api }}
run: |
mkdir -p "test-results/android-api$DEVICE_API"
{
date -u
"$ANDROID_HOME/platform-tools/adb" devices -l
ps -eo pid,ppid,stat,rss,comm
free -m
df -h
sudo dmesg --ctime | tail -200
} > "test-results/android-api$DEVICE_API/host-diagnostics.txt" 2>&1
- name: Retry emulator startup before tests only
id: device_retry
if: ${{ !cancelled() && steps.device_tests.outcome == 'failure' && hashFiles(format('test-results/android-api{0}/runner-started', inputs.api)) == '' }}
continue-on-error: true
uses: reactivecircus/android-emulator-runner@v2.38.0
with: *device_test_options
- name: Require successful device tests
if: ${{ !cancelled() && steps.device_tests.outcome == 'failure' && steps.device_retry.outcome != 'success' }}
run: |
echo 'Device tests failed, or emulator startup failed on both attempts.' >&2
exit 1
- name: Upload Android evidence
if: always()
id: evidence
uses: actions/upload-artifact@v7
with:
name: android-api${{ inputs.api }}-results
path: test-results/android-api${{ inputs.api }}/
if-no-files-found: warn
retention-days: 7
- name: Upload emulator JUnit report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: junit-Android API ${{ inputs.api }}
overwrite: true
path: test-results/android-api${{ inputs.api }}/junit.xml
retention-days: 7
- name: Link evidence in job summary
if: always() && steps.evidence.outputs.artifact-url != ''
env:
ARTIFACT_URL: ${{ steps.evidence.outputs.artifact-url }}
DEVICE_API: ${{ inputs.api }}
run: echo "[Android API $DEVICE_API reports, Logcat and failure screenshots]($ARTIFACT_URL)" >> "$GITHUB_STEP_SUMMARY"