Skip to content

feat: Add Swift 6 language mode support #1916

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 0 additions & 15 deletions .github/workflows/continuous-integration.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore these changes

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
- macos-14
- macos-15
xcode:
- Xcode_15.2
- Xcode_16.1
destination:
- 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
Expand All @@ -32,26 +31,13 @@ jobs:
- 'platform=visionOS Simulator,OS=2.1,name=Apple Vision Pro'
- 'platform=macOS'
exclude:
# Don't run old macOS with new Xcode
- runner: macos-14
xcode: Xcode_16.1
# Don't run new macOS with old Xcode
- runner: macos-15
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.1
- destination: 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
xcode: Xcode_16.1
- destination: 'platform=visionOS Simulator,OS=1.0,name=Apple Vision Pro'
xcode: Xcode_16.1
# Don't run new simulators with old Xcode
- destination: 'platform=tvOS Simulator,OS=18.1,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_15.2
- destination: 'platform=iOS Simulator,OS=18.1,name=iPhone 16'
xcode: Xcode_15.2
- destination: 'platform=visionOS Simulator,OS=2.1,name=Apple Vision Pro'
xcode: Xcode_15.2
steps:
- name: Configure Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
Expand Down Expand Up @@ -140,7 +126,6 @@ jobs:
os:
- jammy
version:
- "5.9"
- "6.0"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- macos-14
- macos-15
xcode:
- Xcode_15.2
- Xcode_16.1
destination:
- 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
Expand All @@ -37,26 +36,13 @@ jobs:
- 'platform=visionOS Simulator,OS=2.1,name=Apple Vision Pro'
- 'platform=macOS'
exclude:
# Don't run old macOS with new Xcode
- runner: macos-14
xcode: Xcode_16.1
# Don't run new macOS with old Xcode
- runner: macos-15
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.1
- destination: 'platform=iOS Simulator,OS=17.2,name=iPhone 15'
xcode: Xcode_16.1
- destination: 'platform=visionOS Simulator,OS=1.0,name=Apple Vision Pro'
xcode: Xcode_16.1
# Don't run new simulators with old Xcode
- destination: 'platform=tvOS Simulator,OS=18.1,name=Apple TV 4K (3rd generation) (at 1080p)'
xcode: Xcode_15.2
- destination: 'platform=iOS Simulator,OS=18.1,name=iPhone 16'
xcode: Xcode_15.2
- destination: 'platform=visionOS Simulator,OS=2.1,name=Apple Vision Pro'
xcode: Xcode_15.2
steps:
- name: Configure Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
Expand All @@ -76,6 +62,8 @@ jobs:
uses: actions/checkout@v4
with:
path: aws-sdk-swift
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: Checkout smithy-swift with composite action
uses: ./aws-sdk-swift/.github/actions/checkout-smithy-swift-composite-action
with:
Expand Down Expand Up @@ -132,8 +120,7 @@ jobs:
-scheme AWSIntegrationTestsOnCI \
-testPlan AWSIntegrationTestsOnCI \
-destination '${{ matrix.destination }}' \
test 2>&1 \
| xcbeautify
test 2>&1

linux:
# Details on why AL2 isn't included: https://github.com/awslabs/aws-sdk-swift/pull/1833
Expand All @@ -146,7 +133,6 @@ jobs:
os:
- jammy
version:
- "5.9"
- "6.0"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
Expand All @@ -162,6 +148,8 @@ jobs:
uses: actions/checkout@v4
with:
path: aws-sdk-swift
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: Checkout smithy-swift with composite action
uses: ./aws-sdk-swift/.github/actions/checkout-smithy-swift-composite-action
with:
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private var clientRuntimeDependency: Package.Dependency {
}

private var crtDependency: Package.Dependency {
.package(url: "https://github.com/awslabs/aws-crt-swift", exact: crtVersion)
.package(url: "https://github.com/awslabs/aws-crt-swift", branch: "swift6-support")
}

