Skip to content

Commit fdf4893

Browse files
committed
build: run E2E tests for pull requests
1 parent 2f7c1ac commit fdf4893

File tree

1 file changed

+27
-74
lines changed

1 file changed

+27
-74
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 27 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: E2E Tests
33
on:
44
workflow_dispatch:
55
inputs:
6-
app:
7-
description: 'Specific app to test (leave empty for all apps)'
8-
required: false
9-
type: string
106
platform:
117
description: 'Platform to test'
128
required: false
@@ -16,40 +12,16 @@ on:
1612
- all
1713
- android
1814
- ios
15+
pull_request:
16+
types: [ready_for_review]
1917

2018
jobs:
21-
discover-apps:
22-
name: Discover Apps
23-
runs-on: ubuntu-22.04
24-
outputs:
25-
apps: ${{ steps.set-apps.outputs.apps }}
26-
steps:
27-
- name: Checkout code
28-
uses: actions/checkout@v4
29-
30-
- name: Discover apps
31-
id: set-apps
32-
run: |
33-
if [ -n "${{ github.event.inputs.app }}" ]; then
34-
apps='["${{ github.event.inputs.app }}"]'
35-
else
36-
# Dynamically discover apps in the /apps directory
37-
apps=$(find apps -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | jq -R . | jq -sc .)
38-
fi
39-
echo "apps=$apps" >> $GITHUB_OUTPUT
40-
echo "Discovered apps: $apps"
41-
4219
e2e-android:
43-
name: E2E Android - ${{ matrix.app }}
20+
name: E2E Android
4421
runs-on: ubuntu-22.04
45-
needs: discover-apps
46-
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
22+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
4723
env:
4824
HARNESS_DEBUG: true
49-
strategy:
50-
fail-fast: false
51-
matrix:
52-
app: ${{ fromJson(needs.discover-apps.outputs.apps) }}
5325

5426
steps:
5527
- name: Checkout code
@@ -69,8 +41,8 @@ jobs:
6941
- name: Metro cache
7042
uses: actions/cache@v4
7143
with:
72-
path: apps/${{ matrix.app }}/node_modules/.cache/rn-harness/metro-cache
73-
key: metro-cache-${{ hashFiles('apps/${{ matrix.app }}/node_modules/.cache/rn-harness/metro-cache/**/*') }}
44+
path: apps/playground/node_modules/.cache/rn-harness/metro-cache
45+
key: metro-cache-${{ hashFiles('apps/playground/node_modules/.cache/rn-harness/metro-cache/**/*') }}
7446
restore-keys: |
7547
metro-cache
7648
@@ -92,38 +64,33 @@ jobs:
9264
id: cache-apk-restore
9365
uses: actions/cache/restore@v4
9466
with:
95-
path: apps/${{ matrix.app }}/android/app/build/outputs/apk/debug/app-debug.apk
96-
key: apk-${{ matrix.app }}
67+
path: apps/playground/android/app/build/outputs/apk/debug/app-debug.apk
68+
key: apk-playground
9769

9870
- name: Build Android app
9971
if: steps.cache-apk-restore.outputs.cache-hit != 'true'
100-
working-directory: apps/${{ matrix.app }}
72+
working-directory: apps/playground
10173
run: |
102-
pnpm nx run @react-native-harness/${{ matrix.app }}:build-android --tasks=assembleDebug
74+
pnpm nx run @react-native-harness/playground:build-android --tasks=assembleDebug
10375
10476
- name: Save APK to cache
10577
if: steps.cache-apk-restore.outputs.cache-hit != 'true' && success()
10678
uses: actions/cache/save@v4
10779
with:
108-
path: apps/${{ matrix.app }}/android/app/build/outputs/apk/debug/app-debug.apk
109-
key: apk-${{ matrix.app }}
80+
path: apps/playground/android/app/build/outputs/apk/debug/app-debug.apk
81+
key: apk-playground
11082

11183
- name: Run React Native Harness
11284
uses: ./actions/android
11385
with:
11486
app: android/app/build/outputs/apk/debug/app-debug.apk
11587
runner: android
116-
projectRoot: apps/${{ matrix.app }}
88+
projectRoot: apps/playground
11789

