Skip to content

Commit 2250a65

Browse files
chore: add maestro tests to CI
1 parent 84378d2 commit 2250a65

3 files changed

Lines changed: 179 additions & 4 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: E2E Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
merge_group:
10+
types:
11+
- checks_requested
12+
13+
jobs:
14+
changes:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
android: ${{ steps.filter.outputs.android }}
18+
ios: ${{ steps.filter.outputs.ios }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Check file changes
24+
uses: dorny/paths-filter@v3
25+
id: filter
26+
with:
27+
filters: |
28+
android:
29+
- 'android/**'
30+
- 'apps/example/android/**'
31+
- 'apps/example/src/**'
32+
- 'src/**'
33+
- 'cpp/**'
34+
- 'package.json'
35+
- 'apps/example/package.json'
36+
- 'react-native.config.js'
37+
- 'babel.config.js'
38+
- '.maestro/**'
39+
ios:
40+
- 'ios/**'
41+
- 'apps/example/ios/**'
42+
- 'apps/example/src/**'
43+
- 'src/**'
44+
- 'cpp/**'
45+
- '*.podspec'
46+
- 'package.json'
47+
- 'apps/example/package.json'
48+
- 'react-native.config.js'
49+
- 'babel.config.js'
50+
- '.maestro/**'
51+
52+
e2e-ios:
53+
needs: [changes]
54+
if: needs.changes.outputs.ios == 'true'
55+
runs-on: macos-latest
56+
timeout-minutes: 60
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Setup
62+
uses: ./.github/actions/setup
63+
64+
- name: Set up Xcode
65+
uses: maxim-lobanov/setup-xcode@v1
66+
with:
67+
xcode-version: latest-stable
68+
69+
- name: Install Maestro CLI
70+
run: |
71+
curl -Ls "https://get.maestro.mobile.dev" | bash
72+
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
73+
74+
- name: Restore cocoapods
75+
id: cocoapods-cache
76+
uses: actions/cache/restore@v4
77+
with:
78+
path: |
79+
**/ios/Pods
80+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('apps/example/ios/Podfile.lock') }}
81+
restore-keys: |
82+
${{ runner.os }}-cocoapods-
83+
84+
- name: Install cocoapods
85+
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
86+
run: |
87+
cd apps/example/ios
88+
pod install
89+
env:
90+
NO_FLIPPER: 1
91+
92+
- name: Cache cocoapods
93+
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
94+
uses: actions/cache/save@v4
95+
with:
96+
path: |
97+
**/ios/Pods
98+
key: ${{ steps.cocoapods-cache.outputs.cache-key }}
99+
100+
- name: Run E2E tests
101+
run: yarn test:e2e:ios
102+
103+
- name: Upload test artifacts
104+
if: failure()
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: e2e-ios-artifacts
108+
path: |
109+
.maestro/screenshots/
110+
111+
e2e-android:
112+
needs: [changes]
113+
if: needs.changes.outputs.android == 'true'
114+
runs-on: ubuntu-latest
115+
timeout-minutes: 60
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
120+
- name: Setup
121+
uses: ./.github/actions/setup
122+
123+
- name: Enable KVM
124+
run: |
125+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
126+
sudo udevadm control --reload-rules
127+
sudo udevadm trigger --name-match=kvm
128+
129+
- name: Install JDK
130+
uses: actions/setup-java@v4
131+
with:
132+
distribution: 'zulu'
133+
java-version: '17'
134+
135+
- name: Finalize Android SDK
136+
run: |
137+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
138+
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> $GITHUB_PATH
139+
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
140+
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
141+
142+
- name: Install Maestro CLI
143+
run: |
144+
curl -Ls "https://get.maestro.mobile.dev" | bash
145+
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
146+
147+
- name: Cache Gradle
148+
uses: actions/cache@v4
149+
with:
150+
path: |
151+
~/.gradle/wrapper
152+
~/.gradle/caches
153+
key: ${{ runner.os }}-gradle-${{ hashFiles('apps/example/android/gradle/wrapper/gradle-wrapper.properties') }}
154+
restore-keys: |
155+
${{ runner.os }}-gradle-
156+
157+
- name: Run E2E tests
158+
run: yarn test:e2e:android
159+
env:
160+
JAVA_OPTS: '-XX:MaxHeapSize=6g'
161+
162+
- name: Upload test artifacts
163+
if: failure()
164+
uses: actions/upload-artifact@v4
165+
with:
166+
name: e2e-android-artifacts
167+
path: |
168+
.maestro/screenshots/

.maestro/scripts/setup-android-emulator.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ fi
5050

5151
AVD_CONFIG="$HOME/.android/avd/${AVD_NAME}.avd/config.ini"
5252
if [ -f "$AVD_CONFIG" ]; then
53-
sed -i '' 's/^hw\.keyboard=.*/hw.keyboard=yes/' "$AVD_CONFIG"
53+
sed -i.bak 's/^hw\.keyboard=.*/hw.keyboard=yes/' "$AVD_CONFIG"
5454
grep -q "^hw.keyboard=" "$AVD_CONFIG" || echo "hw.keyboard=yes" >> "$AVD_CONFIG"
55-
sed -i '' 's/^hw\.mainKeys=.*/hw.mainKeys=yes/' "$AVD_CONFIG"
55+
sed -i.bak 's/^hw\.mainKeys=.*/hw.mainKeys=yes/' "$AVD_CONFIG"
5656
grep -q "^hw.mainKeys=" "$AVD_CONFIG" || echo "hw.mainKeys=yes" >> "$AVD_CONFIG"
57+
rm -f "$AVD_CONFIG.bak"
5758
fi
5859

5960
if pgrep -f "emulator.*${AVD_NAME}" > /dev/null 2>&1; then
@@ -63,7 +64,11 @@ if pgrep -f "emulator.*${AVD_NAME}" > /dev/null 2>&1; then
6364
fi
6465

6566
echo "Starting emulator '$AVD_NAME'..."
66-
emulator "@${AVD_NAME}" -port "$PORT" > /dev/null 2>&1 &
67+
EMULATOR_ARGS=("@${AVD_NAME}" -port "$PORT")
68+
if [ -n "${CI:-}" ]; then
69+
EMULATOR_ARGS+=(-no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim)
70+
fi
71+
emulator "${EMULATOR_ARGS[@]}" > /dev/null 2>&1 &
6772

6873
echo "Waiting for emulator ($SERIAL) to connect to ADB..."
6974
if ! timeout 120 adb -s "$SERIAL" wait-for-device; then

.maestro/scripts/setup-ios-simulator.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ if [ "$STATE" != "(Booted)" ]; then
3131
xcrun simctl boot "$UDID"
3232
fi
3333

34-
open -a Simulator
34+
if [ -z "${CI:-}" ]; then
35+
open -a Simulator
36+
fi
3537

3638
echo "Simulator ready: $DEVICE_NAME ($UDID)"
3739
echo "DEVICE_ID=$UDID"

0 commit comments

Comments
 (0)