Skip to content

Commit 0e56359

Browse files
chore(examples): Apply RNRepo to FabricExample (#3963)
## Description Adds RNRepo build-tools integration to `FabricExample` so that CI builds can consume pre-built native dependencies instead of compiling them from scratch, speeding up CI. The integration is guarded by `CI=true` / `ENV['CI']` environment variables, so local development is unaffected. ## Changes - `FabricExample/android/build.gradle` — resolves `@rnrepo/build-tools` via Node and adds its Gradle plugin JAR to the buildscript classpath. - `FabricExample/android/app/build.gradle` — applies `org.rnrepo.tools.prebuilds-plugin` when running in CI. - `FabricExample/ios/Podfile` — requires the RNRepo CocoaPods plugin and calls `rnrepo_post_install` in the `post_install` hook, both gated on `ENV['CI']`. - `FabricExample/package.json` — adds `@rnrepo/build-tools ~0.1.3-beta.0` as a dev dependency. ## Performance CI build time comparison (rnrepo vs baseline): | Platform | Category | rnrepo | basic | Faster | | --- | --- | --- | --- | --- | | Android | Without runner cache | 6:53 avg | 8:35 avg | **19.8%** | | Android | With runner cache | 3:17 avg | 5:29 avg | **40.1%** | | iOS | Without runner cache | 6:22 | 6:16 | -1.6% | | iOS | With runner cache | 6:28 avg | 6:18 avg | -2.6% | | iOS | With runner cache and prebuilt rncore | 3:31 avg | 4:01 avg | **12.4%** | Android sees the biggest wins (~20% standard, ~40% with cache). iOS gains are visible when `rncore` is prebuilt (~12%) (tracked in #3955). ## Test plan - Verified that a local build (without `CI=true`) still works without any RNRepo-related side effects. - CI run with `CI=true` should pick up pre-built artifacts via the RNRepo plugin on both Android and iOS.
1 parent 959df62 commit 0e56359

6 files changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/android-build-test-fabric.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ jobs:
4646
run: yarn
4747
- name: Build app
4848
working-directory: ${{ env.WORKING_DIRECTORY }}/android
49-
run: ./gradlew assembleDebug --console=plain -PreactNativeArchitectures=arm64-v8a
49+
run: ./gradlew :app:assembleDebug --console=plain -PreactNativeArchitectures=arm64-v8a

FabricExample/android/app/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44

5+
def isCIEnabled() {
6+
return ["1", "true"].contains(System.getenv("CI")?.toLowerCase())
7+
}
8+
9+
// System.setProperty("DISABLE_RNREPO", "1") // Uncomment to disable RNRepo even in CI
10+
def isRNRepoEnabled() {
11+
return System.getenv("DISABLE_RNREPO") == null
12+
}
13+
14+
// Use RNRepo in CI builds.
15+
// Set DISABLE_RNREPO to any value to disable RNRepo.
16+
if (isCIEnabled() && isRNRepoEnabled()) {
17+
apply plugin: "org.rnrepo.tools.prebuilds-plugin"
18+
}
19+
520
/**
621
* This is the configuration block to customize your React Native Android app.
722
* By default you don't need to apply any configuration, just uncomment the lines you need.

FabricExample/android/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ buildscript {
1111
google()
1212
mavenCentral()
1313
}
14+
// RNRepo plugin classpath for CI builds (plugin applied in app/build.gradle).
15+
// To disable RNRepo support, set DISABLE_RNREPO environment variable to ANY value.
16+
def rnrepoClasspath = {
17+
def rnrepoDir = new File(
18+
providers.exec {
19+
workingDir(rootDir)
20+
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
21+
}.standardOutput.asText.get().trim()
22+
).getParentFile().absolutePath
23+
return fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
24+
}
1425
dependencies {
1526
classpath("com.android.tools.build:gradle")
1627
classpath("com.facebook.react:react-native-gradle-plugin")
1728
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
29+
classpath rnrepoClasspath()
1830
}
1931
}
2032

FabricExample/ios/Podfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ require Pod::Executable.execute_command('node', ['-p',
55
{paths: [process.argv[1]]},
66
)', __dir__]).strip
77

8+
def is_ci_enabled?
9+
%w[1 true].include?(ENV['CI'].to_s.downcase)
10+
end
11+
12+
# ENV['DISABLE_RNREPO'] = "1" # Uncomment to disable RNRepo even in CI
13+
def is_rnrepo_enabled?
14+
ENV['DISABLE_RNREPO'].nil?
15+
end
16+
17+
# Use RNRepo in CI builds. Set DISABLE_RNREPO to any value to disable RNRepo.
18+
if is_ci_enabled? && is_rnrepo_enabled?
19+
require Pod::Executable.execute_command('node', ['-p',
20+
'require.resolve(
21+
"@rnrepo/build-tools/cocoapods-plugin/lib/plugin.rb",
22+
{paths: [process.argv[1]]},
23+
)', __dir__]).strip
24+
end
25+
826
require_relative '../../scripts/ios/rns_update_info_plist'
927
require_relative '../../scripts/ios/rns_set_swift_compilation_flags'
1028

@@ -32,6 +50,9 @@ target 'FabricExample' do
3250
)
3351

3452
post_install do |installer|
53+
if is_ci_enabled? && is_rnrepo_enabled?
54+
rnrepo_post_install(installer)
55+
end
3556
react_native_post_install(
3657
installer,
3758
config[:reactNativePath],

FabricExample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@react-native/jest-preset": "0.85.0",
4949
"@react-native/metro-config": "0.85.0",
5050
"@react-native/typescript-config": "0.85.0",
51+
"@rnrepo/build-tools": "~0.1.3-beta.0",
5152
"@types/jest": "^29.5.13",
5253
"@types/react": "^19.2.0",
5354
"@types/react-test-renderer": "^19.1.0",

FabricExample/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,13 @@ __metadata:
31013101
languageName: node
31023102
linkType: soft
31033103

3104+
"@rnrepo/build-tools@npm:~0.1.3-beta.0":
3105+
version: 0.1.3-beta.0
3106+
resolution: "@rnrepo/build-tools@npm:0.1.3-beta.0"
3107+
checksum: 10c0/83d2c2b05d87ab038d139c56b2e8ea1df071c41a51094a6464d9c7bc5794f25eb289b8b9298418e829d9ebfe723a77d5556fb1eaf69d87b25dda1f7d19d2d5fb
3108+
languageName: node
3109+
linkType: hard
3110+
31043111
"@sideway/address@npm:^4.1.5":
31053112
version: 4.1.5
31063113
resolution: "@sideway/address@npm:4.1.5"
@@ -3515,6 +3522,7 @@ __metadata:
35153522
"@react-navigation/native-stack": "link:../react-navigation/packages/native-stack/"
35163523
"@react-navigation/routers": "link:../react-navigation/packages/routers/"
35173524
"@react-navigation/stack": "link:../react-navigation/packages/stack/"
3525+
"@rnrepo/build-tools": "npm:~0.1.3-beta.0"
35183526
"@types/jest": "npm:^29.5.13"
35193527
"@types/react": "npm:^19.2.0"
35203528
"@types/react-test-renderer": "npm:^19.1.0"

0 commit comments

Comments
 (0)