Skip to content

Commit eb49786

Browse files
committed
chore: add new e2e setup
1 parent c4abb8d commit eb49786

9 files changed

Lines changed: 448 additions & 93 deletions

.github/workflows/e2e-expo-example-android.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/e2e-expo-example-ios.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build Android Debug App
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Build on main for caching purposes, this way every branch will have access to it
7+
workflow_call:
8+
outputs:
9+
build-cache-key:
10+
description: 'The primary key used for caching the build'
11+
value: android-debug-build-${{ jobs.lookup-cached-build.outputs.fingerprint }}
12+
13+
jobs:
14+
lookup-cached-build:
15+
name: Lookup cached debug build
16+
uses: ./.github/workflows/expo-example-lookup-cached-debug-build.yml
17+
with:
18+
platform: android
19+
20+
build-debug-android:
21+
name: Build Android Debug App
22+
needs: lookup-cached-build
23+
if: needs.lookup-cached-build.outputs.build-exists != 'true'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: 💾 Maximize build space
27+
uses: AdityaGarg8/remove-unwanted-software@v4.1
28+
with:
29+
remove-dotnet: 'true'
30+
remove-haskell: 'true'
31+
remove-codeql: 'true'
32+
remove-docker-images: 'true'
33+
34+
- name: 🏗 Checkout repository
35+
uses: actions/checkout@v4
36+
37+
- name: 🌿 Setup Node
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version-file: 'examples/expo-example/.nvmrc'
41+
cache: 'yarn'
42+
43+
- name: ☕ Setup JDK 17
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: '17'
47+
distribution: 'zulu'
48+
49+
- name: 🐘 Setup Gradle 8.8
50+
uses: gradle/actions/setup-gradle@v4
51+
with:
52+
gradle-version: 8.8
53+
54+
- name: 📦 Install dependencies
55+
run: yarn install --immutable
56+
57+
- name: 🛠️ Build
58+
run: yarn run build:debug:android
59+
working-directory: examples/expo-example
60+
61+
- name: 📁 Prepare cache folder
62+
run: |
63+
mkdir android-debug-build
64+
mv examples/expo-example/android/app/build/outputs/apk/debug/app-debug.apk android-debug-build/android-debug.apk
65+
66+
- name: 📡 Store built app in cache
67+
id: android-debug-save
68+
uses: actions/cache/save@v4
69+
with:
70+
path: android-debug-build/
71+
key: android-debug-build-${{ needs.lookup-cached-build.outputs.fingerprint }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build iOS Debug App
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Build on main for caching purposes, this way every branch will have access to it
7+
workflow_call:
8+
outputs:
9+
build-cache-key:
10+
description: 'The primary key used for caching the build'
11+
value: ios-debug-build-${{ jobs.lookup-cached-build.outputs.fingerprint }}
12+
13+
jobs:
14+
lookup-cached-build:
15+
name: Lookup cached debug build
16+
uses: ./.github/workflows/expo-example-lookup-cached-debug-build.yml
17+
with:
18+
platform: ios
19+
20+
build-debug-ios:
21+
name: Build iOS Debug App
22+
needs: lookup-cached-build
23+
if: needs.lookup-cached-build.outputs.build-exists != 'true'
24+
runs-on: macos-latest
25+
steps:
26+
- name: 🏗 Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: 🌿 Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version-file: 'examples/expo-example/.nvmrc'
33+
cache: 'yarn'
34+
35+
- name: 🔨 Use latest stable Xcode
36+
uses: maxim-lobanov/setup-xcode@v1
37+
with:
38+
xcode-version: latest-stable
39+
40+
- name: 📦 Install dependencies
41+
run: yarn install --immutable
42+
43+
- name: 🛠️ Build
44+
run: yarn run build:debug:ios
45+
working-directory: examples/expo-example
46+
47+
- name: 📁 Prepare cache folder
48+
run: |
49+
mkdir ios-debug-build
50+
mv examples/expo-example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeLegalExpoExample.app ios-debug-build/ios-debug.app
51+
52+
- name: 📡 Store built app in cache
53+
id: ios-debug-save
54+
uses: actions/cache/save@v4
55+
with:
56+
path: ios-debug-build/
57+
key: ios-debug-build-${{ needs.lookup-cached-build.outputs.fingerprint }}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Maestro Test Android
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- examples/expo-example/**
7+
8+
jobs:
9+
build-debug-android:
10+
name: Build Android Debug App
11+
uses: ./.github/workflows/expo-example-build-debug-android.yml
12+
13+
android-e2e:
14+
name: Run Expo Example Android E2E Tests
15+
needs: build-debug-android
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 60
18+
permissions:
19+
checks: read
20+
contents: read
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
env:
25+
API_LEVEL: 34
26+
steps:
27+
- name: 🏗 Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: 🐛 Restore debug build from cache
31+
uses: actions/cache/restore@v4
32+
with:
33+
path: android-debug-build/
34+
key: ${{ needs.build-debug-android.outputs.build-cache-key }}
35+
36+
- name: 🌿 Setup Node
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version-file: 'examples/expo-example/.nvmrc'
40+
cache: 'yarn'
41+
42+
- name: ☕ Setup JDK 17
43+
uses: actions/setup-java@v4
44+
with:
45+
java-version: '17'
46+
distribution: 'zulu'
47+
48+
- name: 🐘 Setup Gradle 8.8
49+
uses: gradle/actions/setup-gradle@v4
50+
with:
51+
gradle-version: 8.8
52+
53+
- name: 📦 Install dependencies
54+
run: yarn install --immutable
55+
56+
- name: 📦 Install AVD dependencies
57+
run: |
58+
sudo apt update
59+
sudo apt-get install -y libpulse0 libgl1
60+
61+
- name: 📦 Install Maestro
62+
run: |
63+
MAESTRO_VERSION=1.38.1
64+
curl -fsSL "https://get.maestro.mobile.dev" | bash
65+
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
66+
67+
- name: 🏎️ Enable KVM
68+
run: |
69+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
70+
sudo udevadm control --reload-rules
71+
sudo udevadm trigger --name-match=kvm
72+
73+
- name: 📱 AVD cache restore
74+
uses: actions/cache/restore@v4
75+
id: avd-cache-restore
76+
with:
77+
path: |
78+
~/.android/avd/*
79+
~/.android/adb*
80+
key: avd-${{ env.API_LEVEL }}
81+
82+
- name: 📷 Create AVD and generate snapshot for caching
83+
if: steps.avd-cache-restore.outputs.cache-hit != 'true'
84+
uses: reactivecircus/android-emulator-runner@v2
85+
with:
86+
api-level: ${{ env.API_LEVEL }}
87+
force-avd-creation: false
88+
disable-animations: false
89+
target: google_apis
90+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
91+
avd-name: e2e_emulator
92+
arch: x86_64
93+
script: echo "Generated AVD snapshot for caching."
94+
95+
- name: 📱 AVD cache save
96+
if: steps.avd-cache-restore.outputs.cache-hit != 'true'
97+
uses: actions/cache/save@v4
98+
with:
99+
path: |
100+
~/.android/avd/*
101+
~/.android/adb*
102+
key: avd-${{ env.API_LEVEL }}
103+
104+
- name: 🚇 Run Metro bundler in the background
105+
uses: miguelteixeiraa/action-run-in-background@v1
106+
with:
107+
script: yarn --cwd examples/expo-example start
108+
readiness-script: |
109+
if curl -sSf http://localhost:8081 > /dev/null; then
110+
echo "curl request to metro was successful."
111+
else
112+
echo "curl request to metro failed."
113+
exit 1
114+
fi
115+
116+
- name: 🧪 Run Maestro tests
117+
uses: reactivecircus/android-emulator-runner@v2
118+
with:
119+
api-level: ${{ env.API_LEVEL }}
120+
force-avd-creation: false
121+
disable-animations: false
122+
target: google_apis
123+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none
124+
avd-name: e2e_emulator
125+
arch: x86_64
126+
script: |
127+
adb install android-debug-build/android-debug.apk
128+
yarn run test:e2e:android
129+
working-directory: examples/expo-example

0 commit comments

Comments
 (0)