diff --git a/.ado/ado-test-setup.sh b/.ado/ado-test-setup.sh index 0e64adbebb..8f7d11d173 100755 --- a/.ado/ado-test-setup.sh +++ b/.ado/ado-test-setup.sh @@ -3,6 +3,43 @@ set -ex # Script used by the Azure DevOps build agent to start the packager and web socket server +# Wait for the package to start +waitForPackager() { + local -i max_attempts=60 + local -i attempt_num=1 + + until curl -s http://localhost:8081/status | grep "packager-status:running" -q; do + if (( attempt_num == max_attempts )); then + echo "Packager did not respond in time. No more attempts left." + exit 1 + else + (( attempt_num++ )) + echo "Packager did not respond. Retrying for attempt number $attempt_num..." + sleep 1 + fi + done + + echo "Packager is ready!" +} + +waitForWebSocketServer() { + local -i max_attempts=60 + local -i attempt_num=1 + + until curl -s http://localhost:5555 | grep "Upgrade Required" -q; do + if (( attempt_num == max_attempts )); then + echo "WebSocket Server did not respond in time. No more attempts left." + exit 1 + else + (( attempt_num++ )) + echo "WebSocket Server did not respond. Retrying for attempt number $attempt_num..." + sleep 1 + fi + done + + echo "WebSocket Server is ready!" +} + THIS_DIR=$PWD # AppleScript can't be invoked from Azure DevOps Mojave agents until the following ticket is resolved: https://dev.azure.com/mseng/AzureDevOps/_workitems/edit/1513729 @@ -17,8 +54,10 @@ COMMAND="$TMPDIR/launchPackager.command" echo "cd ${THIS_DIR}; export SERVERS_NO_WAIT=1; ./scripts/launchPackager.command" > "$COMMAND" chmod +x "$COMMAND" open "$COMMAND" +waitForPackager COMMAND="$TMPDIR/launchWebSocketServer.command" echo "cd ${THIS_DIR}; export SERVERS_NO_WAIT=1; ./IntegrationTests/launchWebSocketServer.command" > "$COMMAND" chmod +x "$COMMAND" open "$COMMAND" +waitForWebSocketServer diff --git a/.ado/apple-integration.yml b/.ado/apple-integration.yml index 7f53c5f1c6..110c5334ab 100644 --- a/.ado/apple-integration.yml +++ b/.ado/apple-integration.yml @@ -28,7 +28,7 @@ jobs: timeoutInMinutes: 60 cancelTimeoutInMinutes: 5 steps: - - template: templates/apple-node-setup.yml + - template: templates/apple-tools-setup.yml - template: templates/apple-xcode-select.yml parameters: slice_name: $(slice_name) diff --git a/.ado/publish.yml b/.ado/publish.yml index 78fa05fdd7..f5c2e1d69f 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -59,7 +59,7 @@ jobs: displayName: Set dist-tag to v0.x-stable condition: and(ne(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.SourceBranchName'], variables.latestStableBranch)) - - template: templates/apple-node-setup.yml + - template: templates/apple-tools-setup.yml - task: CmdLine@2 displayName: yarn install diff --git a/.ado/templates/apple-job-javascript.yml b/.ado/templates/apple-job-javascript.yml index 9a741d6349..c6be655291 100644 --- a/.ado/templates/apple-job-javascript.yml +++ b/.ado/templates/apple-job-javascript.yml @@ -3,7 +3,7 @@ parameters: xcode_version: '' steps: - - template: apple-node-setup.yml + - template: apple-tools-setup.yml # Task Group: Xcode select proper version - template: apple-xcode-select.yml diff --git a/.ado/templates/apple-job-react-native.yml b/.ado/templates/apple-job-react-native.yml index cd6f11fd31..743c476ee6 100644 --- a/.ado/templates/apple-job-react-native.yml +++ b/.ado/templates/apple-job-react-native.yml @@ -10,11 +10,7 @@ parameters: use_fabric: '' steps: - - script: | - rm -rf $(Build.Repository.LocalPath)/DerivedData - displayName: 'Clean DerivedData' - - - template: apple-node-setup.yml + - template: apple-tools-setup.yml # Task Group: Xcode select proper version - template: apple-xcode-select.yml @@ -32,7 +28,8 @@ steps: inputs: script: | cd packages/rn-tester - pod install + bundle install + bundle exec pod install env: USE_FABRIC: $(use_fabric) @@ -45,21 +42,31 @@ steps: - bash: | echo Preparing the packager for platform $PLATFORM + curl --retry-connrefused --connect-timeout 5 --max-time 10 --retry 10 --retry-delay 5 --retry-max-time 120 "http://localhost:8081/packages/rn-tester/js/RNTesterApp.${PLATFORM}.bundle?platform=${PLATFORM}&dev=true" -o /dev/null + curl --retry-connrefused --connect-timeout 5 --max-time 10 --retry 10 --retry-delay 5 --retry-max-time 120 "http://localhost:8081/packages/rn-tester/js/RNTesterApp.${PLATFORM}.bundle?platform=${PLATFORM}&dev=true&minify=false" -o /dev/null curl --retry-connrefused --connect-timeout 5 --max-time 10 --retry 10 --retry-delay 5 --retry-max-time 120 "http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=${PLATFORM}&dev=true" -o /dev/null + curl --retry-connrefused --connect-timeout 5 --max-time 10 --retry 10 --retry-delay 5 --retry-max-time 120 "http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=${PLATFORM}&dev=true" -o /dev/null env: PLATFORM: ${{ parameters.packager_platform }} displayName: 'curl the packager' - - template: apple-xcode-build.yml - parameters: - xcode_sdk: ${{ parameters.xcode_sdk }} - xcode_configuration: ${{ parameters.xcode_configuration }} - xcode_workspacePath: packages/rn-tester/RNTesterPods.xcworkspace - xcode_scheme: ${{ parameters.xcode_scheme }} - xcode_actions: ${{ parameters.xcode_actions }} - xcode_useXcpretty: true - xcode_destination: ${{ parameters.xcode_destination }} - xcode_extraArgs: -retry-tests-on-failure -test-iterations 2 + - task: Xcode@5 + displayName: 'Xcode ${{ parameters.xcode_actions }} ${{ parameters.xcode_configuration }} ${{ parameters.xcode_sdk }} ${{ parameters.xcode_scheme }}' + inputs: + actions: '${{ parameters.xcode_actions }}' + configuration: ${{ parameters.xcode_configuration }} + sdk: ${{ parameters.xcode_sdk }} + xcWorkspacePath: packages/rn-tester/RNTesterPods.xcworkspace + scheme: ${{ parameters.xcode_scheme }} + xcodeVersion: default + signingOption: auto + packageApp: false + teamId: '$(XCodeSigningMicrosoftTeamID)' + args: '-destination "${{ parameters.xcode_destination }}" ONLY_ACTIVE_ARCH=YES -verbose -derivedDataPath DerivedData ${{ parameters.xcode_extraArgs }}' + exportPath: '$(agent.builddirectory)/output/${{ parameters.xcode_sdk }}/${{ parameters.xcode_configuration }}' + useXcpretty: ${{ parameters.xcode_useXcpretty }} + publishJUnitResults: ${{ parameters.xcode_useXcpretty }} + xctoolReporter: 'junit:test-results.xml' - task: ShellScript@2 displayName: 'Cleanup packager and WebSocket test server' diff --git a/.ado/templates/apple-node-setup.yml b/.ado/templates/apple-node-setup.yml deleted file mode 100644 index 26586dae06..0000000000 --- a/.ado/templates/apple-node-setup.yml +++ /dev/null @@ -1,13 +0,0 @@ -# -# Task Group: Brew install node version -# -steps: - - script: 'brew bundle' - displayName: 'brew bundle' - - # Brew can't access user data for node - - script: sudo chown -R $(whoami) /usr/local/* - displayName: 'fix node permissions' - - - script: brew link node@16 --overwrite --force - displayName: 'ensure node 16' diff --git a/.ado/templates/apple-tools-setup.yml b/.ado/templates/apple-tools-setup.yml new file mode 100644 index 0000000000..603626fa1c --- /dev/null +++ b/.ado/templates/apple-tools-setup.yml @@ -0,0 +1,12 @@ +steps: + - task: NodeTool@0 + inputs: + versionSource: 'fromFile' # 'spec' | 'fromFile'. Required. Source of version. Default: spec. + versionFilePath: '.node-version' + + - task: UseRubyVersion@0 + inputs: + versionSpec: '>= 2.7' + + - script: 'brew bundle' + displayName: 'brew bundle' diff --git a/.ado/templates/apple-xcode-build.yml b/.ado/templates/apple-xcode-build.yml deleted file mode 100644 index c0ee51376b..0000000000 --- a/.ado/templates/apple-xcode-build.yml +++ /dev/null @@ -1,28 +0,0 @@ -parameters: - xcode_sdk: '' - xcode_configuration: '' - xcode_workspacePath: '' - xcode_scheme: '' - xcode_actions: '' - xcode_useXcpretty: false - xcode_destination: '' - xcode_extraArgs: '' - -steps: - - task: Xcode@5 - displayName: 'Xcode ${{ parameters.xcode_actions }} ${{ parameters.xcode_configuration }} ${{ parameters.xcode_sdk }} ${{ parameters.xcode_scheme }}' - inputs: - actions: '${{ parameters.xcode_actions }}' - configuration: ${{ parameters.xcode_configuration }} - sdk: ${{ parameters.xcode_sdk }} - xcWorkspacePath: ${{ parameters.xcode_workspacePath }} - scheme: ${{ parameters.xcode_scheme }} - xcodeVersion: default - signingOption: auto - packageApp: false - teamId: '$(XCodeSigningMicrosoftTeamID)' - args: '-destination "${{ parameters.xcode_destination }}" ONLY_ACTIVE_ARCH=YES -verbose -derivedDataPath DerivedData ${{ parameters.xcode_extraArgs }}' - exportPath: '$(agent.builddirectory)/output/${{ parameters.xcode_sdk }}/${{ parameters.xcode_configuration }}' - useXcpretty: ${{ parameters.xcode_useXcpretty }} - publishJUnitResults: ${{ parameters.xcode_useXcpretty }} - xctoolReporter: 'junit:test-results.xml' diff --git a/.ado/templates/react-native-macos-init.yml b/.ado/templates/react-native-macos-init.yml index 34e414a8e4..e2b8c88e54 100644 --- a/.ado/templates/react-native-macos-init.yml +++ b/.ado/templates/react-native-macos-init.yml @@ -9,7 +9,7 @@ steps: submodules: false # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules persistCredentials: false # set to 'true' to leave the OAuth token in the Git config after the initial fetch - - template: apple-node-setup.yml + - template: apple-tools-setup.yml # First do a build of the local package, since we point the cli at the local files, it needs to be pre-built - task: CmdLine@2 diff --git a/.ado/variables/vars.yml b/.ado/variables/vars.yml index 7f7be99215..77104d18c4 100644 --- a/.ado/variables/vars.yml +++ b/.ado/variables/vars.yml @@ -1,4 +1,4 @@ variables: VmImageApple: internal-macos12 - slice_name: 'Xcode_14.0.1' - xcode_version: '/Applications/Xcode_14.0.1.app' + slice_name: 'Xcode_14.2' + xcode_version: '/Applications/Xcode_14.2.app' diff --git a/Brewfile b/Brewfile index cf32f503c6..fe9137de4c 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1 @@ -brew "node@16" brew "watchman" diff --git a/IntegrationTests/launchWebSocketServer.command b/IntegrationTests/launchWebSocketServer.command new file mode 100755 index 0000000000..003a8abdf9 --- /dev/null +++ b/IntegrationTests/launchWebSocketServer.command @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# [macOS] Keep this file around to help Azure Pipelines run the Websocket integration test + +# Set terminal title +echo -en "\033]0;Web Socket Test Server\a" +clear + +THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +pushd "$THIS_DIR" +./websocket_integration_test_server.js +popd + +echo "Process terminated. Press to close the window" +read