Skip to content

Commit 4352459

Browse files
Riccardo Cipolleschifacebook-github-bot
authored andcommitted
Add matrix for Debug/Release, New/Legacy Architecture, (No)Hermes (#34469)
Summary: This PR is the dual of the Matrix Tests we added to the Android Template a couple of weeks ago. It adds the same tests to iOS, to verify that the template builds with both architectures and with both configurations (Debug/Release).. And it tests that the template works with both Hermes and without it. ## Changelog [iOS] [Added] - Test iOS template with both architectures and configurations Pull Request resolved: #34469 Test Plan: CI is green in all the 8 new jobs. Reviewed By: hramos, cortinico Differential Revision: D39087876 Pulled By: cipolleschi fbshipit-source-id: 1205b2339bac87cf11b4f356a2e50e1e93ba52bc
1 parent 4b9382c commit 4352459

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

.circleci/config.yml

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,16 @@ jobs:
679679
# -------------------------
680680
test_ios_template:
681681
executor: reactnativeios
682+
parameters:
683+
flavor:
684+
type: string
685+
default: "Debug"
686+
architecture:
687+
type: string
688+
default: "OldArch"
689+
jsengine:
690+
type: string
691+
default: "Hermes"
682692
environment:
683693
- PROJECT_NAME: "iOSTemplateProject"
684694
- HERMES_WS_DIR: *hermes_workspace_root
@@ -689,25 +699,49 @@ jobs:
689699
- attach_workspace:
690700
at: .
691701
- *attach_hermes_workspace
692-
- run:
693-
name: Set USE_HERMES=1
694-
command: echo "export USE_HERMES=1" >> $BASH_ENV
695-
- run:
696-
name: Set HERMES_ENGINE_TARBALL_PATH
697-
command: |
698-
echo "export HERMES_ENGINE_TARBALL_PATH=$(ls -AU $HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-*.tar.gz | head -1)" >> $BASH_ENV
702+
- when:
703+
condition:
704+
equal: ["Hermes", << parameters.jsengine >>]
705+
steps:
706+
- run:
707+
name: Set HERMES_ENGINE_TARBALL_PATH
708+
command: |
709+
echo "export HERMES_ENGINE_TARBALL_PATH=$(ls -AU $HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-*.tar.gz | head -1)" >> $BASH_ENV
699710
- run:
700711
name: Create iOS template project
701712
command: |
702713
REPO_ROOT=$(pwd)
703714
PACKAGE=$(cat build/react-native-package-version)
704715
PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE"
705716
node ./scripts/set-rn-template-version.js "file:$PATH_TO_PACKAGE"
706-
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose
717+
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install
718+
- run:
719+
name: Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>>
720+
command: |
721+
cd /tmp/$PROJECT_NAME
722+
yarn install
723+
cd ios
724+
725+
bundle install
726+
727+
if [[ << parameters.flavor >> == "Release" ]]; then
728+
export PRODUCTION=1
729+
fi
730+
731+
if [[ << parameters.architecture >> == "NewArch" ]]; then
732+
export RCT_NEW_ARCH_ENABLED=1
733+
fi
734+
735+
if [[ << parameters.jsengine >> == "JSC" ]]; then
736+
export USE_HERMES=0
737+
fi
738+
739+
bundle exec pod install
707740
- run:
708741
name: Build template project
709742
command: |
710743
xcodebuild build \
744+
-configuration << parameters.flavor >> \
711745
-workspace /tmp/$PROJECT_NAME/ios/$PROJECT_NAME.xcworkspace \
712746
-scheme $PROJECT_NAME \
713747
-sdk iphonesimulator
@@ -1308,6 +1342,11 @@ workflows:
13081342
- test_ios_template:
13091343
requires:
13101344
- build_npm_package
1345+
matrix:
1346+
parameters:
1347+
architecture: ["NewArch", "OldArch"]
1348+
flavor: ["Debug", "Release"]
1349+
jsengine: ["Hermes", "JSC"]
13111350
- test_ios_rntester:
13121351
requires:
13131352
- build_hermes_macos

scripts/react-native-xcode.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,24 @@ fi
7878
# shellcheck source=/dev/null
7979
source "$REACT_NATIVE_DIR/scripts/node-binary.sh"
8080

81+
# If hermes-engine is in the podfile.lock, it means that Hermes is a dependency of the project
82+
# and it is enabled. If not, it means that hermes is disabled.
83+
HERMES_ENABLED=$(grep hermes-engine podfile.lock)
84+
85+
# If hermes-engine is not in the podfile.lock, it means that the app is not using Hermes.
86+
# Setting USE_HERMES is no the only way to set whether the app can use hermes or not: users
87+
# can also modify manually the Podfile.
88+
if [[ -z "$HERMES_ENABLED" ]]; then
89+
USE_HERMES=false
90+
fi
91+
8192
HERMES_ENGINE_PATH="$PODS_ROOT/hermes-engine"
8293
[ -z "$HERMES_CLI_PATH" ] && HERMES_CLI_PATH="$HERMES_ENGINE_PATH/destroot/bin/hermesc"
8394

8495
# Hermes is enabled in new projects by default, so we cannot assume that USE_HERMES=1 is set as an envvar.
8596
# If hermes-engine is found in Pods, we can assume Hermes has not been disabled.
8697
# If hermesc is not available and USE_HERMES is either unset or true, show error.
87-
if [[ -f "$HERMES_ENGINE_PATH" && ! -f "$HERMES_CLI_PATH" ]]; then
98+
if [[ ! -z "$HERMES_ENABLED" && -f "$HERMES_ENGINE_PATH" && ! -f "$HERMES_CLI_PATH" ]]; then
8899
echo "error: Hermes is enabled but the hermesc binary could not be found at ${HERMES_CLI_PATH}." \
89100
"Perhaps you need to run 'bundle exec pod install' or otherwise " \
90101
"point the HERMES_CLI_PATH variable to your custom location." >&2

scripts/react_native_pods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def use_react_native! (
3838
fabric_enabled: false,
3939
new_arch_enabled: ENV['RCT_NEW_ARCH_ENABLED'] == '1',
4040
production: ENV['PRODUCTION'] == '1',
41-
hermes_enabled: true,
41+
hermes_enabled: ENV['USE_HERMES'] && ENV['USE_HERMES'] == '0' ? false : true,
4242
flipper_configuration: FlipperConfiguration.disabled,
4343
app_path: '..',
4444
config_file_dir: '')

template/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target 'HelloWorld' do
1515
# Hermes is now enabled by default. Disable by setting this flag to false.
1616
# Upcoming versions of React Native may rely on get_default_flags(), but
1717
# we make it explicit here to aid in the React Native upgrade process.
18-
:hermes_enabled => true,
18+
:hermes_enabled => flags[:hermes_enabled],
1919
:fabric_enabled => flags[:fabric_enabled],
2020
# Enables Flipper.
2121
#

0 commit comments

Comments
 (0)