Skip to content

Commit 92bc8c5

Browse files
author
theGrep01
committed
feat: add Android and iOS E2E test workflows and actions
1 parent 0f8e0ca commit 92bc8c5

File tree

4 files changed

+230
-0
lines changed

4 files changed

+230
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Android E2E Tests
2+
description: 'Runs Android E2E tests'
3+
4+
inputs:
5+
app_name:
6+
description: 'Name of the app to test'
7+
required: true
8+
github_token:
9+
description: 'GitHub token for authentication'
10+
required: true
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
clean: true
20+
21+
- name: Setup KVM (Required for Android Emulator)
22+
run: |
23+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
24+
sudo udevadm control --reload-rules
25+
sudo udevadm trigger --name-match=kvm
26+
shell: bash
27+
28+
- uses: pnpm/action-setup@v3
29+
30+
- name: Set up Node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
cache: 'pnpm'
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
shell: bash
39+
40+
- name: Install Maestro CLI
41+
run: |
42+
curl -Ls "https://get.maestro.mobile.dev" | bash
43+
echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
44+
shell: bash
45+
46+
- name: Local RNEF Setup
47+
shell: bash
48+
run: |
49+
RNEF_PATH="apps/${{ inputs.app_name }}/.rnef/cache"
50+
mkdir -p $RNEF_PATH
51+
echo "{\"githubToken\": \"${{ inputs.github_token }}\"}" > "$RNEF_PATH/project.json"
52+
53+
- name: E2E Prepare Script
54+
run: |
55+
pnpm --filter ${{ inputs.app_name }} e2e:prepare:android
56+
# Serve mini apps in the background
57+
pnpm --filter ${{ inputs.app_name }} e2e:serve:android &
58+
shell: bash
59+
60+
- uses: callstackincubator/android@v1
61+
with:
62+
github-token: ${{ inputs.github_token }}
63+
variant: 'Release'
64+
working-directory: './apps/${{ inputs.app_name}}'
65+
66+
- name: Run Android E2E Tests
67+
uses: reactivecircus/android-emulator-runner@v2
68+
with:
69+
api-level: ${{ env.ANDROID_EMULATOR_API_LEVEL }}
70+
target: ${{ env.ANDROID_EMULATOR_TARGET }}
71+
arch: ${{ env.ANDROID_EMULATOR_ARCH }}
72+
disk-size: ${{ env.ANDROID_EMULATOR_DISK_SPACE }}
73+
emulator-boot-timeout: ${{ env.ANDROID_EMULATOR_BOOT_TIMEOUT }}
74+
force-avd-creation: false
75+
disable-animations: true
76+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
77+
script: |
78+
pnpm --filter ${{ inputs.app_name }} android:release
79+
pnpm --filter ${{ inputs.app_name }} adbreverse
80+
pnpm --filter ${{ inputs.app_name }} e2e:run:android
81+
82+
- name: Upload Maestro Logs on Failure
83+
if: failure() # Runs only if any of the previous steps fail
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: maestro-logs-android-${{ inputs.app_name }}
87+
path: ~/.maestro/tests/
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: iOS E2E Tests
2+
description: 'Runs iOS E2E tests'
3+
4+
inputs:
5+
app_name:
6+
description: 'Name of the app to test'
7+
required: true
8+
github_token:
9+
description: 'GitHub token for authentication'
10+
required: true
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
clean: true
20+
21+
- name: Setup Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ env.RUBY_VERSION }}
25+
26+
- uses: pnpm/action-setup@v3
27+
28+
- name: Set up Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 22
32+
cache: 'pnpm'
33+
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
shell: bash
37+
38+
- name: Install Maestro CLI and iOS Utilities
39+
run: |
40+
curl -Ls "https://get.maestro.mobile.dev" | bash
41+
brew tap facebook/fb
42+
brew install facebook/fb/idb-companion
43+
echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
44+
shell: bash
45+
46+
- name: Local RNEF Setup
47+
shell: bash
48+
run: |
49+
RNEF_PATH="apps/${{ inputs.app_name }}/.rnef/cache"
50+
mkdir -p $RNEF_PATH
51+
echo "{\"githubToken\": \"${{ inputs.github_token }}\"}" > "$RNEF_PATH/project.json"
52+
53+
- uses: callstackincubator/ios@v1
54+
with:
55+
github-token: ${{ inputs.github_token }}
56+
destination: 'simulator'
57+
scheme: 'MFExampleHost'
58+
configuration: 'Release'
59+
working-directory: './apps/${{ inputs.app_name}}'
60+
61+
- name: E2E Prepare Script
62+
shell: bash
63+
run: |
64+
pnpm --filter ${{ inputs.app_name }} e2e:prepare:ios
65+
# Serve mini apps in the background
66+
pnpm --filter ${{ inputs.app_name }} e2e:serve:ios &
67+
68+
- name: Run iOS E2E Tests
69+
run: |
70+
pnpm --filter ${{ inputs.app_name }} ios:release
71+
pnpm --filter ${{ inputs.app_name }} e2e:run:ios
72+
shell: bash
73+
74+
- name: Upload Maestro Logs on Failure
75+
if: failure() # Runs only if any of the previous steps fail
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: maestro-logs-ios-${{ inputs.app_name }}
79+
path: ~/.maestro/tests/

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ jobs:
141141
uses: ./.github/workflows/e2e-router.yml
142142
secrets: inherit
143143

144+
e2e-metro:
145+
needs: checkout-install
146+
uses: ./.github/workflows/e2e-metro.yml
147+
secrets: inherit
148+
144149
build-metro:
145150
needs: checkout-install
146151
uses: ./.github/workflows/build-metro.yml

.github/workflows/e2e-metro.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Trigger E2E Tests
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
actions: read
8+
contents: read
9+
checks: write
10+
pull-requests: write
11+
id-token: write
12+
13+
concurrency:
14+
group: e2e-tests-${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
e2e-matrix-android:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
strategy:
22+
matrix:
23+
app_name: [example-host]
24+
env:
25+
ANDROID_EMULATOR_API_LEVEL: 28
26+
ANDROID_EMULATOR_TARGET: default
27+
ANDROID_EMULATOR_ARCH: x86_64
28+
ANDROID_EMULATOR_DISK_SPACE: 1024M
29+
ANDROID_EMULATOR_RAM_SIZE: 256M
30+
ANDROID_EMULATOR_HEAP_SIZE: 256M
31+
ANDROID_EMULATOR_BOOT_TIMEOUT: 2700
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Android E2E Tests
37+
uses: ./.github/actions/android-e2e
38+
with:
39+
app_name: ${{ matrix.app_name }}
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
e2e-matrix-ios:
42+
runs-on: macos-latest
43+
timeout-minutes: 60
44+
strategy:
45+
matrix:
46+
app_name: [example-host]
47+
env:
48+
RUBY_VERSION: 2.7.6
49+
MAESTRO_VERSION: 1.39.13
50+
MAESTRO_DRIVER_STARTUP_TIMEOUT: 360000
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: iOS E2E Tests
56+
uses: ./.github/actions/ios-e2e
57+
with:
58+
app_name: ${{ matrix.app_name }}
59+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)