From 7d045fd5e5146f2aabac8cb87ca35d5a797b5f5f Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 23 Aug 2021 15:44:25 +1000 Subject: [PATCH 1/6] Configure ScreenObject shared scheme to run the UI tests --- .../xcshareddata/xcschemes/ScreenObject.xcscheme | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ScreenObject.xcodeproj/xcshareddata/xcschemes/ScreenObject.xcscheme b/ScreenObject.xcodeproj/xcshareddata/xcschemes/ScreenObject.xcscheme index cd1b7da..30421a9 100644 --- a/ScreenObject.xcodeproj/xcshareddata/xcschemes/ScreenObject.xcscheme +++ b/ScreenObject.xcodeproj/xcshareddata/xcschemes/ScreenObject.xcscheme @@ -28,6 +28,16 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + Date: Mon, 23 Aug 2021 15:45:34 +1000 Subject: [PATCH 2/6] Add Buildkite pipeline running the tests --- .buildkite/pipeline.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .buildkite/pipeline.yml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 0000000..36ed1e7 --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,15 @@ +# Nodes with values to reuse in the pipeline. +common_params: + env: &common_env + IMAGE_ID: xcode-12.5.1 + +steps: + - label: "🧪 Build and Test (iPhone 12 Simulator)" + command: | + xcodebuild clean test \ + -project 'ScreenObject.xcodeproj' \ + -scheme 'ScreenObject' \ + -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.5' + env: *common_env + agents: + queue: 'mac' From ef19a80bce2349e2395fcb7ace9742c036715fd3 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 23 Aug 2021 16:41:50 +1000 Subject: [PATCH 3/6] Add parallel step to build and test on iPad Pro --- .buildkite/pipeline.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 36ed1e7..8a6d0de 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -13,3 +13,13 @@ steps: env: *common_env agents: queue: 'mac' + + - label: "🧪 Build and Test (iPad Pro (12.9-inch) (5th generation) Simulator)" + command: | + xcodebuild clean test \ + -project 'ScreenObject.xcodeproj' \ + -scheme 'ScreenObject' \ + -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation),OS=14.5' + env: *common_env + agents: + queue: 'mac' From 2c8ff495faf265c1a3ac387c50b964ed63ec6395 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 25 Aug 2021 11:24:17 +1000 Subject: [PATCH 4/6] Extract syntax to run tests in Buildkite command --- .buildkite/commands/run-tests.sh | 8 ++++++++ .buildkite/pipeline.yml | 12 ++---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100755 .buildkite/commands/run-tests.sh diff --git a/.buildkite/commands/run-tests.sh b/.buildkite/commands/run-tests.sh new file mode 100755 index 0000000..aa853cb --- /dev/null +++ b/.buildkite/commands/run-tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash -eu + +SIMULATOR_NAME=$1 + +xcodebuild clean test \ + -project 'ScreenObject.xcodeproj' \ + -scheme 'ScreenObject' \ + -destination "platform=iOS Simulator,name=$SIMULATOR_NAME,OS=14.5" diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 8a6d0de..0d2c3e9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,21 +5,13 @@ common_params: steps: - label: "🧪 Build and Test (iPhone 12 Simulator)" - command: | - xcodebuild clean test \ - -project 'ScreenObject.xcodeproj' \ - -scheme 'ScreenObject' \ - -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.5' + command: .buildkite/commands/run-tests.sh 'iPhone 12' env: *common_env agents: queue: 'mac' - label: "🧪 Build and Test (iPad Pro (12.9-inch) (5th generation) Simulator)" - command: | - xcodebuild clean test \ - -project 'ScreenObject.xcodeproj' \ - -scheme 'ScreenObject' \ - -destination 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (5th generation),OS=14.5' + command: .buildkite/commands/run-tests.sh 'iPad Pro (12.9-inch) (5th generation)' env: *common_env agents: queue: 'mac' From 2bebe59557768abe26490f57fce290848b5c8c95 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 25 Aug 2021 11:39:01 +1000 Subject: [PATCH 5/6] DRY Buildkite pipeline syntax --- .buildkite/pipeline.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0d2c3e9..4d7c872 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,17 +1,11 @@ -# Nodes with values to reuse in the pipeline. -common_params: - env: &common_env - IMAGE_ID: xcode-12.5.1 +env: + IMAGE_ID: xcode-12.5.1 +agents: + queue: 'mac' steps: - label: "🧪 Build and Test (iPhone 12 Simulator)" command: .buildkite/commands/run-tests.sh 'iPhone 12' - env: *common_env - agents: - queue: 'mac' - label: "🧪 Build and Test (iPad Pro (12.9-inch) (5th generation) Simulator)" command: .buildkite/commands/run-tests.sh 'iPad Pro (12.9-inch) (5th generation)' - env: *common_env - agents: - queue: 'mac' From a0680cde16cc9ce72da58c26e08bbd4f2af681c7 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 26 Aug 2021 13:01:03 +1000 Subject: [PATCH 6/6] Add note on the hardcoded iOS version in the Builkite tests command See also: https://github.com/Automattic/XCUITestHelpers/pull/4#discussion_r695601359 --- .buildkite/commands/run-tests.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.buildkite/commands/run-tests.sh b/.buildkite/commands/run-tests.sh index aa853cb..ad2d215 100755 --- a/.buildkite/commands/run-tests.sh +++ b/.buildkite/commands/run-tests.sh @@ -1,5 +1,18 @@ #!/bin/bash -eu +# Notice that: +# +# - We are using raw `xcodebuild` without extra tooling such as Fastlane, +# `xcpretty`, or `xcbeautify`. This is an intentional compromise to keep the +# setup lean, as adding any of those would require extras in CI such as +# chating for what, right now, looks like merely a log readability gain. +# +# - The iOS Simulator version is hardcoded in the command call, unlike the +# Simulator device, so we have a single source of truth. The downside is that +# the syntax in the pipeline is less clear: a reader might as where's the +# iOS version set. As long as we only need to test against the latest iOS +# version, that seems like a reasonable tradeoff to make it easier to move to +# newer versions as they are released. SIMULATOR_NAME=$1 xcodebuild clean test \