From 63838b937c2621c3c4ef6537edb11eab8b7c04d3 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 19 Mar 2024 10:23:26 +1300 Subject: [PATCH 1/6] Add steps to test Swift pakcage on all supported Apple platforms --- .buildkite/pipeline.yml | 9 +++++++-- .gitignore | 1 + Makefile | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index dc45f574a..b5f254e6a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -23,7 +23,7 @@ steps: - group: ":swift: Swift Wrapper" key: "swift" steps: - - label: ":swift: :darwin: Build and Test" + - label: ":swift: :darwin: Build and Test on {{matrix}}" command: | echo "--- :rust: Installing Rust" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v -y @@ -41,12 +41,17 @@ steps: rustup component add rust-src --toolchain nightly-aarch64-apple-darwin echo "--- :swift: Building + Testing" - make test-swift + make test-swift-{{matrix}} env: IMAGE_ID: xcode-15.2 plugins: *common_plugins agents: queue: mac + matrix: + - macOS + - iOS + - tvOS + - watchOS - label: ":swift: :linux: Build and Test" command: | echo "--- :swift: Building + Testing" diff --git a/.gitignore b/.gitignore index d8d29c126..2f01b0f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ local.properties .build .swiftpm/xcode xcuserdata +DerivedData # Auto-generated Swift Files native/swift/Sources/wordpress-api-wrapper/*.swift diff --git a/Makefile b/Makefile index 9bb224842..fa874e2b4 100644 --- a/Makefile +++ b/Makefile @@ -171,6 +171,20 @@ test-swift-linux-in-docker: swift-linux-library test-swift-darwin: xcframework swift test +test-swift-macOS: test-swift-darwin + +test-swift-iOS: XCODEBUILD_DESTINATION='platform=iOS Simulator,name=iPhone 15,OS=17.2' +test-swift-iOS: xcframework _xcodebuild_test + +test-swift-tvOS: XCODEBUILD_DESTINATION='platform=tvOS Simulator,name=Apple TV,OS=17.2' +test-swift-tvOS: xcframework _xcodebuild_test + +test-swift-watchOS: XCODEBUILD_DESTINATION='platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2' +test-swift-watchOS: xcframework _xcodebuild_test + +_xcodebuild_test: + env NSUnbufferedIO=YES xcodebuild -scheme wordpress -derivedDataPath DerivedData -destination ${XCODEBUILD_DESTINATION} test | xcbeautify + test-android: bindings _test-android publish-android-local: bindings _publish-android-local From cb7a5d117faad650da4bfea6dd1bc211f1356978 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 19 Mar 2024 11:27:56 +1300 Subject: [PATCH 2/6] Fail if simulator doesn't exist in Xcode --- Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index fa874e2b4..7f7e1e846 100644 --- a/Makefile +++ b/Makefile @@ -173,17 +173,35 @@ test-swift-darwin: xcframework test-swift-macOS: test-swift-darwin -test-swift-iOS: XCODEBUILD_DESTINATION='platform=iOS Simulator,name=iPhone 15,OS=17.2' +test-swift-iOS: XCODEBUILD_PLATFORM='iOS-17-2' test-swift-iOS: xcframework _xcodebuild_test -test-swift-tvOS: XCODEBUILD_DESTINATION='platform=tvOS Simulator,name=Apple TV,OS=17.2' +test-swift-tvOS: XCODEBUILD_PLATFORM='tvOS-17-2' test-swift-tvOS: xcframework _xcodebuild_test -test-swift-watchOS: XCODEBUILD_DESTINATION='platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2' +test-swift-watchOS: XCODEBUILD_PLATFORM='watchOS-10-2' test-swift-watchOS: xcframework _xcodebuild_test +# Find a simulator for the given platform. +# Requires a parameter whose value is the os and version part of simulator +# runtime identifier returned by `xcrun simctl list runtimes`. +_xcodebuild_test_simulator_id = $(shell \ + xcrun simctl list --json devices available \ + | jq -re '.devices."com.apple.CoreSimulator.SimRuntime.$(1)" | last.udid' \ +) + +_xcodebuild_test: XCODEBUILD_DEVICE_ID='$(call _xcodebuild_test_simulator_id,${XCODEBUILD_PLATFORM})' _xcodebuild_test: - env NSUnbufferedIO=YES xcodebuild -scheme wordpress -derivedDataPath DerivedData -destination ${XCODEBUILD_DESTINATION} test | xcbeautify + ifeq (${XCODEBUILD_DEVICE_ID}, "null") + $(error No simulator found for platform ${XCODEBUILD_PLATFORM}) + endif + env NSUnbufferedIO=YES \ + xcodebuild \ + -scheme wordpress \ + -derivedDataPath DerivedData \ + -destination "id=$(XCODEBUILD_DEVICE_ID)" \ + test \ + | xcbeautify test-android: bindings _test-android From c41a8a9d3f5b9aa751d64e256d63f8671523499c Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 19 Mar 2024 18:49:32 +1300 Subject: [PATCH 3/6] Move xcodebuild command into a shell script --- Makefile | 37 ++++++++----------------------------- scripts/xcodebuild-test.sh | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 29 deletions(-) create mode 100755 scripts/xcodebuild-test.sh diff --git a/Makefile b/Makefile index 7f7e1e846..e1cf65395 100644 --- a/Makefile +++ b/Makefile @@ -173,35 +173,14 @@ test-swift-darwin: xcframework test-swift-macOS: test-swift-darwin -test-swift-iOS: XCODEBUILD_PLATFORM='iOS-17-2' -test-swift-iOS: xcframework _xcodebuild_test - -test-swift-tvOS: XCODEBUILD_PLATFORM='tvOS-17-2' -test-swift-tvOS: xcframework _xcodebuild_test - -test-swift-watchOS: XCODEBUILD_PLATFORM='watchOS-10-2' -test-swift-watchOS: xcframework _xcodebuild_test - -# Find a simulator for the given platform. -# Requires a parameter whose value is the os and version part of simulator -# runtime identifier returned by `xcrun simctl list runtimes`. -_xcodebuild_test_simulator_id = $(shell \ - xcrun simctl list --json devices available \ - | jq -re '.devices."com.apple.CoreSimulator.SimRuntime.$(1)" | last.udid' \ -) - -_xcodebuild_test: XCODEBUILD_DEVICE_ID='$(call _xcodebuild_test_simulator_id,${XCODEBUILD_PLATFORM})' -_xcodebuild_test: - ifeq (${XCODEBUILD_DEVICE_ID}, "null") - $(error No simulator found for platform ${XCODEBUILD_PLATFORM}) - endif - env NSUnbufferedIO=YES \ - xcodebuild \ - -scheme wordpress \ - -derivedDataPath DerivedData \ - -destination "id=$(XCODEBUILD_DEVICE_ID)" \ - test \ - | xcbeautify +test-swift-iOS: xcframework + scripts/xcodebuild-test.sh iOS-17-2 + +test-swift-tvOS: xcframework + scripts/xcodebuild-test.sh tvOS-17-2 + +test-swift-watchOS: xcframework + scripts/xcodebuild-test.sh watchOS-10-2 test-android: bindings _test-android diff --git a/scripts/xcodebuild-test.sh b/scripts/xcodebuild-test.sh new file mode 100755 index 000000000..b9bf1a7e0 --- /dev/null +++ b/scripts/xcodebuild-test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -euo pipefail + +# Requires a parameter whose value is the os and version part of simulator +# runtime identifier returned by `xcrun simctl list runtimes`. +platform=$1 + +device_id=$(xcrun simctl list --json devices available | jq -re ".devices.\"com.apple.CoreSimulator.SimRuntime.${platform}\" | last.udid") + +export NSUnbufferedIO=YES + +xcodebuild \ + -scheme wordpress \ + -derivedDataPath DerivedData \ + -destination "id=${device_id}" \ + test \ + | xcbeautify From 12783a23c3ee5fb2d66a2196ee58aeba1b84cc5d Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 19 Mar 2024 18:56:20 +1300 Subject: [PATCH 4/6] Use Xcode 15.3 --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b5f254e6a..880393dd9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -43,7 +43,7 @@ steps: echo "--- :swift: Building + Testing" make test-swift-{{matrix}} env: - IMAGE_ID: xcode-15.2 + IMAGE_ID: xcode-15.3 plugins: *common_plugins agents: queue: mac From 4653fb2685314a5e6ace65d6d0bc79407de66257 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Tue, 19 Mar 2024 19:05:51 +1300 Subject: [PATCH 5/6] Update iOS, tvOS, watchOS simulator versions --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e1cf65395..1d8e622f3 100644 --- a/Makefile +++ b/Makefile @@ -174,13 +174,13 @@ test-swift-darwin: xcframework test-swift-macOS: test-swift-darwin test-swift-iOS: xcframework - scripts/xcodebuild-test.sh iOS-17-2 + scripts/xcodebuild-test.sh iOS-17-4 test-swift-tvOS: xcframework - scripts/xcodebuild-test.sh tvOS-17-2 + scripts/xcodebuild-test.sh tvOS-17-4 test-swift-watchOS: xcframework - scripts/xcodebuild-test.sh watchOS-10-2 + scripts/xcodebuild-test.sh watchOS-10-4 test-android: bindings _test-android From febdc90263619a8e0d51777db2a62b14d0187865 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Wed, 20 Mar 2024 09:39:20 +1300 Subject: [PATCH 6/6] Add a workaround for simulator issues in the Xcode 15.3 image --- .buildkite/pipeline.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 880393dd9..c09ec0645 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -40,6 +40,9 @@ steps: rustup toolchain install nightly rustup component add rust-src --toolchain nightly-aarch64-apple-darwin + echo "--- 🧹 Clearing simulator cache" + rm -rf ~/Library/Developer/CoreSimulator/Caches + echo "--- :swift: Building + Testing" make test-swift-{{matrix}} env: