-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT MERGE] Introduce swift version testing #513
base: trunk
Are you sure you want to change the base?
Changes from 36 commits
ec040d9
7c3bdac
daefb44
c5f84a6
7d0a0e3
4aeaf93
a280108
4260fb5
6d0dbe6
495b8c1
7877527
0f95d01
05025f3
c51d45a
9132be5
5f8e661
a4acef4
e34d6e0
b2c7460
a90ec77
c7d7437
fdd0a52
c094892
5c7946c
d6eba0c
612b281
6b75175
f14bc5b
070180d
fb4efe8
98b21fa
541a4c4
3388ffe
15fbebf
b00cc5d
4482a62
abb0aec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
agents: | ||
queue: "mac" | ||
env: | ||
IMAGE_ID: $IMAGE_ID | ||
IMAGE_ID: $CURRENT_IMAGE_ID | ||
|
||
steps: | ||
################# | ||
|
@@ -21,20 +21,56 @@ steps: | |
################# | ||
# Build and Test | ||
################# | ||
- label: "📦 Build and Test Swift Package" | ||
key: "test" | ||
command: | | ||
validate_swift_package | ||
plugins: [$CI_TOOLKIT] | ||
- group: "📦 Build and Test Swift Package" | ||
steps: | ||
- label: "📦 Build and Test Swift Package (Swift {{matrix.swift_version}})" | ||
key: "test" | ||
command: | | ||
validate_swift_package test device_model:"{{matrix.device_model}}" os:"{{matrix.device_os}}" | ||
plugins: [$CI_TOOLKIT] | ||
env: | ||
IMAGE_ID: "{{matrix.image_id}}" | ||
matrix: | ||
setup: # Specify the current version of Xcode, Swift, a device, and the required version of iOS | ||
image_id: $CURRENT_IMAGE_ID | ||
swift_version: $CURRENT_SWIFT_VERSION | ||
device_model: $CURRENT_DEVICE | ||
device_os: $CURRENT_OS | ||
adjustments: # Specify additional versions of Xcode, Swift, a device, and the required version of iOS | ||
- with: # Swift 5.9 | ||
image_id: $SWIFT_5_9_IMAGE_ID | ||
swift_version: $SWIFT_5_9_VERSION | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given how YAML works, I expect that if If that's the case, and to prevent YAML from interpreting this as a float even if it looks like one and instead force it to interpret it as a string, you have two options:
The first option is probably easier to understand (and less surprising to people who don't know some advanced YAML techniques likes I'd suggest to apply the same rule (i.e. quoted strings) for other values as well, especially |
||
device_model: $SWIFT_5_9_DEVICE | ||
device_os: $SWIFT_5_9_OS | ||
- with: # Swift 6.0 | ||
image_id: $SWIFT_6_0_IMAGE_ID | ||
swift_version: $SWIFT_6_0_VERSION | ||
device_model: $SWIFT_6_0_DEVICE | ||
device_os: $SWIFT_6_0_OS | ||
|
||
################### | ||
# Validate Podspec | ||
################### | ||
- label: "🔬 Validate Podspecs" | ||
key: "validate" | ||
command: | | ||
.buildkite/commands/validate-pods.sh | ||
plugins: [$CI_TOOLKIT] | ||
- group: "🔬 Validate Podspecs" | ||
steps: | ||
- label: "🔬 Validate Podspecs (Swift {{matrix.swift_version}})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, changing the name of the label will impact the name of the status check reported in GitHub PR that the |
||
key: "validate" | ||
command: | | ||
.buildkite/commands/validate-pods.sh | ||
plugins: [$CI_TOOLKIT] | ||
env: | ||
IMAGE_ID: "{{matrix.image_id}}" | ||
matrix: | ||
setup: # Specify the current version of Xcode and Swift | ||
image_id: $CURRENT_IMAGE_ID | ||
swift_version: $CURRENT_SWIFT_VERSION | ||
adjustments: # Specify additional versions of Xcode and Swift | ||
- with: | ||
image_id: $SWIFT_5_9_IMAGE_ID | ||
swift_version: $SWIFT_5_9_VERSION | ||
- with: | ||
image_id: $SWIFT_6_0_IMAGE_ID | ||
swift_version: $SWIFT_6_0_VERSION | ||
|
||
####################### | ||
# Publish the Podspecs (if we're building a tag) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,29 @@ | |
# This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used | ||
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. | ||
|
||
export IMAGE_ID=$(echo "xcode-$(cat .xcode-version)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only place that uses the But for now, we don't do that, so we don't need this abstraction. |
||
|
||
export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.2.2" | ||
|
||
## Supported versions of Swift | ||
# Swift 6.0 | ||
export SWIFT_6_0_IMAGE_ID="xcode-16.0-v7" | ||
export SWIFT_6_0_VERSION="6.0" | ||
export SWIFT_6_0_DEVICE="default" # Use the default value in Fastlane | ||
export SWIFT_6_0_OS="18.0" | ||
|
||
# Swift 5.10 | ||
export SWIFT_5_10_IMAGE_ID="xcode-15.4" | ||
export SWIFT_5_10_VERSION="5.10" | ||
export SWIFT_5_10_DEVICE="default" | ||
export SWIFT_5_10_OS="17.5" | ||
|
||
# Swift 5.9 | ||
export SWIFT_5_9_IMAGE_ID="xcode-15.2-xl" | ||
export SWIFT_5_9_VERSION="5.9" | ||
export SWIFT_5_9_DEVICE="default" # Use the default value in Fastlane | ||
export SWIFT_5_9_OS="17.2" | ||
|
||
# Current Development Environment | ||
export CURRENT_IMAGE_ID=$SWIFT_5_10_IMAGE_ID | ||
export CURRENT_SWIFT_VERSION=$SWIFT_5_10_VERSION | ||
export CURRENT_DEVICE=$SWIFT_5_10_DEVICE | ||
export CURRENT_OS="default" # Use the default value in Fastlane | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels a little more self-documenting and clear. I also added the Swift version, and used it in the |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,5 @@ | |
} | ||
} | ||
], | ||
"version" : 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change (to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: In addition to the {
+ "originHash" : "85a761808437c26b26a29368f9cc9aa509cdd039f95eff656309c72fa6ff2557"
# ...
+ "version" : 3
} That might be meaningful only in |
||
"version" : 2 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ import Foundation | |
|
||
func getAssociatedObject<T>(_ object: Any, _ key: UnsafeRawPointer) -> T? { | ||
if #available(iOS 14, *) { // swift 5.3 fixed this issue (https://github.com/apple/swift/issues/46456) | ||
objc_getAssociatedObject(object, key) as? T | ||
// swiftformat:disable:next --redundantReturn | ||
return objc_getAssociatedObject(object, key) as? T | ||
} else { | ||
objc_getAssociatedObject(object, key) as AnyObject as? T | ||
// swiftformat:disable:next --redundantReturn | ||
return objc_getAssociatedObject(object, key) as AnyObject as? T | ||
} | ||
Comment on lines
+5
to
10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixed an issue with Swift 5.9. With the implicit |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
default_platform(:ios) | ||
|
||
OS = '17.5' | ||
IPHONE_DEVICE = "iPhone SE (3rd generation) (#{OS})".freeze | ||
IPHONE_MODEL = 'iPhone SE (3rd generation)' | ||
IPHONE_DEVICE = "#{IPHONE_MODEL} (#{OS})".freeze | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I broke this up into two constants because we often share the model across multiple versions of Xcode (and therefore, across multiple versions of iOS). |
||
|
||
PROJECT_ROOT_FOLDER = File.join(File.dirname(File.expand_path(__dir__)), 'Demo') | ||
BUILD_FOLDER = File.join(__dir__, '.build') | ||
|
@@ -50,12 +51,15 @@ end | |
|
||
platform :ios do | ||
desc 'Builds the project and runs tests' | ||
lane :test do | ||
lane :test do |device_model: "default", os: "default"| | ||
device_model = IPHONE_MODEL if device_model == "default" | ||
os = OS if os == "default" | ||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love having to use "default" strings like this. The problem is that I'm open to suggestions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah tbh when I first read the I'd also love if it was possible to provide a |
||
|
||
run_tests( | ||
package_path: '.', | ||
scheme: 'Gravatar-Package', | ||
xcargs: COMMON_XCARGS, | ||
device: IPHONE_DEVICE, | ||
device: "#{device_model} (#{os})", | ||
prelaunch_simulator: true, | ||
clean: true, | ||
buildlog_path: LOGS_FOLDER, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that changing the label of those jobs will have the side-effect of changing the name of the commit status event reported on the GitHub PR.
This PR targets
release/3.0.0
which is not a protected branch, so doesn't have any required check, so this doesn't show here. But for PRs targetingtrunk
, the branch protection settings requires thebuildkite/gravatar-sdk-ios/build-and-test-swift-package
check to pass… and with the new names of those CI jobs, such a check with that exact name won't exist anymore.So this means that once this PR lands and then is propagated to
trunk
, you'll have to remember to update the branch protection settings of thetrunk
branch in GitHub to stop requiring the old check names and instead add the new ones instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the names of those checks emitted to GitHub are derived by Buildkite because we have the following settings set on the
gravatar-ios-sdk
pipeline in Buildkite:If you don't like the names generated by Buildkite and find they are too verbose, we can disable this option (via our Infrastructure-as-Code setup for this pipeline and instead add the appropriate
notify: { github_commit_status: { context: "custom name" } }
entry to each of the step we want a GitHub status to be reported for.The only "drawback" is that if we disable that setting for Buildkite to generate the commit statuses for us, we'll have to add the
notify
entry for every single step manually (i.e. we can't just customize some of them but let buildkite generate the status for the others). But that's still the approach we've tended to go towards in other pipelines lately (see: paaHJt-78h-p2), because custom status names are so much nicer to read in the UI of a Github PR than the generated oneLet us know if you want to go that route. You can already start adding the
notify: …
blocks for each step to provide custom status names, and we can take care of disabling the ones generated by Buildkite once the custom ones fromnotify:
land intrunk
and we update the branch protection settings in GitHub accordingly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, thank you!
Excellent, good idea.