Skip to content

Commit a9bdaa7

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Connect ReactNativeDependencies with ios jobs (facebook#49978)
Summary: Pull Request resolved: facebook#49978 This change connects the RNDependencies we prebuild in CI with the other iOS jobs we have. By doing so, we aim to speed up the build time in CI, saving time and money. ## Changelog: [Internal] - Connect the ReactNativeDependencies in CI Differential Revision: D71034587
1 parent 0eeac79 commit a9bdaa7

File tree

5 files changed

+65
-27
lines changed

5 files changed

+65
-27
lines changed

.github/actions/test-ios-helloworld/action.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ runs:
4646
uses: ruby/[email protected]
4747
with:
4848
ruby-version: ${{ inputs.ruby-version }}
49+
- name: Download ReactNativeDependencies
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz
53+
path: /tmp/third-party
54+
- name: Print third-party folder
55+
shell: bash
56+
run: ls -lR /tmp/third-party
4957
- name: Install iOS dependencies - Configuration ${{ inputs.flavor }}; New Architecture ${{ inputs.architecture }}; JS Engine ${{ inputs.jsengine }}
5058
shell: bash
5159
run: |
@@ -78,7 +86,8 @@ runs:
7886
BUILD_TYPE="${{ inputs.flavor }}"
7987
TARBALL_FILENAME=$(node ../react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")
8088
HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME"
81-
HERMES_ENGINE_TARBALL_PATH="$HERMES_PATH" yarn bootstrap ios "${args[@]}" | cat
89+
RN_DEP_PATH="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz"
90+
RCT_USE_LOCAL_RN_DEP="$RN_DEP_PATH" HERMES_ENGINE_TARBALL_PATH="$HERMES_PATH" yarn bootstrap ios "${args[@]}" | cat
8291
fi
8392
- name: Build HelloWorld project
8493
shell: bash

.github/actions/test-ios-rntester/action.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ runs:
9292
else
9393
echo 'No Hermes tarball found.'
9494
fi
95+
- name: Download ReactNativeDependencies
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz
99+
path: /tmp/third-party/
100+
- name: Print third-party folder
101+
shell: bash
102+
run: ls -lR /tmp/third-party
95103
- name: Setup xcode build cache
96104
uses: ./.github/actions/setup-xcode-build-cache
97105
with:
@@ -118,10 +126,11 @@ runs:
118126
export RCT_NEW_ARCH_ENABLED=0
119127
fi
120128
129+
DEP_TARBALL_PATH="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz"
121130
cd packages/rn-tester
122131
123132
bundle install
124-
bundle exec pod install
133+
RCT_USE_LOCAL_RN_DEP="$DEP_TARBALL_PATH" bundle exec pod install
125134
- name: Build RNTester
126135
shell: bash
127136
run: |

.github/workflows/test-all.yml

+17-7
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
test_ios_rntester_ruby_3_2_0:
124124
runs-on: macos-13
125125
needs:
126-
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos]
126+
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies]
127127
env:
128128
HERMES_WS_DIR: /tmp/hermes
129129
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
@@ -140,7 +140,7 @@ jobs:
140140
test_ios_rntester_dynamic_frameworks:
141141
runs-on: macos-13
142142
needs:
143-
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos]
143+
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies]
144144
env:
145145
HERMES_WS_DIR: /tmp/hermes
146146
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
@@ -163,7 +163,7 @@ jobs:
163163
test_ios_rntester:
164164
runs-on: macos-13-large
165165
needs:
166-
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos]
166+
[build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies]
167167
env:
168168
HERMES_WS_DIR: /tmp/hermes
169169
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
@@ -232,7 +232,7 @@ jobs:
232232
test_e2e_ios_templateapp:
233233
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
234234
runs-on: macos-13-large
235-
needs: build_npm_package
235+
needs: [build_npm_package, prebuild_apple_dependencies]
236236
env:
237237
HERMES_WS_DIR: /tmp/hermes
238238
HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin
@@ -268,6 +268,14 @@ jobs:
268268
path: /tmp/react-native-tmp
269269
- name: Print /tmp folder
270270
run: ls -lR /tmp/react-native-tmp
271+
- name: Download ReactNativeDependencies
272+
uses: actions/download-artifact@v4
273+
with:
274+
name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
275+
path: /tmp/third-party
276+
- name: Print third-party folder
277+
shell: bash
278+
run: ls -lR /tmp/third-party
271279
- name: Prepare artifacts
272280
run: |
273281
REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz")
@@ -292,7 +300,9 @@ jobs:
292300
echo "Disable the New Architecture"
293301
NEW_ARCH_ENABLED=0
294302
fi
295-
HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install
303+
304+
LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
305+
RCT_USE_LOCAL_RN_DEP="$LOCAL_RN_DEP" HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install
296306
297307
xcodebuild \
298308
-scheme "RNTestProject" \
@@ -580,7 +590,7 @@ jobs:
580590