private var doccDependencyOrNil: Package.Dependency? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//
// Copyright Amazon.com Inc. or its affiliates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
/// - count: The number of test runs
/// - test: The function pointer for the test to run
/// - Throws: Any error thrown by one of the test runs.
public func repeatConcurrently(count: Int, test: @escaping () async throws -> Void) async throws {
public func repeatConcurrently(
count: Int,
test: @escaping @Sendable () async throws -> Void
) async throws {
try await withThrowingTaskGroup(of: Void.self) { taskGroup in
for _ in 0..<count {
taskGroup.addTask {
Expand All @@ -33,15 +36,15 @@ public func repeatConcurrently(count: Int, test: @escaping () async throws -> Vo
/// - test: The function pointer for the test to run
/// - args: Any values to pass along to test function
/// - Throws: Any error thrown by one of the test runs.
public func repeatConcurrentlyWithArgs(
public func repeatConcurrentlyWithArgs<Arg: Sendable>(
count: Int,
test: @escaping (Any...) async throws -> Void,
args: Any...
test: @escaping @Sendable (Arg) async throws -> Void,
arg: Arg
) async throws {
try await withThrowingTaskGroup(of: Void.self) { taskGroup in
for _ in 0..<count {
taskGroup.addTask {
try await test(args)
try await test(arg)
}
}
try await taskGroup.waitForAll()
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//
// Copyright Amazon.com Inc. or its affiliates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,46 @@ import XCTest
import AWSS3
import AWSIntegrationTestUtils

final class S3ConcurrentTests: S3XCTestCase {
final class S3ConcurrentTests: S3XCTestCase, @unchecked Sendable {
private var fileData: Data!

// Payload just below chunked threshold
// Tests concurrent upload of simple data payloads
func test_10x_1MB_getObject() async throws {
fileData = generateRandomTextData(ofSizeInMB: 1)
try await repeatConcurrentlyWithArgs(count: 10, test: getObject, args: fileData!)
try await repeatConcurrentlyWithArgs(count: 10, test: getObject, arg: fileData!)
}

// Payload at chunked threshold, just large enough to chunk
// Tests concurrent upload with aws-chunked encoding & flexible checksums
func test_10x_1_5MB_getObject() async throws {
fileData = generateRandomTextData(ofSizeInMB: 1.5)
try await repeatConcurrentlyWithArgs(count: 10, test: getObject, args: fileData!)
try await repeatConcurrentlyWithArgs(count: 10, test: getObject, arg: fileData!)
}

// Payload 256 bytes with 200 concurrent requests, sends as simple data
// Tests very high concurrency with small data payloads
func test_200x_256B_getObject() async throws {
fileData = generateRandomTextData(ofSizeInBytes: 256)
try await repeatConcurrentlyWithArgs(count: 200, test: getObject, args: fileData!)
try await repeatConcurrentlyWithArgs(count: 200, test: getObject, arg: fileData!)
}

// MARK: - Private methods

// Puts data to S3, gets the uploaded file, asserts retrieved data == original data, deletes S3 object
private func getObject(args: Any...) async throws {
private func getObject(data: Data) async throws {
let objectKey = UUID().uuidString.split(separator: "-").first!.lowercased()
let putObjectInput = PutObjectInput(body: .data(data), bucket: bucketName, key: objectKey)

// Take the test data and crate a PutObject request to send it
guard let data = args[0] as? Data else {
throw ClientError.dataNotFound("Failed to retrieve dummy data.")
}
let file = ByteStream.data(data)
let objectKey = UUID().uuidString.split(separator: "-").first!.lowercased()
let putObjectInput = PutObjectInput(body: file, bucket: bucketName, key: objectKey)
_ = try await client.putObject(input: putObjectInput)

// Put the test data to S3
_ = try await client.putObject(input: putObjectInput)
let retrievedData = try await client.getObject(input: GetObjectInput(
bucket: bucketName, key: objectKey
)).body?.readData()

// Read the response's data stream into memory
let retrievedData = try await client.getObject(input: GetObjectInput(
bucket: bucketName, key: objectKey
)).body?.readData()
XCTAssertEqual(data, retrievedData)

// Compare the retrieved data to the uploaded data to show they are equal
XCTAssertEqual(data, retrievedData)

// Delete the S3 object once the test has been verified
// Calling DeleteObject here allows for concurrent deletion, accelerating test teardown
let deleteObjectInput = DeleteObjectInput(bucket: bucketName, key: objectKey)
_ = try await client.deleteObject(input: deleteObjectInput)
}
let deleteObjectInput = DeleteObjectInput(bucket: bucketName, key: objectKey)
_ = try await client.deleteObject(input: deleteObjectInput)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import AWSS3
/// Provides a basic set of functions that can be used to perform S3 integration tests.
/// Creates a bucket for testing before every test, then deletes the bucket after the test completes.
class S3XCTestCase: XCTestCase {
static var client: S3Client!
static let region = "us-west-2"
var client: S3Client { Self.client }
var client: S3Client!
var region: String { Self.region }
var bucketName: String!

Expand All @@ -39,14 +38,14 @@ class S3XCTestCase: XCTestCase {

override func setUp() async throws{
self.bucketName = "aws-sdk-s3-integration-test-\(UUID().uuidString.split(separator: "-").first!.lowercased())"
Self.client = try S3Client(region: region)
try await Self.createBucket(bucketName: bucketName)
self.client = try S3Client(region: region)
try await createBucket(bucketName: bucketName)
}

/// Empty & delete the test bucket before each test.
override func tearDown() async throws {
try await emptyBucket()
try await Self.deleteBucket(bucketName: bucketName)
try await deleteBucket(bucketName: bucketName)
}

// MARK: Helpers
Expand All @@ -73,9 +72,9 @@ class S3XCTestCase: XCTestCase {
}
}

static func createBucket(bucketName: String) async throws {
func createBucket(bucketName: String) async throws {
let input = CreateBucketInput(bucket: bucketName, createBucketConfiguration: S3ClientTypes.CreateBucketConfiguration(locationConstraint: S3ClientTypes.BucketLocationConstraint.usWest2))
_ = try await Self.client.createBucket(input: input)
_ = try await self.client.createBucket(input: input)
}

func putObject(body: String, key: String) async throws {
Expand Down Expand Up @@ -112,7 +111,7 @@ class S3XCTestCase: XCTestCase {
}
}

static func deleteBucket(bucketName: String) async throws {
func deleteBucket(bucketName: String) async throws {
let input = DeleteBucketInput(bucket: bucketName)
_ = try await client.deleteBucket(input: input)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
import AWSTranscribeStreaming
import protocol AWSClientRuntime.AWSServiceError

final class TranscribeStreamingTests: XCTestCase {
final class TranscribeStreamingTests: XCTestCase, @unchecked Sendable {

// MARK: - Test transcription

Expand Down
33 changes: 33 additions & 0 deletions Package.resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this it will be removed

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"originHash" : "1fdaa55664cdad23f69d7841f64fc8963c8731108c2d485a300429c13912b3ae",
"pins" : [
{
"identity" : "aws-crt-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-crt-swift",
"state" : {
"branch" : "swift6-support",
"revision" : "f7ea06a571f64c12b501d3a3ad772eee94f547a5"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa",
"version" : "1.6.3"
}
}
],
"version" : 3
}
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//
// Copyright Amazon.com Inc. or its affiliates.
Expand Down Expand Up @@ -514,7 +514,7 @@ private var clientRuntimeDependency: Package.Dependency {
}

private var crtDependency: Package.Dependency {
.package(url: "https://github.com/awslabs/aws-crt-swift", exact: crtVersion)
.package(url: "https://github.com/awslabs/aws-crt-swift", branch: "swift6-support")
}

private var doccDependencyOrNil: Package.Dependency? {
Expand Down
2 changes: 1 addition & 1 deletion PerformanceTests/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import PackageDescription

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AWSClientRuntime/Package.swift.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import PackageDescription

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

/// Determines how & whether an account ID-based endpoint will be used for requests.
public enum AccountIDEndpointMode: String, Equatable {
public enum AccountIDEndpointMode: String, Equatable, Sendable {
// Note : these case names match string values for the accountIdEndpointMode endpoint param.
// Do not rename them

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AWSSDKChecksums/Package.swift.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import PackageDescription

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//

public enum AWSChecksumCalculationMode: String {
public enum AWSChecksumCalculationMode: String, Sendable {
case whenRequired = "when_required"
case whenSupported = "when_supported"

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AWSSDKCommon/Package.swift.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import PackageDescription

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AWSSDKEventStreamsAuth/Package.swift.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.9
// swift-tools-version: 6.0

import PackageDescription

Expand Down
Loading
Loading