diff --git a/.travis.yml b/.travis.yml index 1729ddb109..5f0caaabc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: objective-c -osx_image: xcode8 +osx_image: xcode8.2 install: - mkdir -p /Users/travis/build/facebook/.nvm @@ -18,6 +18,7 @@ install: script: - if [[ "$TEST_TYPE" = objc-ios ]]; then travis_retry travis_wait ./scripts/objc-test-ios.sh; fi + - if [[ "$TEST_TYPE" = objc-tvos ]]; then travis_retry travis_wait ./scripts/objc-test-tvos.sh; fi - if [[ "$TEST_TYPE" = e2e-objc ]]; then node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; fi - if [[ ( "$TEST_TYPE" = podspecs ) && ( "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then gem install cocoapods && ./scripts/process-podspecs.sh; fi @@ -30,6 +31,7 @@ env: - TEST_TYPE=objc-ios - TEST_TYPE=podspecs - TEST_TYPE=e2e-objc + - TEST_TYPE=objc-tvos branches: only: @@ -40,6 +42,7 @@ notifications: email: recipients: - mkonicek@fb.com + - douglowder@mac.com # Doug Lowder built and maintains Apple TV specific code and wants to be notified about tvOS failures. - eloy@artsy.net # Eloy DurĂ¡n maintains the podspecs test and wants to be notified about failures. on_failure: change on_success: change diff --git a/scripts/objc-test-ios.sh b/scripts/objc-test-ios.sh index f6db784d99..f0f1148fb9 100755 --- a/scripts/objc-test-ios.sh +++ b/scripts/objc-test-ios.sh @@ -6,11 +6,45 @@ ROOT=$(dirname $SCRIPTS) cd $ROOT -XCODE_PROJECT="Examples/UIExplorer/UIExplorer.xcodeproj" -XCODE_SCHEME="UIExplorer" -XCODE_SDK="iphonesimulator" -if [ -z ${XCODE_DESTINATION+x} ]; then - XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=10.0" -fi +# Create cleanup handler +function cleanup { + EXIT_CODE=$? + set +e -. ./scripts/objc-test.sh + if [ $EXIT_CODE -ne 0 ]; + then + WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log + [ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS + fi + # kill whatever is occupying port 8081 (packager) + lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill + # kill whatever is occupying port 5555 (web socket server) + lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill +} +trap cleanup EXIT + +# Start the packager +open "./packager/launchPackager.command" || echo "Can't start packager automatically" +open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically" + +# Preload the UIExplorerApp bundle for better performance in integration tests +sleep 20 +curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle + +# TODO: We use xcodebuild because xctool would stall when collecting info about +# the tests before running them. Switch back when this issue with xctool has +# been resolved. +xcodebuild \ + -project "Examples/UIExplorer/UIExplorer.xcodeproj" \ + -scheme "UIExplorer" \ + -sdk "iphonesimulator" \ + -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.1" \ + build test + diff --git a/scripts/objc-test-tvos.sh b/scripts/objc-test-tvos.sh index 44201a09db..2266a5ba6f 100755 --- a/scripts/objc-test-tvos.sh +++ b/scripts/objc-test-tvos.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -ex SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) @@ -7,11 +6,63 @@ ROOT=$(dirname $SCRIPTS) cd $ROOT -XCODE_PROJECT="Examples/UIExplorer/UIExplorer.xcodeproj" -XCODE_SCHEME="UIExplorer-tvOS" -XCODE_SDK="appletvsimulator" -if [ -z ${XCODE_DESTINATION+x} ]; then - XCODE_DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0" -fi +# Create cleanup handler +function cleanup { + EXIT_CODE=$? + set +e -. ./scripts/objc-test.sh + if [ $EXIT_CODE -ne 0 ]; + then + WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log + [ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS + fi + # kill whatever is occupying port 8081 (packager) + lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill + # kill whatever is occupying port 5555 (web socket server) + lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill +} +trap cleanup EXIT + +# If first argument is "test", actually start the packager and run tests as in the iOS script +# Otherwise, just build UIExplorer for tvOS and exit + +if [ "$1" = "test" ]; +then + +# Start the packager +open "./packager/launchPackager.command" || echo "Can't start packager automatically" +open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically" + +# Preload the UIExplorerApp bundle for better performance in integration tests +sleep 20 +curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle +curl 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' -o temp.bundle +rm temp.bundle + +# Build and test for tvOS +# TODO: We use xcodebuild because xctool would stall when collecting info about +# the tests before running them. Switch back when this issue with xctool has +# been resolved. +xcodebuild \ + -project "Examples/UIExplorer/UIExplorer.xcodeproj" \ + -scheme "UIExplorer-tvOS" \ + -sdk "appletvsimulator" \ + -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.1" \ + build test + +else + +# Build only (no test) for tvOS, to make sure there are no missing files +xcodebuild \ + -project "Examples/UIExplorer/UIExplorer.xcodeproj" \ + -scheme "UIExplorer-tvOS" \ + -sdk "appletvsimulator" \ + -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.1" \ + build + +fi diff --git a/scripts/objc-test.sh b/scripts/objc-test.sh deleted file mode 100755 index 571efc842c..0000000000 --- a/scripts/objc-test.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# This script contains common code to be run from scripts/objc-test-ios.sh or scripts/objc-test-tvos.sh - -# Start the packager and preload the UIExplorerApp bundle for better performance in integration tests -open "./packager/launchPackager.command" || echo "Can't start packager automatically" -open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically" -sleep 20 -curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true' -o temp.bundle -rm temp.bundle -curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle -rm temp.bundle -curl 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' -o temp.bundle -rm temp.bundle -curl 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' -o temp.bundle -rm temp.bundle - -function cleanup { - EXIT_CODE=$? - set +e - - if [ $EXIT_CODE -ne 0 ]; - then - WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log - [ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS - fi - # kill whatever is occupying port 8081 (packager) - lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill - # kill whatever is occupying port 5555 (web socket server) - lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill -} -trap cleanup EXIT - -if [ -z "$XCODE_BUILD_STEPS" ]; then - XCODE_BUILD_STEPS="build test" -fi -# TODO: We use xcodebuild because xctool would stall when collecting info about -# the tests before running them. Switch back when this issue with xctool has -# been resolved. -if [ -n "$XCODE_DESTINATION" ]; then - xcodebuild \ - -project $XCODE_PROJECT \ - -scheme $XCODE_SCHEME \ - -sdk $XCODE_SDK \ - -destination "$XCODE_DESTINATION" \ - $XCODE_BUILD_STEPS -else - xcodebuild \ - -project $XCODE_PROJECT \ - -scheme $XCODE_SCHEME \ - -sdk $XCODE_SDK \ - $XCODE_BUILD_STEPS -fi