@@ -3,10 +3,6 @@ name: E2E Tests
33on :
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
1612 - all
1713 - android
1814 - ios
15+ pull_request :
16+ types : [ready_for_review]
17+ branches :
18+ - main
1919
20- 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"
20+ permissions :
21+ contents : read
22+ pull-requests : read
4123
24+ jobs :
4225 e2e-android :
43- name : E2E Android - ${{ matrix.app }}
26+ name : E2E Android
4427 runs-on : ubuntu-22.04
45- needs : discover-apps
46- if : ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android' }}
28+ if : ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || (github.event_name == 'workflow_dispatch' && (github.event.inputs.platform == 'all' || github.event.inputs.platform == 'android')) }}
4729 env :
4830 HARNESS_DEBUG : true
49- strategy :
50- fail-fast : false
51- matrix :
52- app : ${{ fromJson(needs.discover-apps.outputs.apps) }}
5331
5432 steps :
5533 - name : Checkout code
5634 uses : actions/checkout@v4
35+ with :
36+ ref : ${{ github.event.pull_request.head.sha || github.ref }}
37+ fetch-depth : 0
38+
39+ - name : Reclaim disk space
40+ uses : AdityaGarg8/remove-unwanted-software@v5
41+ with :
42+ remove-dotnet : true
43+ remove-haskell : true
44+ remove-codeql : true
45+ remove-docker-images : true
5746
5847 - name : Install pnpm
5948 uses : pnpm/action-setup@v2
6958 - name : Metro cache
7059 uses : actions/cache@v4
7160 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/**/*') }}
61+ path : apps/playground /node_modules/.cache/rn-harness/metro-cache
62+ key : metro-cache-${{ hashFiles('apps/playground /node_modules/.cache/rn-harness/metro-cache/**/*') }}
7463 restore-keys : |
7564 metro-cache
7665
@@ -92,41 +81,39 @@ jobs:
9281 id : cache-apk-restore
9382 uses : actions/cache/restore@v4
9483 with :
95- path : apps/${{ matrix.app }} /android/app/build/outputs/apk/debug/app-debug.apk
96- key : apk-${{ matrix.app }}
84+ path : apps/playground /android/app/build/outputs/apk/debug/app-debug.apk
85+ key : apk-playground
9786
9887 - name : Build Android app
9988 if : steps.cache-apk-restore.outputs.cache-hit != 'true'
100- working-directory : apps/${{ matrix.app }}
89+ working-directory : apps/playground
10190 run : |
102- pnpm nx run @react-native-harness/${{ matrix.app }} :build-android --tasks=assembleDebug
91+ pnpm nx run @react-native-harness/playground :build-android --tasks=assembleDebug
10392
10493 - name : Save APK to cache
10594 if : steps.cache-apk-restore.outputs.cache-hit != 'true' && success()
10695 uses : actions/cache/save@v4
10796 with :
108- path : apps/${{ matrix.app }} /android/app/build/outputs/apk/debug/app-debug.apk
109- key : apk-${{ matrix.app }}
97+ path : apps/playground /android/app/build/outputs/apk/debug/app-debug.apk
98+ key : apk-playground
11099
111100 - name : Run React Native Harness
112101 uses : ./actions/android
113102 with :
114103 app : android/app/build/outputs/apk/debug/app-debug.apk
115104 runner : android
116- projectRoot : apps/${{ matrix.app }}
105+ projectRoot : apps/playground
117106
118107 e2e-ios :
119- name : E2E iOS - ${{ matrix.app }}
108+ name : E2E iOS
120109 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) }}
110+ if : ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || (github.event_name == 'workflow_dispatch' && (github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios')) }}
127111 steps :
128112 - name : Checkout code
129113 uses : actions/checkout@v4
114+ with :
115+ ref : ${{ github.event.pull_request.head.sha || github.ref }}
116+ fetch-depth : 0
130117
131118 - name : Install pnpm
132119 uses : pnpm/action-setup@v2
@@ -142,8 +129,8 @@ jobs:
142129 - name : Metro cache
143130 uses : actions/cache@v4
144131 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/**/*') }}
132+ path : apps/playground /node_modules/.cache/rn-harness/metro-cache
133+ key : metro-cache-${{ hashFiles('apps/playground /node_modules/.cache/rn-harness/metro-cache/**/*') }}
147134 restore-keys : |
148135 metro-cache
149136
@@ -162,57 +149,43 @@ jobs:
162149 id : cache-app-restore
163150 uses : actions/cache/restore@v4
164151 with :
165- path : ./apps/${{ matrix.app }} /ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
166- key : ios-app-${{ matrix.app }}
152+ path : ./apps/playground /ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
153+ key : ios-app-playground
167154
168155 - name : CocoaPods cache
169156 if : steps.cache-app-restore.outputs.cache-hit != 'true'
170157 uses : actions/cache@v4
171158 with :
172159 path : |
173- ./apps/${{ matrix.app }} /ios/Pods
160+ ./apps/playground /ios/Pods
174161 ~/Library/Caches/CocoaPods
175162 ~/.cocoapods
176- key : ${{ matrix.app }} -${{ runner.os }}-pods-${{ hashFiles('./apps/${{ matrix.app }} /ios/Podfile.lock') }}
163+ key : playground -${{ runner.os }}-pods-${{ hashFiles('./apps/playground /ios/Podfile.lock') }}
177164 restore-keys : |
178- ${{ matrix.app }} -${{ runner.os }}-pods-
165+ playground -${{ runner.os }}-pods-
179166
180167 - name : Install CocoaPods
181168 if : steps.cache-app-restore.outputs.cache-hit != 'true'
182- working-directory : apps/${{ matrix.app }} /ios
169+ working-directory : apps/playground /ios
183170 run : |
184171 pod install
185172
186173 - name : Build iOS app
187174 if : steps.cache-app-restore.outputs.cache-hit != 'true'
188- working-directory : apps/${{ matrix.app }}
175+ working-directory : apps/playground
189176 run : |
190177 pnpm react-native build-ios --buildFolder ./build --verbose
191178
192179 - name : Save app to cache
193180 if : steps.cache-app-restore.outputs.cache-hit != 'true' && success()
194181 uses : actions/cache/save@v4
195182 with :
196- path : ./apps/${{ matrix.app }} /ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
197- key : ios-app-${{ matrix.app }}
183+ path : ./apps/playground /ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
184+ key : ios-app-playground
198185
199186 - name : Run React Native Harness
200187 uses : ./actions/ios
201188 with :
202189 app : ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
203190 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
191+ projectRoot : apps/playground
0 commit comments