-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (126 loc) · 4.8 KB
/
e2e-tests.yml
File metadata and controls
145 lines (126 loc) · 4.8 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
name: E2E Tests
on:
pull_request:
jobs:
e2e-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo docker image prune --all --force
echo "Disk space after cleanup:"
df -h
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: Install SDK dependencies
run: npm install
- name: Build SDK
run: npm run build
- name: Install example app dependencies
working-directory: ./example
run: npm install
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install Maestro CLI
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Verify Maestro installation
run: maestro --version
- 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: Cache AVD
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-31
- 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: 31
arch: x86_64
target: google_apis
profile: pixel_6
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "Generated AVD snapshot for caching."
- name: Build Android app
working-directory: ./example
run: |
npx expo prebuild --platform android
cd android
./gradlew assembleDebug
ls -la app/build/outputs/apk/debug/
- name: Run Maestro tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
arch: x86_64
target: google_apis
profile: pixel_6
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb install example/android/app/build/outputs/apk/debug/app-debug.apk
mkdir -p example/maestro-output
# Run tests (produce JUnit results) and capture artifacts under example/maestro-output
maestro test ./example/maestro/ --format junit --output example/maestro-results.xml || true
# Run record to capture screenshots & artifacts into the output directory (use --local to render a video file)
maestro record --local ./example/maestro/ example/maestro-output/recording.mp4 || true
# If Maestro also wrote to the user home tests dir, copy those into the output dir for upload
if [ -d "$HOME/.maestro/tests" ]; then
mkdir -p example/maestro-output/.maestro-tests
cp -r "$HOME/.maestro/tests/." example/maestro-output/.maestro-tests/ || true
fi
echo "Listing example/maestro-output contents:"; ls -la example/maestro-output || true
if [ -d example/maestro-output ]; then
echo "Creating tarball example/maestro-output.tar.gz"
tar -czf example/maestro-output.tar.gz -C example maestro-output || true
fi
ls -la example/ || true
- name: Upload Maestro test results
if: always()
uses: actions/upload-artifact@v4
with:
name: maestro-test-results
path: |
example/maestro-results.xml
example/maestro-output/
example/maestro-output.tar.gz
~/.maestro/tests/
retention-days: 7
if-no-files-found: warn