Repository navigation
206 lines (185 loc) · 9.44 KB
/
Copy pathe2e_android.yml
File metadata and controls
206 lines (185 loc) · 9.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: e2e-android
on:
pull_request:
branches:
- '**'
paths: &e2e-android-paths
- '.github/workflows/e2e_android.yml'
- '.github/actions/e2e-android-setup/**'
- '.github/actions/e2e-common/**'
- '.gitmodules'
# codegenConfig is copied into the linked package and drives codegen
- 'package.json'
- 'react-native-update.podspec'
- 'react-native.config.js'
- 'expo-module.config.json'
- 'src/**'
- 'android/**'
- 'cpp/**'
- 'Example/e2etest/**'
push:
branches:
- master
paths: *e2e-android-paths
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Read by .detoxrc.js (detox build/test only): the ABI to build and the AVD
# the emulator steps below create.
env:
DETOX_ANDROID_ARCHS: x86_64
DETOX_AVD_NAME: api34
jobs:
e2e-android:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout react-native-update
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Set up e2e environment
uses: ./.github/actions/e2e-android-setup
- name: Detox build (android.emu.release)
run: cd Example/e2etest && E2E_PLATFORM=android bunx detox build --configuration android.emu.release
- name: Prepare local update artifacts
env:
E2E_PLATFORM: android
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
run: cd Example/e2etest && bun run prepare:e2e
- name: Detox test (android.emu.release)
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
env:
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
RNU_E2E_SKIP_PREPARE: 'true'
# 每条命令自带 cd:android-emulator-runner 逐行起独立 shell,
# 单独一行的 cd 不会保持到下一条(实测 detox 会在仓库根找不到 jest)
EMULATOR_SCRIPT: |
cd Example/e2etest && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1
# 原生冷启动检测有自己的 runner 配置(见 e2e/native/jest.config.js);
# Android 这个 job 有预算,不必像 iOS 那样拆成独立 job
cd Example/e2etest && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1 --config e2e/native/jest.config.js
# Shared by every emulator step in this workflow; each step supplies
# its own commands through the EMULATOR_SCRIPT env var.
with: &emulator
api-level: 34
target: google_apis
arch: x86_64
avd-name: api34
# Pinned while stabilizing e2e. The 2026-07-30 breakage was NOT the
# emulator version (red herring): bundle-hash.test.ts landed 07-29 as
# a second suite, and a second Detox worker tried to boot the same
# AVD twice, which Android cannot do, retrying until the job timed
# out. .detoxrc.js now pins the Android configurations to one
# worker. Unpin once a run proves 37.x stable.
emulator-build: 15507667
emulator-boot-timeout: 900
script: ${{ env.EMULATOR_SCRIPT }}
- name: Upload Detox artifacts
# cancelled() 覆盖 job 超时被杀的场景,否则超时时拿不到现场
if: failure() || cancelled()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: e2e-android-detox-artifacts
path: Example/e2etest/artifacts
if-no-files-found: ignore
retention-days: 7
# Debug 构建启动冒烟:codegen 生成的 Java spec 把常量校验等检查包在
# ReactBuildConfig.DEBUG 内,上面的 release e2e 物理上跑不到这些代码路径
# (v10.48.2 的 "doesn't declare constants" 启动崩溃就是这样漏掉的)。
# 只验证 debug 包能启动进首屏,不跑更新流,所以不需要更新 server 和产物。
e2e-android-debug-smoke:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout react-native-update
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Set up e2e environment
uses: ./.github/actions/e2e-android-setup
with:
checkout-cli: 'false'
- name: Detox build (android.emu.debug)
run: cd Example/e2etest && bunx detox build --configuration android.emu.debug
- name: Start Metro in background
run: |
cd Example/e2etest
mkdir -p .e2e-artifacts
nohup bun start > .e2e-artifacts/metro.log 2>&1 &
# 预热 dev bundle:趁模拟器启动的窗口把首个 bundle 编出来,
# 避免 app 首次加载时现编,把冒烟等待时间全吃掉
nohup bash -c 'for i in $(seq 1 90); do curl -sf http://localhost:8081/status >/dev/null && break; sleep 2; done; curl -sf --max-time 420 -o /dev/null "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false"' > .e2e-artifacts/metro-prewarm.log 2>&1 &
- name: Detox test (android.emu.debug boot smoke)
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
env:
# 注意:emulator-runner 把 script 的每一行单独用 sh -c 执行,
# cd 不会跨行生效,所以每行必须自包含。
EMULATOR_SCRIPT: |
for i in $(seq 1 90); do curl -sf http://localhost:8081/status >/dev/null && break; sleep 2; done
curl -sf --max-time 420 -o /dev/null "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false" || { echo '::error::Metro dev bundle failed to build'; tail -n 100 Example/e2etest/.e2e-artifacts/metro.log; exit 1; }
cd Example/e2etest && bunx detox test --configuration android.emu.debug --config e2e/smoke/jest.config.js --no-start --headless --record-logs all --retries 1
with: *emulator
- name: Upload Detox artifacts
# cancelled() 覆盖 job 超时被杀的场景,否则超时时拿不到现场
if: failure() || cancelled()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: e2e-android-debug-smoke-detox-artifacts
path: |
Example/e2etest/artifacts
Example/e2etest/.e2e-artifacts/metro.log
Example/e2etest/.e2e-artifacts/metro-prewarm.log
if-no-files-found: ignore
retention-days: 7
e2e-android-rn077-oldarch:
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- name: Checkout react-native-update
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Set up e2e environment
uses: ./.github/actions/e2e-android-setup
with:
project-dir: .e2e-rn077-oldarch/AwesomeProject
bun-cache-scope: -rn077-oldarch
bun-cache-key-suffix: -${{ hashFiles('Example/e2etest/scripts/create-rn077-oldarch-project.js') }}
# The project is generated by the script below (RN/template/Detox
# versions live there) after the cache is restored, so key the
# Gradle cache on its inputs rather than on files that do not exist
# yet; the library module's own build.gradle participates too.
gradle-cache-dependency-path: |
Example/e2etest/scripts/create-rn077-oldarch-project.js
android/build.gradle
create-project: node Example/e2etest/scripts/create-rn077-oldarch-project.js
# `react-native init --skip-install` writes no lockfile, so there is
# nothing to freeze against.
frozen-lockfile: 'false'
- name: Detox build (RN 0.77.3 old arch android.emu.release)
run: cd .e2e-rn077-oldarch/AwesomeProject && E2E_PLATFORM=android bunx detox build --configuration android.emu.release
- name: Prepare local update artifacts
env:
E2E_PLATFORM: android
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
run: cd .e2e-rn077-oldarch/AwesomeProject && bun run prepare:e2e
- name: Detox test (RN 0.77.3 old arch android.emu.release)
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
env:
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
RNU_E2E_SKIP_PREPARE: 'true'
# 每条命令自带 cd,理由同上
EMULATOR_SCRIPT: |
cd .e2e-rn077-oldarch/AwesomeProject && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1
cd .e2e-rn077-oldarch/AwesomeProject && E2E_PLATFORM=android bunx detox test --configuration android.emu.release --headless --record-logs all --retries 1 --config e2e/native/jest.config.js
with: *emulator
- name: Upload Detox artifacts
# cancelled() 覆盖 job 超时被杀的场景,否则超时时拿不到现场
if: failure() || cancelled()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: e2e-android-rn077-oldarch-detox-artifacts
path: .e2e-rn077-oldarch/AwesomeProject/artifacts
if-no-files-found: ignore
retention-days: 7