1- name : E2E Tests
1+ name : E2E Tests (RN Fabric Optimized)
22
33on :
44 push :
55 branches : [ master, dev, feat-rn-e2e-detox ]
66 pull_request :
77 branches : [ master, dev, feat-rn-e2e-detox ]
8- workflow_dispatch : # 允许手动触发
8+ workflow_dispatch :
9+
10+ env :
11+ RCT_NEW_ARCH_ENABLED : " 1" # 强制启用新架构(Fabric)
12+ NODE_OPTIONS : " --max_old_space_size=4096"
913
1014jobs :
1115 e2e-ios :
12- name : E2E Tests (iOS)
13- runs-on : macos-14 # 使用最新的 macOS runner
16+ name : E2E Tests (iOS - Fabric )
17+ runs-on : macos-13 # 使用 Xcode 15.2 (最高稳定)
1418 timeout-minutes : 60
15-
19+
1620 steps :
17- - name : Checkout code
18- uses : actions/checkout@v4
19-
21+ - uses : actions/checkout@v4
22+
23+ # Cache node_modules
24+ - uses : actions/cache@v4
25+ id : node-cache
26+ with :
27+ path : |
28+ **/node_modules
29+ key : npm-${{ hashFiles('**/package-lock.json') }}
30+ restore-keys : npm-
31+
2032 - name : Setup Node.js
2133 uses : actions/setup-node@v4
2234 with :
2335 node-version : ' 20'
24-
25- - name : Install dependencies
36+
37+ - name : Install JS dependencies
2638 run : |
2739 npm install
2840 cd test/e2e/miniprogram-cli-project
2941 npm install
30-
31- - name : Setup React Native dependencies
32- run : |
33- cd test/e2e/miniprogram-cli-project/ReactNativeProject
42+ cd ReactNativeProject
3443 npm install
35-
44+
45+ # Ccache for C++ Fabric/Folly boost —— 提升构建速度关键步骤
46+ - name : Install ccache
47+ run : brew install ccache
48+
49+ - name : Setup ccache path
50+ run : echo 'export PATH="/usr/local/opt/ccache/libexec:$PATH"' >> $GITHUB_ENV
51+
52+ - uses : actions/cache@v4
53+ id : ccache-cache
54+ with :
55+ path : ~/.ccache
56+ key : ccache-ios-${{ hashFiles('**/*.{cpp,h,m,mm,cc}') }}
57+ restore-keys : ccache-ios-
58+
59+ # CocoaPods cache
60+ - uses : actions/cache@v4
61+ id : pods-cache
62+ with :
63+ path : test/e2e/miniprogram-cli-project/ReactNativeProject/ios/Pods
64+ key : pods-${{ hashFiles('**/Podfile.lock') }}
65+ restore-keys : pods-
66+
3667 - name : Install CocoaPods dependencies
3768 run : |
3869 cd test/e2e/miniprogram-cli-project/ReactNativeProject/ios
39- pod install --repo-update
40-
70+ pod install
71+
4172 - name : Install Detox CLI
4273 run : npm install -g detox-cli
4374
75+ # Build bundle
4476 - name : Build Mpx bundle for iOS
4577 run : |
4678 cd test/e2e/miniprogram-cli-project
4779 npm run build:ios
48-
49- - name : Build iOS app for Detox
80+
81+ # Build iOS app with Detox
82+ - name : Build iOS app (Fabric)
5083 run : |
5184 cd test/e2e/miniprogram-cli-project/ReactNativeProject
52- npm run e2e:build:ios
53-
85+ npm run e2e:build:ios:release -- --maxWorkers 2
86+
5487 - name : Run iOS E2E tests
5588 run : |
5689 cd test/e2e/miniprogram-cli-project/ReactNativeProject
57- # 启动 Metro Bundler 在后台
5890 npm start &
5991 METRO_PID=$!
60-
61- # 等待 Metro 启动
62- echo "Waiting for Metro Bundler to start..."
92+
93+ echo "Waiting for Metro..."
6394 npx wait-on tcp:8081 --timeout 60000
64-
65- # 运行测试
66- npm run e2e:test:ios -- --loglevel trace
67-
68- # 保存退出码
95+
96+ npm run e2e:test:ios -- --loglevel warn
6997 TEST_EXIT_CODE=$?
70-
71- # 停止 Metro
98+
7299 kill $METRO_PID || true
73-
74- # 返回测试退出码
100+
75101 exit $TEST_EXIT_CODE
76-
77- - name : Upload test artifacts (on failure)
102+
103+ - name : Upload iOS artifacts (failure only )
78104 if : failure()
79105 uses : actions/upload-artifact@v4
80106 with :
81107 name : e2e-ios-artifacts
82108 path : test/e2e/miniprogram-cli-project/ReactNativeProject/artifacts/
83109 retention-days : 7
84110
111+
112+ # Android E2E
85113 e2e-android :
86- name : E2E Tests (Android)
87- runs-on : macos-14 # macOS 提供更好的 Android 模拟器性能
114+ name : E2E Tests (Android - Fabric )
115+ runs-on : macos-13
88116 timeout-minutes : 60
89-
117+
90118 steps :
91- - name : Checkout code
92- uses : actions/checkout@v4
93-
119+ - uses : actions/checkout@v4
120+
121+ - uses : actions/cache@v4
122+ id : node-cache
123+ with :
124+ path : |
125+ **/node_modules
126+ key : npm-${{ hashFiles('**/package-lock.json') }}
127+ restore-keys : npm-
128+
94129 - name : Setup Node.js
95130 uses : actions/setup-node@v4
96131 with :
97132 node-version : ' 20'
98-
133+
99134 - name : Setup Java
100135 uses : actions/setup-java@v4
101136 with :
102137 distribution : ' corretto'
103138 java-version : ' 17'
104139 cache : ' gradle'
105-
106- - name : Install dependencies
140+
141+ - name : Install JS deps
107142 run : |
108143 npm install
109144 cd test/e2e/miniprogram-cli-project
110145 npm install
111-
112- - name : Setup React Native dependencies
113- run : |
114- cd test/e2e/miniprogram-cli-project/ReactNativeProject
146+ cd ReactNativeProject
115147 npm install
116-
117- - name : Install Detox CLI
148+
149+ - name : Detox CLI
118150 run : npm install -g detox-cli
119-
151+
120152 - name : Setup Android SDK
121153 uses : android-actions/setup-android@v3
122-
154+
123155 - name : AVD cache
124156 uses : actions/cache@v4
125157 id : avd-cache
@@ -128,75 +160,42 @@ jobs:
128160 ~/.android/avd/*
129161 ~/.android/adb*
130162 key : avd-34
131-
132- - name : Create AVD and generate snapshot for caching
163+
164+ - name : Generate AVD if no cache
133165 if : steps.avd-cache.outputs.cache-hit != 'true'
134166 uses : reactivecircus/android-emulator-runner@v2
135167 with :
136168 api-level : 34
137- arch : x86_64
169+ arch : arm64-v8a
138170 target : google_apis
139- force-avd-creation : false
140- emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
171+ force-avd-creation : true
172+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio
141173 disable-animations : true
142- script : echo "Generated AVD snapshot for caching."
143-
144- - name : Gradle cache
145- uses : actions/cache@v4
146- with :
147- path : |
148- ~/.gradle/caches
149- ~/.gradle/wrapper
150- key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
151- restore-keys : |
152- ${{ runner.os }}-gradle-
153-
174+ script : echo "AVD snapshot created"
175+
154176 - name : Build Mpx bundle for Android
155177 run : |
156178 cd test/e2e/miniprogram-cli-project
157179 npm run build:android
158180
159- - name : Build Android app for Detox
181+ - name : Build Android app (Fabric)
160182 run : |
161183 cd test/e2e/miniprogram-cli-project/ReactNativeProject
162- npm run e2e:build:android
163-
164- - name : Run Android E2E tests
184+ npm run e2e:build:android:release -- --max-workers=2
185+
186+ - name : Run Android E2E
165187 uses : reactivecircus/android-emulator-runner@v2
166188 with :
167189 api-level : 34
168- arch : x86_64
190+ arch : arm64-v8a
169191 target : google_apis
170- emulator-options : -no-snapshot-save -no- window -gpu swiftshader_indirect -noaudio - no-boot-anim -camera-back none
192+ emulator-options : -no-window -gpu swiftshader_indirect -no-snapshot-save
171193 disable-animations : true
172194 script : |
173195 cd test/e2e/miniprogram-cli-project/ReactNativeProject
174-
175- # 启动 Metro Bundler 在后台
176- npm start &
177- METRO_PID=$!
178-
179- # 等待 Metro 启动
180- echo "Waiting for Metro Bundler to start..."
181- npx wait-on tcp:8081 --timeout 120000
182-
183- # 配置 adb 端口转发
184- adb reverse tcp:8081 tcp:8081
185- adb reverse tcp:8097 tcp:8097
186-
187- # 运行测试
188- npm run e2e:test:android -- --loglevel trace
189-
190- # 保存退出码
191- TEST_EXIT_CODE=$?
192-
193- # 停止 Metro
194- kill $METRO_PID || true
195-
196- # 返回测试退出码
197- exit $TEST_EXIT_CODE
198-
199- - name : Upload test artifacts (on failure)
196+ npm run e2e:test:android:release -- --loglevel warn
197+
198+ - name : Upload Android artifacts (failure only)
200199 if : failure()
201200 uses : actions/upload-artifact@v4
202201 with :
0 commit comments