@@ -170,7 +170,7 @@ android_defaults: &android_defaults
170
170
macos_defaults : &macos_defaults
171
171
<< : *defaults
172
172
macos :
173
- xcode : " 10.1 .0"
173
+ xcode : " 10.2 .0"
174
174
175
175
# -------------------------
176
176
# JOBS
@@ -340,12 +340,22 @@ jobs:
340
340
# Runs unit tests on iOS devices
341
341
test_ios :
342
342
<< : *macos_defaults
343
+ environment :
344
+ - REPORTS_DIR : " ./reports"
343
345
steps :
344
346
- attach_workspace :
345
347
at : ~/react-native
346
348
347
349
- run :
348
- name : Boot iPhone Simulator
350
+ name : Print Xcode environment
351
+ command : xcodebuild -version
352
+
353
+ - run :
354
+ name : List available devices
355
+ command : instruments -s devices
356
+
357
+ - run :
358
+ name : Boot iOS Simulator
349
359
command : source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
350
360
351
361
- restore-cache : *restore-brew-cache
@@ -357,8 +367,91 @@ jobs:
357
367
- save-cache : *save-brew-cache
358
368
359
369
- run :
360
- name : iOS Test Suite
361
- command : ./scripts/objc-test-ios.sh test
370
+ name : Start Metro packager
371
+ command : yarn start --nonPersistent --max-workers=1 || echo "Can't start packager automatically"
372
+ background : true
373
+
374
+ - run :
375
+ name : Start WebSocket test server
376
+ command : open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
377
+ background : true
378
+
379
+ - run :
380
+ name : Verify RNTester can be built
381
+ command : |
382
+ source ./scripts/.tests.env
383
+ xcodebuild \
384
+ -project RNTester/RNTester.xcodeproj \
385
+ -scheme RNTester \
386
+ -sdk iphonesimulator \
387
+ -destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
388
+ -UseModernBuildSystem=NO \
389
+ build | \
390
+ xcpretty --report junit --output "$REPORTS_DIR/junit/ios_buiild/results.xml" && \
391
+ exit "${PIPESTATUS[0]}"
392
+
393
+ - run :
394
+ name : Wait for Metro packager
395
+ command : |
396
+ max_attempts=60
397
+ attempt_num=1
398
+ until curl -s http://localhost:8081/status | grep "packager-status:running" -q; do
399
+ if (( attempt_num == max_attempts )); then
400
+ echo "Packager did not respond in time. No more attempts left."
401
+ exit 1
402
+ else
403
+ (( attempt_num++ ))
404
+ echo "Packager did not respond. Retrying for attempt number $attempt_num..."
405
+ sleep 1
406
+ fi
407
+ done
408
+ echo "Packager is ready!"
409
+
410
+ - run :
411
+ name : Preload the RNTesterApp bundles
412
+ command : |
413
+ curl --silent 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true' --output /dev/null
414
+ curl --silent 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true&minify=false' --output /dev/null
415
+ curl --silent 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' --output /dev/null
416
+ curl --silent 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' --output /dev/null
417
+
418
+ - run :
419
+ name : Run RNTester Unit Tests
420
+ command : |
421
+ source ./scripts/.tests.env
422
+ xcodebuild \
423
+ -project RNTester/RNTester.xcodeproj \
424
+ -scheme RNTester \
425
+ -sdk iphonesimulator \
426
+ -destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
427
+ -UseModernBuildSystem=NO \
428
+ -only-testing:RNTesterUnitTests \
429
+ build test | \
430
+ xcpretty --report junit --output "$REPORTS_DIR/junit/ios_unit_tests/results.xml" && \
431
+ exit "${PIPESTATUS[0]}"
432
+
433
+ - run :
434
+ name : Run RNTester Integration Tests
435
+ command : |
436
+ source ./scripts/.tests.env
437
+ xcodebuild \
438
+ -project RNTester/RNTester.xcodeproj \
439
+ -scheme RNTester \
440
+ -sdk iphonesimulator \
441
+ -destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
442
+ -UseModernBuildSystem=NO \
443
+ -only-testing:RNTesterIntegrationTests \
444
+ build test | \
445
+ xcpretty --report junit --output "$REPORTS_DIR/junit/ios_integration_tests/results.xml" && \
446
+ exit "${PIPESTATUS[0]}"
447
+
448
+ - run :
449
+ name : Stop Metro packager and WebSocket test server
450
+ command : |
451
+ # kill whatever is occupying port 8081 (packager)
452
+ lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
453
+ # kill whatever is occupying port 5555 (web socket server)
454
+ lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill
362
455
363
456
- run :
364
457
name : iOS End-to-End Test Suite
0 commit comments