11890
e2e-ios:
119-
name: E2E iOS - ${{ matrix.app }}
91+
name: E2E iOS
12092
runs-on: macos-latest
121-
needs: discover-apps
122-
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' }}
123-
strategy:
124-
fail-fast: false
125-
matrix:
126-
app: ${{ fromJson(needs.discover-apps.outputs.apps) }}
93+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' }}
12794
steps:
12895
- name: Checkout code
12996
uses: actions/checkout@v4
@@ -142,8 +109,8 @@ jobs:
142109
- name: Metro cache
143110
uses: actions/cache@v4
144111
with:
145-
path: apps/${{ matrix.app }}/node_modules/.cache/rn-harness/metro-cache
146-
key: metro-cache-${{ hashFiles('apps/${{ matrix.app }}/node_modules/.cache/rn-harness/metro-cache/**/*') }}
112+
path: apps/playground/node_modules/.cache/rn-harness/metro-cache
113+
key: metro-cache-${{ hashFiles('apps/playground/node_modules/.cache/rn-harness/metro-cache/**/*') }}
147114
restore-keys: |
148115
metro-cache
149116
@@ -162,57 +129,43 @@ jobs:
162129
id: cache-app-restore
163130
uses: actions/cache/restore@v4
164131
with:
165-
path: ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
166-
key: ios-app-${{ matrix.app }}
132+
path: ./apps/playground/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
133+
key: ios-app-playground
167134

168135
- name: CocoaPods cache
169136
if: steps.cache-app-restore.outputs.cache-hit != 'true'
170137
uses: actions/cache@v4
171138
with:
172139
path: |
173-
./apps/${{ matrix.app }}/ios/Pods
140+
./apps/playground/ios/Pods
174141
~/Library/Caches/CocoaPods
175142
~/.cocoapods
176-
key: ${{ matrix.app }}-${{ runner.os }}-pods-${{ hashFiles('./apps/${{ matrix.app }}/ios/Podfile.lock') }}
143+
key: playground-${{ runner.os }}-pods-${{ hashFiles('./apps/playground/ios/Podfile.lock') }}
177144
restore-keys: |
178-
${{ matrix.app }}-${{ runner.os }}-pods-
145+
playground-${{ runner.os }}-pods-
179146
180147
- name: Install CocoaPods
181148
if: steps.cache-app-restore.outputs.cache-hit != 'true'
182-
working-directory: apps/${{ matrix.app }}/ios
149+
working-directory: apps/playground/ios
183150
run: |
184151
pod install
185152
186153
- name: Build iOS app
187154
if: steps.cache-app-restore.outputs.cache-hit != 'true'
188-
working-directory: apps/${{ matrix.app }}
155+
working-directory: apps/playground
189156
run: |
190157
pnpm react-native build-ios --buildFolder ./build --verbose
191158
192159
- name: Save app to cache
193160
if: steps.cache-app-restore.outputs.cache-hit != 'true' && success()
194161
uses: actions/cache/save@v4
195162
with:
196-
path: ./apps/${{ matrix.app }}/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
197-
key: ios-app-${{ matrix.app }}
163+
path: ./apps/playground/ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
164+
key: ios-app-playground
198165

199166
- name: Run React Native Harness
200167
uses: ./actions/ios
201168
with:
202169
app: ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
203170
runner: ios
204-
projectRoot: apps/${{ matrix.app }}
205-
206-
- name: Take screenshot after E2E tests
207-
if: failure()
208-
run: |
209-
mkdir -p screenshots
210-
xcrun simctl io booted screenshot screenshots/ios-${{ matrix.app }}-after.png
211-
212-
- name: Upload iOS screenshots
213-
if: failure()
214-
uses: actions/upload-artifact@v4
215-
with:
216-
name: ios-screenshots-${{ matrix.app }}
217-
path: screenshots/ios-${{ matrix.app }}-*.png
218-
retention-days: 7
171+
projectRoot: apps/playground

0 commit comments

Comments
 (0)