-
Notifications
You must be signed in to change notification settings - Fork 2
528 lines (473 loc) · 16.7 KB
/
Copy pathci.yml
File metadata and controls
528 lines (473 loc) · 16.7 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
name: CI
on:
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '17 3 * * 1'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Classify changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
android: ${{ steps.changes.outputs.android }}
ios: ${{ steps.changes.outputs.ios }}
quality: ${{ steps.changes.outputs.quality }}
site: ${{ steps.changes.outputs.site }}
web: ${{ steps.changes.outputs.web }}
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
- name: Classify changed files
id: changes
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
EVENT_NAME: ${{ github.event_name }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
android=false
ios=false
quality=false
site=false
web=false
if [[ "$EVENT_NAME" != "pull_request" ]]; then
android=true
ios=true
quality=true
site=true
web=true
else
while IFS= read -r file; do
case "$file" in
.github/workflows/ci.yml|.github/actions/**|package.json|yarn.lock|.yarnrc.yml|.yarn/releases/**|.nvmrc)
android=true
ios=true
quality=true
site=true
web=true
;;
.github/workflows/registry-canary.yml|scripts/test-registry-consumers.mjs)
quality=true
web=true
;;
src/**|assets/**)
android=true
ios=true
quality=true
web=true
;;
cpp/fuzz/**|scripts/test-native-fuzz.sh|cpp/benchmark/**|scripts/benchmark-native.mjs|.github/workflows/native-benchmark.yml)
quality=true
;;
cpp/**)
android=true
ios=true
quality=true
web=true
;;
android/**|example/android/**|scripts/run-android-runtime-test.sh)
android=true
quality=true
;;
compatibility/android-api/**|scripts/test-rn-android-compatibility.sh)
android=true
quality=true
;;
compatibility/ios-api/**|scripts/test-rn-ios-compatibility.sh)
ios=true
quality=true
;;
ios/**|example/ios/**|*.podspec)
ios=true
quality=true
;;
example/src/**|example/e2e/**)
android=true
ios=true
quality=true
;;
web/**|fixtures/**|scripts/build-web-wasm.sh|scripts/test-web*.mjs|scripts/web-*)
android=true
ios=true
web=true
quality=true
site=true
;;
scripts/prepare-package.mjs|scripts/test-package-consumers.mjs)
quality=true
web=true
;;
benchmarks/**|scripts/benchmark-web.mjs)
quality=true
site=true
web=true
;;
site/**|docs/**|README*.md|CONTRIBUTING.md|scripts/build-site.mjs|scripts/test-site*.mjs|.github/workflows/pages.yml)
site=true
;;
.github/ISSUE_TEMPLATE/**|.github/PULL_REQUEST_TEMPLATE.md|.github/CODEOWNERS|.github/dependabot.yml)
quality=true
;;
*.md)
site=true
;;
*)
# Unknown repository changes run every gate instead of risking a false skip.
android=true
ios=true
quality=true
site=true
web=true
;;
esac
done < <(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
fi
{
echo "android=$android"
echo "ios=$ios"
echo "quality=$quality"
echo "site=$site"
echo "web=$web"
} >> "$GITHUB_OUTPUT"
{
echo '### CI change classification'
echo
echo "| Gate | Run |"
echo "| --- | --- |"
echo "| Android | $android |"
echo "| iOS | $ios |"
echo "| Core quality | $quality |"
echo "| Site | $site |"
echo "| Web | $web |"
} >> "$GITHUB_STEP_SUMMARY"
android-build:
name: Android New Architecture Build
needs: changes
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
with:
distribution: zulu
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
with:
cache-provider: basic
cache-read-only: ${{ github.event_name == 'pull_request' }}
- name: Build package
run: yarn prepare
- name: Build Android and run unit tests
working-directory: example/android
run: |
./gradlew test assembleRelease --stacktrace -PnewArchEnabled=true
mv app/build/outputs/apk/release/app-release.apk app-release-${{ github.sha }}-new-arch.apk
- name: Upload Android reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Android-New-Architecture-Build-Reports
path: example/android/**/build/reports
if-no-files-found: ignore
retention-days: 7
- name: Upload APK
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: app-release-${{ github.sha }}-new-arch
path: example/android/app-release-${{ github.sha }}-new-arch.apk
if-no-files-found: error
retention-days: 7
android-api-level-test:
name: Android New Architecture Runtime Test (API ${{ matrix.api-level }})
needs: [changes, android-build]
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: ${{ github.event_name == 'pull_request' }}
max-parallel: 2
matrix:
api-level: ${{ fromJSON(github.event_name == 'pull_request' && '[24,31]' || '[24,25,29,30,31]') }}
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
with:
distribution: zulu
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
with:
cache-provider: basic
cache-read-only: true
- name: Prewarm Gradle wrapper
working-directory: example/android
run: ./gradlew --version
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build package
run: yarn prepare
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
profile: Nexus 6
script: sh scripts/run-android-runtime-test.sh ${{ matrix.api-level }}
- name: Upload instrumentation reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: New-Arch-Runtime-Test-Reports-${{ matrix.api-level }}
path: |
example/android/app/build/reports
example/android/app/build/outputs/androidTest-results
if-no-files-found: ignore
retention-days: 7
android-rn-compatibility:
name: Android RN API Compatibility (${{ matrix.react-native }}, ${{ matrix.architecture }})
needs: changes
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: true
max-parallel: 2
matrix:
include:
- react-native: '0.73.11'
architecture: old
- react-native: '0.73.11'
architecture: new
- react-native: '0.74.7'
architecture: new
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
with:
distribution: zulu
java-version: 17
- name: Set up Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
with:
gradle-version: '8.3'
cache-provider: basic
cache-read-only: ${{ github.event_name == 'pull_request' }}
- name: Compile library against React Native Android APIs
run: sh scripts/test-rn-android-compatibility.sh ${{ matrix.react-native }} ${{ matrix.architecture }}
ios-build-test:
name: iOS New Architecture Runtime Test
needs: changes
if: needs.changes.outputs.ios == 'true'
runs-on: macos-15
timeout-minutes: 45
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Set up Ruby
uses: ruby/setup-ruby@003a5c4d8d6321bd302e38f6f0ec593f77f06600 # v1
with:
ruby-version: '3.3'
bundler-cache: true
working-directory: example
- name: Cache Pods
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
example/ios/Pods
~/Library/Caches/CocoaPods
key: ${{ runner.os }}-pods-rn86-new-arch-${{ hashFiles('example/ios/Podfile.lock', 'example/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-rn86-new-arch-
- name: Install Pods
env:
NO_FLIPPER: '1'
RCT_NEW_ARCH_ENABLED: '1'
run: |
cd example/ios
bundle exec pod install
- name: Select an available iPhone simulator
id: simulator
run: |
simulator_udid="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/ { print $2; exit }')"
if [[ -z "$simulator_udid" ]]; then
echo 'No available iPhone simulator was found' >&2
exit 1
fi
echo "udid=$simulator_udid" >> "$GITHUB_OUTPUT"
- name: Test
env:
SIMULATOR_UDID: ${{ steps.simulator.outputs.udid }}
run: |
set -o pipefail
cd example/ios
# Xcode expands $(inherited), not the shell.
# shellcheck disable=SC2016
xcodebuild \
-workspace BsDiffPatchExample.xcworkspace \
-scheme BsDiffPatchExample \
-configuration Release \
-sdk iphonesimulator \
-destination "platform=iOS Simulator,id=$SIMULATOR_UDID" \
-resultBundlePath "$RUNNER_TEMP/ios-tests.xcresult" \
EXPECTED_NEW_ARCH=1 \
GCC_PREPROCESSOR_DEFINITIONS='$(inherited) EXPECTED_NEW_ARCH=$(EXPECTED_NEW_ARCH)' \
test | bundle exec xcpretty
- name: Upload iOS test results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: iOS-New-Architecture-Test-Results
path: ${{ runner.temp }}/ios-tests.xcresult
if-no-files-found: ignore
retention-days: 7
ios-rn-compatibility:
name: iOS RN API Compatibility (${{ matrix.react-native }}, ${{ matrix.architecture }})
needs: changes
if: needs.changes.outputs.ios == 'true'
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: true
max-parallel: 2
matrix:
include:
- react-native: '0.73.11'
architecture: old
node: '18'
runner: macos-14
- react-native: '0.73.11'
architecture: new
node: '18'
runner: macos-14
- react-native: '0.74.7'
architecture: new
node: '18'
runner: macos-14
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: ${{ matrix.node }}
- name: Set up Ruby
uses: ruby/setup-ruby@003a5c4d8d6321bd302e38f6f0ec593f77f06600 # v1
with:
ruby-version: '3.3'
bundler-cache: true
working-directory: example
- name: Compile Pod against React Native iOS APIs
run: sh scripts/test-rn-ios-compatibility.sh ${{ matrix.react-native }} ${{ matrix.architecture }}
web-test:
name: Web WASM and Browser Test
needs: changes
if: needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Build package
run: yarn prepare
- name: Run Web tests
env:
CHROME_PATH: /usr/bin/google-chrome
run: |
yarn test:web
yarn test:web:browser
yarn test:web:metro
yarn test:package
- name: Verify npm package contents
run: npm pack --dry-run --ignore-scripts
quality:
name: Lint, TypeScript, and Jest
needs: changes
if: needs.changes.outputs.quality == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Run core quality gates
run: |
yarn prepare
yarn typecheck
yarn lint
yarn test --runInBand
yarn test:native-operations
FUZZ_RUNS=2000 yarn test:fuzz
site-test:
name: Documentation Site and Playground Test
needs: changes
if: needs.changes.outputs.site == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout the code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Setup Node.js and dependencies
uses: ./.github/actions/setup
- name: Build documentation site
run: yarn site:build
- name: Validate site and Playground
env:
CHROME_PATH: /usr/bin/google-chrome
run: |
yarn site:test
yarn site:test:browser
ci-complete:
name: Complete CI
needs:
[
changes,
quality,
android-build,
android-api-level-test,
android-rn-compatibility,
ios-build-test,
ios-rn-compatibility,
web-test,
site-test,
]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check all job statuses
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
- name: Confirm completion
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: echo 'All required CI gates completed successfully.'