Skip to content

Commit 229cf05

Browse files
committed
optimise e2e ci
1 parent 0a1fa1e commit 229cf05

4 files changed

Lines changed: 208 additions & 10 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI Failure Email
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- e2e-android
7+
- e2e-ios
8+
- lint
9+
- Publish Package to npmjs
10+
- test
11+
types: [completed]
12+
13+
jobs:
14+
notify:
15+
if: contains(fromJSON('["failure","timed_out","action_required"]'), github.event.workflow_run.conclusion)
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Send failure email
19+
uses: dawidd6/action-send-mail@v16
20+
with:
21+
connection_url: ${{ secrets.CI_FAILURE_MAIL_CONNECTION }}
22+
subject: "[CI failed] ${{ github.repository }} / ${{ github.event.workflow_run.name }}"
23+
to: sunnylqm@gmail.com
24+
from: "GitHub Actions <sunnylqm@gmail.com>"
25+
body: |
26+
Repository: ${{ github.repository }}
27+
Workflow: ${{ github.event.workflow_run.name }}
28+
Conclusion: ${{ github.event.workflow_run.conclusion }}
29+
Branch: ${{ github.event.workflow_run.head_branch }}
30+
Commit: ${{ github.event.workflow_run.head_sha }}
31+
Actor: ${{ github.event.workflow_run.actor.login }}
32+
Run: ${{ github.event.workflow_run.html_url }}

.github/workflows/e2e_android.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,62 @@ on:
44
pull_request:
55
branches:
66
- '**'
7+
paths:
8+
- '.github/workflows/e2e_android.yml'
9+
- '.gitmodules'
10+
- 'package.json'
11+
- 'bun.lock'
12+
- 'react-native-update.podspec'
13+
- 'react-native.config.js'
14+
- 'expo-module.config.json'
15+
- 'src/**'
16+
- 'scripts/**'
17+
- 'android/**'
18+
- 'cpp/**'
19+
- 'Example/e2etest/package.json'
20+
- 'Example/e2etest/bun.lock'
21+
- 'Example/e2etest/app.json'
22+
- 'Example/e2etest/update.json'
23+
- 'Example/e2etest/.detoxrc.js'
24+
- 'Example/e2etest/.detoxrc.ts'
25+
- 'Example/e2etest/babel.config.js'
26+
- 'Example/e2etest/metro.config.js'
27+
- 'Example/e2etest/index.js'
28+
- 'Example/e2etest/tsconfig*.json'
29+
- 'Example/e2etest/src/**'
30+
- 'Example/e2etest/e2e/**'
31+
- 'Example/e2etest/scripts/**'
32+
- 'Example/e2etest/android/**'
733
push:
834
branches:
935
- master
1036
- main
37+
paths:
38+
- '.github/workflows/e2e_android.yml'
39+
- '.gitmodules'
40+
- 'package.json'
41+
- 'bun.lock'
42+
- 'react-native-update.podspec'
43+
- 'react-native.config.js'
44+
- 'expo-module.config.json'
45+
- 'src/**'
46+
- 'scripts/**'
47+
- 'android/**'
48+
- 'cpp/**'
49+
- 'Example/e2etest/package.json'
50+
- 'Example/e2etest/bun.lock'
51+
- 'Example/e2etest/app.json'
52+
- 'Example/e2etest/update.json'
53+
- 'Example/e2etest/.detoxrc.js'
54+
- 'Example/e2etest/.detoxrc.ts'
55+
- 'Example/e2etest/babel.config.js'
56+
- 'Example/e2etest/metro.config.js'
57+
- 'Example/e2etest/index.js'
58+
- 'Example/e2etest/tsconfig*.json'
59+
- 'Example/e2etest/src/**'
60+
- 'Example/e2etest/e2e/**'
61+
- 'Example/e2etest/scripts/**'
62+
- 'Example/e2etest/android/**'
1163

1264
concurrency:
1365
group: ${{ github.workflow }}-${{ github.ref }}
@@ -39,11 +91,25 @@ jobs:
3991
with:
4092
bun-version: latest
4193

94+
- name: Cache Bun dependencies
95+
uses: actions/cache@v4
96+
with:
97+
path: ~/.bun/install/cache
98+
key: ${{ runner.os }}-bun-e2e-${{ hashFiles('Example/e2etest/bun.lock', 'react-native-update-cli/bun.lock') }}
99+
restore-keys: |
100+
${{ runner.os }}-bun-e2e-
101+
42102
- name: Setup Java
43103
uses: actions/setup-java@v5
44104
with:
45105
distribution: temurin
46106
java-version: '17'
107+
cache: gradle
108+
cache-dependency-path: |
109+
Example/e2etest/bun.lock
110+
Example/e2etest/android/*.gradle
111+
Example/e2etest/android/**/*.gradle
112+
Example/e2etest/android/gradle/wrapper/gradle-wrapper.properties
47113
48114
- name: Enable KVM
49115
run: |
@@ -75,11 +141,18 @@ jobs:
75141
DETOX_AVD_NAME: api34
76142
run: cd Example/e2etest && E2E_PLATFORM=android bunx detox build --configuration android.emu.release
77143

144+
- name: Prepare local update artifacts
145+
env:
146+
E2E_PLATFORM: android
147+
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
148+
run: cd Example/e2etest && bun run prepare:e2e
149+
78150
- name: Detox test (android.emu.release)
79151
uses: reactivecircus/android-emulator-runner@v2
80152
env:
81153
DETOX_ANDROID_ARCHS: x86_64
82154
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
155+
RNU_E2E_SKIP_PREPARE: 'true'
83156
DETOX_AVD_NAME: api34
84157
with:
85158
api-level: 34

