diff --git a/.circleci/config.yml b/.circleci/config.yml index 7452d4bd43a7b2..b8ee195017d6dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -271,7 +271,7 @@ aliases: mkdir -p ~/react-native/reports/build/ mkdir -p ~/react-native/reports/junit/ mkdir -p ~/react-native/reports/outputs/ - + - &run-objc-ios-tests name: iOS Test Suite command: ./scripts/objc-test-ios.sh test @@ -288,6 +288,18 @@ aliases: name: tvOS End-to-End Test Suite command: node ./scripts/run-ci-e2e-tests.js --tvos --js --retries 3; + - &build-objc-ios-cocoapods-install + name: Test Cocoapods + command: ./scripts/objc-test-ios-cocoapods-install.sh + + - &build-objc-ios-cocoapods-test-app + name: Build Objective-C iOS Test App + command: ./scripts/objc-test-ios-cocoapods.sh + + - &run-objc-ios-cocoapods-tests + name: Objective-C iOS Test Suite + command: ./scripts/objc-test-ios-cocoapods.sh test + defaults: &defaults working_directory: ~/react-native @@ -397,6 +409,25 @@ jobs: - store_test_results: path: ~/react-native/reports/junit + # Runs unit tests on iOS devices - cocoapods flavour + test_ios_cocoapods: + <<: *macos_defaults + dependencies: + pre: + - xcrun instruments -w "iPhone 5s (11.1)" || true + steps: + - attach_workspace: + at: ~/react-native + + - run: *build-objc-ios-cocoapods-install + - run: *build-objc-ios-cocoapods-test-app + - run: *run-objc-ios-cocoapods-tests + + - store_test_results: + path: ~/react-native/reports/junit + - store_artifacts: + path: ~/react-native/reports/junit + # Runs unit tests on tvOS devices test_tvos: <<: *macos_defaults @@ -635,6 +666,7 @@ workflows: filters: *filter-ignore-gh-pages requires: - checkout_code + - test_tvos: filters: *filter-ignore-gh-pages requires: @@ -646,6 +678,12 @@ workflows: requires: - checkout_code + # End-to-end tests + - test_ios_cocoapods: + filters: *filter-ignore-gh-pages + requires: + - checkout_code + # Only runs on PRs analyze: jobs: diff --git a/.gitignore b/.gitignore index 6b290712dbd6d4..84b95d64a84e41 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ package-lock.json /coverage /third-party +/RNTester/Pods diff --git a/RNTester/Podfile b/RNTester/Podfile new file mode 100644 index 00000000000000..0ec107ef2aaede --- /dev/null +++ b/RNTester/Podfile @@ -0,0 +1,51 @@ +source 'https://github.com/CocoaPods/Specs.git' + +use_frameworks! +inhibit_all_warnings! + +platform :ios, '9.0' + +project 'RNTester.xcodeproj' + +def shared_pods + pod 'yoga', :path => '../ReactCommon/yoga' + + # Third party deps podspec link + pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec' + pod 'Folly', :podspec => '../third-party-podspecs/Folly.podspec' + pod 'glog', :podspec => '../third-party-podspecs/glog.podspec' + + pod 'React', :path => '../', :subspecs => [ + 'Core', + 'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43 + 'RCTText', + 'RCTNetwork', + 'RCTWebSocket', # needed for debugging + 'RCTImage', + 'RCTLinkingIOS', + 'RCTActionSheet', + 'RCTAnimation', + 'CxxBridge', + 'RCTPushNotification' + ] +end + +target 'RNTester' do + shared_pods +end + +target 'RNTesterUnitTests' do + shared_pods +end + +target 'RNTester-tvOS' do + shared_pods +end + +target 'RNTester-tvOSUnitTests' do + shared_pods +end + +target 'RNTester-tvOSIntegrationTests' do + shared_pods +end diff --git a/scripts/objc-test-ios-cocoapods-install.sh b/scripts/objc-test-ios-cocoapods-install.sh new file mode 100755 index 00000000000000..f37b1c85de0387 --- /dev/null +++ b/scripts/objc-test-ios-cocoapods-install.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -ex + +# Script used to run iOS tests. +# If not arguments are passed to the script, it will only compile +# the RNTester. +# If the script is called with a single argument "test", we'll +# also run the RNTester integration test (needs JS and packager): +# ./objc-test-ios.sh test + +SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +ROOT=$(dirname "$SCRIPTS") + +cd "$ROOT/RNTester" + +SCHEME="RNTester" +SDK="iphonesimulator" +DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" + +pod install diff --git a/scripts/objc-test-ios-cocoapods.sh b/scripts/objc-test-ios-cocoapods.sh new file mode 100755 index 00000000000000..fdef0d8eef34f5 --- /dev/null +++ b/scripts/objc-test-ios-cocoapods.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -ex + +# Script used to run iOS tests. +# If not arguments are passed to the script, it will only compile +# the RNTester. +# If the script is called with a single argument "test", we'll +# also run the RNTester integration test (needs JS and packager): +# ./objc-test-ios.sh test + +SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +ROOT=$(dirname "$SCRIPTS") + +cd "$ROOT" + +SCHEME="RNTester" +SDK="iphonesimulator" +DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" + +# If there's a "test" argument, pass it to the test script. +. ./scripts/objc-test.sh $1 workspace diff --git a/scripts/objc-test.sh b/scripts/objc-test.sh index f2c0459989daaa..1f0b21b627fab7 100755 --- a/scripts/objc-test.sh +++ b/scripts/objc-test.sh @@ -12,6 +12,12 @@ set -ex SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ROOT=$(dirname $SCRIPTS) +XCODE_PROJECT_PATH="RNTester/RNTester.xcodeproj" + +if [ "$2" = "workspace" ]; then + XCODE_PROJECT_PATH="RNTester/RNTester.xcodeproj" +fi + cd $ROOT # Create cleanup handler @@ -74,7 +80,7 @@ rm temp.bundle # Run tests xcodebuild \ - -project "RNTester/RNTester.xcodeproj" \ + -project $XCODE_PROJECT_PATH \ -scheme $SCHEME \ -sdk $SDK \ -destination "$DESTINATION" \ @@ -85,7 +91,7 @@ else # Don't run tests. No need to pass -destination to xcodebuild. xcodebuild \ - -project "RNTester/RNTester.xcodeproj" \ + -project $XCODE_PROJECT_PATH \ -scheme $SCHEME \ -sdk $SDK \ build