Skip to content

Commit 36a8715

Browse files
committed
test
1 parent a3a2e06 commit 36a8715

4 files changed

Lines changed: 143 additions & 30 deletions

File tree

.github/workflows/e2e_android.yml

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,119 @@ jobs:
160160
arch: x86_64
161161
avd-name: api34
162162
emulator-boot-timeout: 900
163-
script: cd Example/e2etest && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all
163+
script: cd Example/e2etest && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1
164+
165+
- name: Upload Detox artifacts
166+
if: failure()
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: e2e-android-detox-artifacts
170+
path: Example/e2etest/artifacts
171+
if-no-files-found: ignore
172+
retention-days: 7
173+
174+
e2e-android-arm:
175+
runs-on: ubuntu-24.04-arm
176+
timeout-minutes: 30
177+
continue-on-error: true
178+
steps:
179+
- name: Checkout react-native-update
180+
uses: actions/checkout@v6
181+
with:
182+
submodules: recursive
183+
184+
- name: Checkout react-native-update-cli
185+
uses: actions/checkout@v6
186+
with:
187+
repository: reactnativecn/react-native-update-cli
188+
path: react-native-update-cli
189+
190+
- name: Setup Node.js
191+
uses: actions/setup-node@v6
192+
with:
193+
node-version: 22
194+
195+
- name: Setup Bun
196+
uses: oven-sh/setup-bun@v2
197+
with:
198+
bun-version: latest
199+
200+
- name: Cache Bun dependencies
201+
uses: actions/cache@v4
202+
with:
203+
path: ~/.bun/install/cache
204+
key: ${{ runner.os }}-${{ runner.arch }}-bun-e2e-${{ hashFiles('Example/e2etest/bun.lock', 'react-native-update-cli/bun.lock') }}
205+
restore-keys: |
206+
${{ runner.os }}-${{ runner.arch }}-bun-e2e-
207+
208+
- name: Setup Java
209+
uses: actions/setup-java@v5
210+
with:
211+
distribution: temurin
212+
java-version: '17'
213+
cache: gradle
214+
cache-dependency-path: |
215+
Example/e2etest/bun.lock
216+
Example/e2etest/android/*.gradle
217+
Example/e2etest/android/**/*.gradle
218+
Example/e2etest/android/gradle/wrapper/gradle-wrapper.properties
219+
220+
- name: Enable KVM
221+
run: |
222+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
223+
sudo udevadm control --reload-rules
224+
sudo udevadm trigger --name-match=kvm
225+
226+
- name: Install e2etest dependencies
227+
run: cd Example/e2etest && bun install --frozen-lockfile
228+
229+
- name: Link local react-native-update
230+
run: |
231+
set -euo pipefail
232+
export LOCAL_RNU_VERSION="$(node -p "require('./Example/e2etest/node_modules/react-native-update/package.json').version")"
233+
LOCAL_RNU_DIR="$PWD/Example/e2etest/.e2e-artifacts/local-react-native-update"
234+
rm -rf "$LOCAL_RNU_DIR" Example/e2etest/node_modules/react-native-update
235+
mkdir -p "$LOCAL_RNU_DIR"
236+
cp package.json react-native-update.podspec react-native.config.js expo-module.config.json "$LOCAL_RNU_DIR"/
237+
rsync -a --exclude='.git' src ios android cpp scripts "$LOCAL_RNU_DIR"/
238+
node -e "const fs = require('fs'); const file = 'Example/e2etest/.e2e-artifacts/local-react-native-update/package.json'; const pkg = JSON.parse(fs.readFileSync(file, 'utf8')); pkg.version = process.env.LOCAL_RNU_VERSION; fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n');"
239+
ln -s ../.e2e-artifacts/local-react-native-update Example/e2etest/node_modules/react-native-update
240+
241+
- name: Install react-native-update-cli dependencies
242+
run: cd react-native-update-cli && bun install --frozen-lockfile && bun run build
243+
244+
- name: Detox build (android.emu.release arm64)
245+
env:
246+
DETOX_ANDROID_ARCHS: arm64-v8a
247+
DETOX_AVD_NAME: api34-arm64
248+
run: cd Example/e2etest && E2E_PLATFORM=android bunx detox build --configuration android.emu.release
249+
250+
- name: Prepare local update artifacts
251+
env:
252+
E2E_PLATFORM: android
253+
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
254+
run: cd Example/e2etest && bun run prepare:e2e
255+
256+
- name: Detox test (android.emu.release arm64)
257+
uses: reactivecircus/android-emulator-runner@v2
258+
env:
259+
DETOX_ANDROID_ARCHS: arm64-v8a
260+
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
261+
RNU_E2E_SKIP_PREPARE: 'true'
262+
DETOX_AVD_NAME: api34-arm64
263+
with:
264+
api-level: 34
265+
target: google_apis
266+
arch: arm64-v8a
267+
avd-name: api34-arm64
268+
emulator-boot-timeout: 900
269+
script: cd Example/e2etest && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1
270+
271+
- name: Upload Detox artifacts
272+
if: failure()
273+
uses: actions/upload-artifact@v4
274+
with:
275+
name: e2e-android-arm-detox-artifacts
276+
path: Example/e2etest/artifacts
277+
if-no-files-found: ignore
278+
retention-days: 7