.github/workflows/e2e_ios.yml

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,63 @@ on:
44
pull_request:
55
branches:
66
- '**'
7+
paths:
8+
- '.github/workflows/e2e_ios.yml'
9+
- '.gitmodules'
10+
- 'package.json'
11+
- 'bun.lock'
12+
- 'react-native-update.podspec'
13+
- 'react-native.config.js'
14+
- 'expo-module.config.json'
15+
- 'src/**'
16+
- 'scripts/**'
17+
- 'ios/**'
18+
- 'cpp/**'
19+
- '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/**'
734
push:
835
branches:
936
- master
37+
paths:
38+
- '.github/workflows/e2e_ios.yml'
39+
- '.gitmodules'
40+
- 'package.json'
41+
- 'bun.lock'
42+
- 'react-native-update.podspec'
43+
- 'react-native.config.js'
44+
- 'expo-module.config.json'
45+
- 'src/**'
46+
- 'scripts/**'
47+
- 'ios/**'
48+
- 'cpp/**'
49+
- '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/**'
1064

1165
concurrency:
1266
group: ${{ github.workflow }}-${{ github.ref }}
@@ -38,11 +92,13 @@ jobs:
3892
with:
3993
bun-version: latest
4094

41-
- name: Setup Java
42-
uses: actions/setup-java@v5
95+
- name: Cache Bun dependencies
96+
uses: actions/cache@v4
4397
with:
44-
distribution: temurin
45-
java-version: '17'
98+
path: ~/.bun/install/cache
99+
key: ${{ runner.os }}-bun-e2e-${{ hashFiles('Example/e2etest/bun.lock', 'react-native-update-cli/bun.lock') }}
100+
restore-keys: |
101+
${{ runner.os }}-bun-e2e-
46102
47103
- name: Setup Xcode
48104
uses: maxim-lobanov/setup-xcode@v1
@@ -70,14 +126,37 @@ jobs:
70126
- name: Install react-native-update-cli dependencies
71127
run: cd react-native-update-cli && bun install --frozen-lockfile && bun run build
72128

129+
- name: Prepare local update artifacts
130+
env:
131+
E2E_PLATFORM: ios
132+
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
133+
run: cd Example/e2etest && bun run prepare:e2e
134+
135+
- name: Cache CocoaPods dependencies
136+
uses: actions/cache@v4
137+
with:
138+
path: |
139+
Example/e2etest/ios/Pods
140+
~/Library/Caches/CocoaPods
141+
key: ${{ runner.os }}-cocoapods-e2e-${{ hashFiles('Example/e2etest/ios/Podfile.lock', 'Example/e2etest/ios/Podfile', 'Example/e2etest/bun.lock') }}
142+
restore-keys: |
143+
${{ runner.os }}-cocoapods-e2e-
144+
73145
- name: Install CocoaPods dependencies
74146
run: cd Example/e2etest/ios && pod install
75147

76-
- name: Rebuild Detox iOS framework cache
77-
run: |
78-
cd Example/e2etest
79-
bunx detox clean-framework-cache
80-
bunx detox build-framework-cache
148+
- name: Cache Detox iOS framework
149+
id: cache-detox-ios-framework
150+
uses: actions/cache@v4
151+
with:
152+
path: ~/Library/Detox
153+
key: ${{ runner.os }}-detox-ios-framework-xcode-26.4-${{ hashFiles('Example/e2etest/bun.lock') }}
154+
restore-keys: |
155+
${{ runner.os }}-detox-ios-framework-xcode-26.4-
156+
157+
- name: Build Detox iOS framework cache
158+
if: steps.cache-detox-ios-framework.outputs.cache-hit != 'true'
159+
run: cd Example/e2etest && bunx detox build-framework-cache
81160

82161
- name: Detox build (ios.sim.release)
83162
env:
@@ -87,4 +166,5 @@ jobs:
87166
- name: Detox test (ios.sim.release)
88167
env:
89168
RNU_CLI_ROOT: ${{ github.workspace }}/react-native-update-cli
169+
RNU_E2E_SKIP_PREPARE: 'true'
90170
run: cd Example/e2etest && E2E_PLATFORM=ios bunx detox test --configuration ios.sim.release

Example/e2etest/e2e/globalSetup.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ function runPrepareScript() {
7676
}
7777
}
7878

79+
function ensurePreparedArtifacts(platform: string) {
80+
const manifestPath = path.join(artifactsRoot, platform, 'manifest.json');
81+
if (!fs.existsSync(manifestPath)) {
82+
throw new Error(
83+
`RNU_E2E_SKIP_PREPARE is set, but local update artifacts are missing: ${manifestPath}`,
84+
);
85+
}
86+
}
87+
7988
function startServer() {
8089
const serverScript = path.join(projectRoot, 'scripts/local-e2e-server.ts');
8190
fs.mkdirSync(artifactsRoot, { recursive: true });
@@ -132,7 +141,11 @@ async function globalSetup() {
132141
}
133142

134143
killExistingServer();
135-
runPrepareScript();
144+
if (process.env.RNU_E2E_SKIP_PREPARE === 'true') {
145+
ensurePreparedArtifacts(platform);
146+
} else {
147+
runPrepareScript();
148+
}
136149
startServer();
137150
await waitForServer();
138151
await detoxGlobalSetup();

0 commit comments

Comments
 (0)