581591
test_ios_helloworld_with_ruby_3_2_0:
582592
runs-on: macos-13
583-
needs: [prepare_hermes_workspace, build_hermes_macos] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs
593+
needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs
584594
env:
585595
PROJECT_NAME: iOSTemplateProject
586596
HERMES_WS_DIR: /tmp/hermes
@@ -598,7 +608,7 @@ jobs:
598608

599609
test_ios_helloworld:
600610
runs-on: macos-13
601-
needs: [prepare_hermes_workspace, build_hermes_macos] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs
611+
needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs
602612
strategy:
603613
matrix:
604614
flavor: [Debug, Release]

packages/react-native/scripts/cocoapods/rndependencies.rb

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ def self.setup_react_native_dependencies(react_native_path, react_native_version
8686
artifacts_exists = ENV["RCT_USE_RN_DEP"] == "1" && release_artifact_exists(@@react_native_version)
8787
use_local_xcframework = ENV["RCT_USE_LOCAL_RN_DEP"] && File.exist?(ENV["RCT_USE_LOCAL_RN_DEP"])
8888

89+
if ENV["RCT_USE_LOCAL_RN_DEP"]
90+
if !File.exist?(ENV["RCT_USE_LOCAL_RN_DEP"])
91+
abort("RCT_USE_LOCAL_RN_DEP is set to #{ENV["RCT_USE_LOCAL_RN_DEP"]} but the file does not exist!")
92+
end
93+
end
94+
8995
@@build_from_source = !use_local_xcframework && !artifacts_exists
9096

9197
rndeps_log("Building from source: #{@@build_from_source}")

packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec

+22-18
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,31 @@ Pod::Spec.new do |spec|
5252
find "$CURRENT_PATH" -type d -empty -delete
5353
CMD
5454

55-
script_phase = {
56-
:name => "[RNDeps] Replace React Native Dependencies for the right configuration, if needed",
57-
:execution_position => :before_compile,
58-
:script => <<-EOS
59-
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
55+
# If we are passing a local tarball, we don't want to switch between Debug and Release
56+
if !ENV["RCT_USE_LOCAL_RN_DEP"]
57+
script_phase = {
58+
:name => "[RNDeps] Replace React Native Dependencies for the right configuration, if needed",
59+
:execution_position => :before_compile,
60+
:script => <<-EOS
61+
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
6062
61-
CONFIG="Release"
62-
if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then
63-
CONFIG="Debug"
64-
fi
63+
CONFIG="Release"
64+
if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then
65+
CONFIG="Debug"
66+
fi
6567
66-
"$NODE_BINARY" "$REACT_NATIVE_PATH/third-party-podspecs/replace_dependencies_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT"
67-
EOS
68-
}
68+
"$NODE_BINARY" "$REACT_NATIVE_PATH/third-party-podspecs/replace_dependencies_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT"
69+
EOS
70+
}
6971

70-
# :always_out_of_date is only available in CocoaPods 1.13.0 and later
71-
if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0')
72-
# always run the script without warning
73-
script_phase[:always_out_of_date] = "1"
74-
end
7572

76-
spec.script_phase = script_phase
73+
# :always_out_of_date is only available in CocoaPods 1.13.0 and later
74+
if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0')
75+
# always run the script without warning
76+
script_phase[:always_out_of_date] = "1"
77+
end
78+
79+
spec.script_phase = script_phase
80+
end
7781

7882
end

0 commit comments

Comments
 (0)