.github/workflows/e2e_ios.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,7 @@ on:
1717
- 'ios/**'
1818
- 'cpp/**'
1919
- 'android/jni/**'
20-
- 'Example/e2etest/package.json'
21-
- 'Example/e2etest/bun.lock'
22-
- 'Example/e2etest/app.json'
23-
- 'Example/e2etest/update.json'
24-
- 'Example/e2etest/.detoxrc.js'
25-
- 'Example/e2etest/.detoxrc.ts'
26-
- 'Example/e2etest/babel.config.js'
27-
- 'Example/e2etest/metro.config.js'
28-
- 'Example/e2etest/index.js'
29-
- 'Example/e2etest/tsconfig*.json'
30-
- 'Example/e2etest/src/**'
31-
- 'Example/e2etest/e2e/**'
32-
- 'Example/e2etest/scripts/**'
33-
- 'Example/e2etest/ios/**'
20+
- 'Example/e2etest/**'
3421
push:
3522
branches:
3623
- master
@@ -47,20 +34,7 @@ on:
4734
- 'ios/**'
4835
- 'cpp/**'
4936
- 'android/jni/**'
50-
- 'Example/e2etest/package.json'
51-
- 'Example/e2etest/bun.lock'
52-
- 'Example/e2etest/app.json'
53-
- 'Example/e2etest/update.json'
54-
- 'Example/e2etest/.detoxrc.js'
55-
- 'Example/e2etest/.detoxrc.ts'
56-
- 'Example/e2etest/babel.config.js'
57-
- 'Example/e2etest/metro.config.js'
58-
- 'Example/e2etest/index.js'
59-
- 'Example/e2etest/tsconfig*.json'
60-
- 'Example/e2etest/src/**'
61-
- 'Example/e2etest/e2e/**'
62-
- 'Example/e2etest/scripts/**'
63-
- 'Example/e2etest/ios/**'
37+
- 'Example/e2etest/**'
6438

6539
concurrency:
6640
group: ${{ github.workflow }}-${{ github.ref }}

Example/e2etest/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ bun install
2222
detox build --configuration android.emu.release
2323
E2E_PLATFORM=android detox test --configuration android.emu.release --headless --record-logs all
2424
```
25+
26+
架构需要跟 AVD 保持一致:Apple Silicon 本地的 `api34` AVD 和 ARM CI
27+
comparison job 用 `arm64-v8a`;GitHub `ubuntu-latest` x64 job 用
28+
`x86_64` emulator 和 `DETOX_ANDROID_ARCHS=x86_64`

Example/e2etest/scripts/prepare-local-update-artifacts.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,27 @@ function ensureHdiffModule() {
9393
const modulePath = path.join(cliRoot, 'node_modules/node-hdiffpatch');
9494
if (!fs.existsSync(modulePath)) {
9595
console.log('node-hdiffpatch not found, installing...');
96-
runPushy(['install', 'node-hdiffpatch'], cliRoot);
96+
const result = spawnSync(
97+
'npm',
98+
[
99+
'install',
100+
'--no-save',
101+
'--package-lock=false',
102+
'--legacy-peer-deps',
103+
'node-hdiffpatch',
104+
],
105+
{
106+
cwd: cliRoot,
107+
stdio: 'inherit',
108+
env: process.env,
109+
},
110+
);
111+
112+
if (result.status !== 0) {
113+
throw new Error(
114+
`npm install node-hdiffpatch failed with exit code ${result.status}`,
115+
);
116+
}
97117
}
98118
if (!fs.existsSync(modulePath)) {
99119
throw new Error(`Failed to install node-hdiffpatch under: ${cliRoot}`);

0 commit comments

Comments
 (0)