Skip to content

Commit

Permalink
feat: Make models Sendable (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Oct 28, 2024
1 parent 3a2053e commit 1eb2d18
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 50 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ env:
jobs:
apple:
runs-on: ${{ matrix.runner }}
env:
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
strategy:
fail-fast: false
matrix:
Expand All @@ -21,7 +19,7 @@ jobs:
- macos-14
xcode:
- Xcode_15.2
- Xcode_16.0
- Xcode_16
destination:
- 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
- 'platform=iOS Simulator,OS=18.0,name=iPhone 15'
Expand All @@ -33,17 +31,17 @@ jobs:
exclude:
# Don't run old macOS with new Xcode
- runner: macos-13
xcode: Xcode_16.0
xcode: Xcode_16
# Don't run new macOS with old Xcode
- runner: macos-14
xcode: Xcode_15.2
# Don't run old simulators with new Xcode
- destination: 'platform=tvOS Simulator,OS=17.2,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_16.0
xcode: Xcode_16
- destination: 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
xcode: Xcode_16.0
xcode: Xcode_16
- destination: 'platform=visionOS Simulator,OS=1.0,name=Apple Vision Pro'
xcode: Xcode_16.0
xcode: Xcode_16
# Don't run new simulators with old Xcode
- destination: 'platform=tvOS Simulator,OS=18.0,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_15.2
Expand All @@ -52,6 +50,8 @@ jobs:
- destination: 'platform=visionOS Simulator,OS=2.0,name=Apple Vision Pro'
xcode: Xcode_15.2
steps:
- name: Configure Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
- name: Install visionOS 2.0 sim
if: ${{ matrix.destination == 'platform=visionOS Simulator,OS=2.0,name=Apple Vision Pro' }}
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ permissions:
jobs:
apple:
runs-on: ${{ matrix.runner }}
env:
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
strategy:
fail-fast: false
matrix:
Expand All @@ -24,7 +22,7 @@ jobs:
- macos-14
xcode:
- Xcode_15.2
- Xcode_16.0
- Xcode_16
destination:
- 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
- 'platform=iOS Simulator,OS=18.0,name=iPhone 15'
Expand All @@ -36,17 +34,17 @@ jobs:
exclude:
# Don't run old macOS with new Xcode
- runner: macos-13
xcode: Xcode_16.0
xcode: Xcode_16
# Don't run new macOS with old Xcode
- runner: macos-14
xcode: Xcode_15.2
# Don't run old simulators with new Xcode
- destination: 'platform=tvOS Simulator,OS=17.2,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_16.0
xcode: Xcode_16
- destination: 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
xcode: Xcode_16.0
xcode: Xcode_16
- destination: 'platform=visionOS Simulator,OS=1.0,name=Apple Vision Pro'
xcode: Xcode_16.0
xcode: Xcode_16
# Don't run new simulators with old Xcode
- destination: 'platform=tvOS Simulator,OS=18.0,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_15.2
Expand All @@ -55,6 +53,8 @@ jobs:
- destination: 'platform=visionOS Simulator,OS=2.0,name=Apple Vision Pro'
xcode: Xcode_15.2
steps:
- name: Configure Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
- name: Install visionOS 2.0 sim
if: ${{ matrix.destination == 'platform=visionOS Simulator,OS=2.0,name=Apple Vision Pro' }}
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import Waiters
import SmithyWaitersAPI

// Convenience test-helper methods for testing acceptor matches

extension WaiterConfiguration.Acceptor.Match: Equatable where Input: Equatable, Output: Equatable {
//
// Use of fully-qualified type names in this extension suppresses the Swift 6
// "retroactive conformance" warning in a manner compatible with Swift 5.
// See: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0364-retroactive-conformance-warning.md#source-compatibility
extension SmithyWaitersAPI.WaiterConfiguration.Acceptor.Match: Swift.Equatable where Input: Swift.Equatable, Output: Swift.Equatable {

public static func == (
lhs: WaiterConfiguration<Input, Output>.Acceptor.Match,
Expand Down Expand Up @@ -42,7 +45,11 @@ extension WaiterConfiguration.Acceptor.Match: Equatable where Input: Equatable,
}

// Allows for the use of a string as an Error, for easy test validation & easy-to-read tests.
extension String: Error {
//
// Use of fully-qualified type names in this extension suppresses the Swift 6
// "retroactive conformance" warning in a manner compatible with Swift 5.
// See: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0364-retroactive-conformance-warning.md#source-compatibility
extension Swift.String: Swift.Error {
var localizedString: String? { self }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ class S3ExpiresTest {
val context = setupTests("s3-expires.smithy", "com.amazonaws.s3#S3", "S3")
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooOutput.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents =
"""
public struct FooOutput {
public var expires: Swift.String?
public var payload1: Swift.String?
public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
""".trimIndent()
val expectedContents = """
public struct FooOutput: Swift.Sendable {
public var expires: Swift.String?
public var payload1: Swift.String?
public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
"""
contents.shouldContainOnlyOnce(expectedContents)
}

Expand All @@ -39,22 +38,21 @@ class S3ExpiresTest {
val context = setupTests("s3-expires.smithy", "com.amazonaws.s3#S3", "S3")
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooInput.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents =
"""
public struct FooInput {
public var expires: Swift.String?
public var payload1: Swift.String?
public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
""".trimIndent()
val expectedContents = """
public struct FooInput: Swift.Sendable {
public var expires: Swift.String?
public var payload1: Swift.String?
public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
"""
contents.shouldContainOnlyOnce(expectedContents)
}

Expand All @@ -64,7 +62,7 @@ class S3ExpiresTest {
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooOutput.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents = """
public struct FooOutput {
public struct FooOutput: Swift.Sendable {
public var expires: Foundation.Date?
public var payload1: Swift.String?
Expand Down

0 comments on commit 1eb2d18

Please sign in to comment.