Skip to content

Commit fcfa4d7

Browse files
dmytrorykunSaadnajmi
authored andcommitted
Reuse test_ios_rntester to run iOS tests (#39277)
Summary: Pull Request resolved: #39277 When we were reworking the Build logic in CI, we thought that the `test_ios` job and the `test_ios_rntester` jobs were the same. But, actually, they aren't. So, now, we are seeing failures in the `test_ios` because its caches are not updated. This changes remove the duplication of the two jobs, making sure that they use the same job, adding the possibility to run tests directly in rntester. ## Changelog: [Internal] - Reuse test_ios_rntester to run iOS tests Reviewed By: motiz88 Differential Revision: D48950096 fbshipit-source-id: e297d77fbd18f03873ed7a16a595e186d0e2453a
1 parent 6659399 commit fcfa4d7

File tree

5 files changed

+86
-126
lines changed

5 files changed

+86
-126
lines changed

.circleci/configurations/commands.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,53 @@ commands:
506506
when: << parameters.when >>
507507
path: << parameters.path >>
508508
destination: << parameters.destination >>
509+
510+
prepare_ios_tests:
511+
description: This command runs a set of commands to prepare iOS for running unit tests
512+
steps:
513+
- brew_install:
514+
package: xcbeautify
515+
- run:
516+
name: Run Ruby Tests
517+
command: |
518+
cd packages/react-native/scripts
519+
sh run_ruby_tests.sh
520+
- run:
521+
name: Boot iPhone Simulator
522+
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
523+
524+
- run:
525+
name: Configure Environment Variables
526+
command: |
527+
echo 'export PATH=/usr/local/opt/node@18/bin:$PATH' >> $BASH_ENV
528+
source $BASH_ENV
529+
530+
- run:
531+
name: "Brew: Tap wix/brew"
532+
command: brew tap wix/brew
533+
- brew_install:
534+
package: applesimutils watchman
535+
- run:
536+
name: Configure Watchman
537+
command: echo "{}" > .watchmanconfig
538+
539+
run_ios_tests:
540+
description: This command run iOS tests and collects results
541+
steps:
542+
- run:
543+
name: "Run Tests: iOS Unit and Integration Tests"
544+
command: node ./scripts/circleci/run_with_retry.js 3 yarn test-ios
545+
- run:
546+
name: Zip Derived data folder
547+
when: always
548+
command: |
549+
echo "zipping tests results"
550+
cd /Users/distiller/Library/Developer/Xcode
551+
XCRESULT_PATH=$(find . -name '*.xcresult')
552+
tar -zcvf xcresults.tar.gz $XCRESULT_PATH
553+
- store_artifacts_if_needed:
554+
path: /Users/distiller/Library/Developer/Xcode/xcresults.tar.gz
555+
- report_bundle_size:
556+
platform: ios
557+
- store_test_results:
558+
path: ./reports/junit

.circleci/configurations/jobs.yml

Lines changed: 26 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -109,109 +109,6 @@ jobs:
109109
- store_test_results:
110110
path: ./reports/junit
111111

112-
# -------------------------
113-
# JOBS: iOS Unit Tests
114-
# -------------------------
115-
test_ios:
116-
executor: reactnativeios
117-
parameters:
118-
run_unit_tests:
119-
description: Specifies whether unit tests should run.
120-
type: boolean
121-
default: false
122-
jsengine:
123-
default: "Hermes"
124-
description: Which JavaScript engine to use. Must be one of "Hermes", "JSC".
125-
type: enum
126-
enum: ["Hermes", "JSC"]
127-
ruby_version:
128-
default: "2.6.10"
129-
description: The version of ruby that must be used
130-
type: string
131-
environment:
132-
- REPORTS_DIR: "./reports/junit"
133-
steps:
134-
- checkout_code_with_cache
135-
- setup_ruby:
136-
ruby_version: << parameters.ruby_version >>
137-
- brew_install:
138-
package: xcbeautify
139-
- run:
140-
name: Run Ruby Tests
141-
command: |
142-
cd packages/react-native/scripts
143-
sh run_ruby_tests.sh
144-
- run_yarn
145-
- *attach_hermes_workspace
146-
- run: |
147-
cd packages/rn-tester
148-
bundle check || bundle install
149-
- run:
150-
name: Boot iPhone Simulator
151-
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
152-
153-
- run:
154-
name: Configure Environment Variables
155-
command: |
156-
echo 'export PATH=/usr/local/opt/node@18/bin:$PATH' >> $BASH_ENV
157-
source $BASH_ENV
158-
159-
- run:
160-
name: "Brew: Tap wix/brew"
161-
command: brew tap wix/brew
162-
- brew_install:
163-
package: applesimutils watchman
164-
165-
- run:
166-
name: Configure Watchman
167-
command: echo "{}" > .watchmanconfig
168-
169-
- run:
170-
name: Setup the CocoaPods environment
171-
command: |
172-
bundle exec pod setup
173-
174-
- with_hermes_tarball_cache_span:
175-
set_tarball_path: True
176-
steps:
177-
- with_rntester_pods_cache_span:
178-
steps:
179-
- run:
180-
name: Generate RNTesterPods Workspace
181-
command: |
182-
if [[ << parameters.jsengine >> == "JSC" ]]; then
183-
export USE_HERMES=0
184-
fi
185-
186-
cd packages/rn-tester
187-
bundle install
188-
bundle exec pod install --verbose
189-
190-
# -------------------------
191-
# Runs iOS unit tests
192-
- when:
193-
condition: << parameters.run_unit_tests >>
194-
steps:
195-
- run:
196-
name: "Run Tests: iOS Unit and Integration Tests"
197-
command: node ./scripts/circleci/run_with_retry.js 3 yarn test-ios
198-
- run:
199-
name: Zip Derived data folder
200-
when: always
201-
command: |
202-
echo "zipping tests results"
203-
cd /Users/distiller/Library/Developer/Xcode
204-
XCRESULT_PATH=$(find . -name '*.xcresult')
205-
tar -zcvf xcresults.tar.gz $XCRESULT_PATH
206-
- store_artifacts_if_needed:
207-
path: /Users/distiller/Library/Developer/Xcode/xcresults.tar.gz
208-
# -------------------------
209-
# Collect Results
210-
- report_bundle_size:
211-
platform: ios
212-
- store_test_results:
213-
path: ./reports/junit
214-
215112
# -------------------------
216113
# JOBS: iOS E2E Tests
217114
# -------------------------
@@ -627,6 +524,10 @@ jobs:
627524
default: "2.6.10"
628525
description: The version of ruby that must be used
629526
type: string
527+
run_unit_tests:
528+
description: whether unit tests should run or not.
529+
default: false
530+
type: boolean
630531
steps:
631532
- checkout_code_with_cache
632533
- run_yarn
@@ -641,6 +542,10 @@ jobs:
641542
command: sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/
642543
- setup_ruby:
643544
ruby_version: << parameters.ruby_version >>
545+
- when:
546+
condition: << parameters.run_unit_tests >>
547+
steps:
548+
- prepare_ios_tests
644549
- with_hermes_tarball_cache_span:
645550
set_tarball_path: True
646551
steps:
@@ -666,13 +571,24 @@ jobs:
666571
667572
bundle install
668573
bundle exec pod install
669-
- run:
670-
name: Build RNTester
671-
command: |
672-
xcodebuild build \
673-
-workspace packages/rn-tester/RNTesterPods.xcworkspace \
674-
-scheme RNTester \
675-
-sdk iphonesimulator
574+
- when:
575+
condition:
576+
# The run_ios_test will also build RNTester so we don't nee to build it
577+
# here if we run tests
578+
equal: [ false, << parameters.run_unit_tests >> ]
579+
580+
steps:
581+
- run:
582+
name: Build RNTester
583+
command: |
584+
xcodebuild build \
585+
-workspace packages/rn-tester/RNTesterPods.xcworkspace \
586+
-scheme RNTester \
587+
-sdk iphonesimulator
588+
- when:
589+
condition: << parameters.run_unit_tests >>
590+
steps:
591+
- run_ios_tests
676592

677593
# -------------------------
678594
# JOBS: Windows

.circleci/configurations/test_workflows/testAll.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,11 @@
169169
- architecture: "OldArch"
170170
jsengine: "JSC"
171171
use_frameworks: "StaticLibraries"
172-
- test_ios:
173-
name: "Test iOS with Ruby 3.2.0"
174-
run_unit_tests: true
175-
requires:
176-
- build_hermes_macos
177-
ruby_version: "3.2.0"
178-
- test_ios:
172+
- test_ios_rntester:
179173
run_unit_tests: true
174+
architecture: "OldArch"
175+
use_frameworks: "StaticLibraries"
176+
ruby_version: "2.6.10"
180177
requires:
181178
- build_hermes_macos
182179
matrix:

.circleci/configurations/test_workflows/testIOS.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,11 @@
160160
- architecture: "OldArch"
161161
jsengine: "JSC"
162162
use_frameworks: "StaticLibraries"
163-
- test_ios:
164-
name: "Test iOS with Ruby 3.2.0"
165-
run_unit_tests: true
166-
requires:
167-
- build_hermes_macos
168-
ruby_version: "3.2.0"
169-
- test_ios:
163+
- test_ios_rntester:
170164
run_unit_tests: true
165+
architecture: "OldArch"
166+
use_frameworks: "StaticLibraries"
167+
ruby_version: "2.6.10"
171168
requires:
172169
- build_hermes_macos
173170
matrix:

.circleci/configurations/top_level.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ references:
8383
# Hermes iOS
8484
hermesc_apple_cache_key: &hermesc_apple_cache_key v2-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
8585
hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v2-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
86-
hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
87-
hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
86+
hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
87+
hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
8888
hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v1-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
8989
hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v1-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
9090
hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v1-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}

0 commit comments

Comments
 (0)