-
Notifications
You must be signed in to change notification settings - Fork 119
153 lines (132 loc) · 4.33 KB
/
e2e-android-test.yml
File metadata and controls
153 lines (132 loc) · 4.33 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
name: End-to-End Tests for Android
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/e2e-android-test.yml'
- 'example/**'
- 'cpp/**'
- 'nitrogen/**'
- 'src/**'
push:
branches: [main]
paths:
- 'example/**'
- 'cpp/**'
- 'nitrogen/**'
- 'src/**'
jobs:
e2e-tests-android:
runs-on: ubuntu-latest
env:
EMULATOR_API_LEVEL: 34
OUTPUT_DIR: ~/output
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
- name: Install Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Create Directories
run: |
mkdir -p $HOME/output
mkdir -p $HOME/.maestro/tests/
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
cache: gradle
- name: Cache Android SDK
uses: actions/cache@v4
with:
path: |
"${{ env.ANDROID_SDK_ROOT }}"
~/.android
key: "${{ runner.os }}-android-sdk-${{ hashFiles('.github/workflows/e2e-android-test.yml') }}"
restore-keys: |
"${{ runner.os }}-android-sdk-"
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install Dependencies
run: bun install
- name: Install Maestro CLI
run: |
export MAESTRO_VERSION=2.0.10
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Enable KVM
if: env.SKIP_KVM != 'true'
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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.EMULATOR_API_LEVEL }}
- name: Create AVD and Generate Snapshot for Caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.EMULATOR_API_LEVEL }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Make scripts executable
run: chmod +x test/e2e/*.sh
working-directory: ./example/
- name: Run E2E Tests
uses: reactivecircus/android-emulator-runner@v2
id: test_android
continue-on-error: true
with:
api-level: ${{ env.EMULATOR_API_LEVEL }}
arch: x86_64
profile: pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
disable-animations: true
working-directory: ./example/
script: ./test/e2e/run-android.sh
- name: Post Maestro Screenshot to PR
if: always()
uses: ./.github/actions/post-maestro-screenshot
with:
platform: android
github-token: ${{ secrets.GITHUB_TOKEN }}
test-outcome: ${{ steps.test_android.outcome }}
imgbb-api-key: ${{ secrets.IMGBB_API_KEY }}
- name: Upload Test Output
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-android-test-output
path: |
${{ env.OUTPUT_DIR }}/*.log
${{ env.OUTPUT_DIR }}/screenshots/*.png
retention-days: 5
- name: Exit with Test Result
if: always()
run: |
if [ "${{ steps.test_android.outcome }}" != "success" ]; then
exit 1
fi