Skip to content
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

Swift 6 #617

Merged
merged 11 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/api-breakage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: swift:5.10
image: swift:latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
image:
- 'swift:5.10'
- 'swift:latest'
container:
image: ${{ matrix.image }}
steps:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ jobs:
strategy:
matrix:
image:
- 'swift:5.8'
- 'swift:5.9'
- 'swift:5.10'
- 'swiftlang/swift:nightly-jammy'
- 'swift:6.0'
container:
image: ${{ matrix.image }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
- name: Install Dependencies
run: |
brew install mint
mint install nicklockwood/swiftformat@0.48.17 --no-link
mint install nicklockwood/swiftformat@0.53.10 --no-link
- name: run script
run: ./scripts/validate.sh
6 changes: 3 additions & 3 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Minimum swiftformat version
--minversion 0.51.0
--minversion 0.53.10

# Swift version
--swiftversion 5.8
--swiftversion 6.0

# file options
--exclude .build

# rules
--disable redundantReturn, extensionAccessControl, typeSugar
--disable redundantReturn, extensionAccessControl, typeSugar, conditionalAssignment, preferForLoop, redundantInternal, redundantStaticSelf

# format options
--ifdef no-indent
Expand Down
8 changes: 2 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Legal
By submitting a pull request, you represent that you have the right to license your contribution to the community, and agree by submitting the patch
that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE.txt)).
that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE)).

## Contributor Conduct
All contributors are expected to adhere to the project's [Code of Conduct](CODE_OF_CONDUCT.md).
Expand All @@ -28,7 +28,7 @@ The main development branch of the repository is `main`. Each major version rel

### Formatting

We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.51.15.
We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.53.10.

All new files need to include the following file header at the top
```swift
Expand All @@ -47,7 +47,3 @@ All new files need to include the following file header at the top
//===----------------------------------------------------------------------===//
```
Please ensure the dates are correct in the header.

## Community

You can also contribute by becoming an active member of the Soto community. Join us on the soto-aws [slack](https://join.slack.com/t/soto-project/shared_invite/zt-juqk6l9w-z9zruW5pjlod4AscdWlz7Q).
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
Expand Down
3 changes: 1 addition & 2 deletions Sources/SotoCore/Credential/ConfigFileLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ enum ConfigFileLoader {
return .assumeRole(roleArn: roleArn, sessionName: sessionName, region: region, sourceCredentialProvider: provider)
}
// If `credental_source` is defined, temporary credentials must be loaded from source
else if let credentialSource = credentials.credentialSource ?? config?.credentialSource
{
else if let credentialSource = credentials.credentialSource ?? config?.credentialSource {
let provider: CredentialProviderFactory
switch credentialSource {
case .environment:
Expand Down
4 changes: 4 additions & 0 deletions Sources/SotoCore/HTTP/AWSHTTPBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public struct AWSHTTPBody: Sendable {
self.storage = .asyncSequence(sequence: .init(asyncSequence), length: length)
}

public init<BufferSequence: AsyncSequence & Sendable>(asyncSequence: BufferSequence, length: Int?) where BufferSequence.Element: Collection<UInt8> & Sendable {
self.storage = .asyncSequence(sequence: .init(asyncSequence.map { .init(bytes: $0) }), length: length)
}

public func collect(upTo length: Int) async throws -> ByteBuffer {
switch self.storage {
case .byteBuffer(let buffer):
Expand Down
3 changes: 1 addition & 2 deletions Sources/SotoCore/Utils/crc32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ let crc32cTable: [CRC32] =
0xAD7D_5351,
]

private func crc32_with_table(crc: CRC32, buffer: UnsafeBufferPointer<UInt8>, table: [CRC32]) -> CRC32
{
private func crc32_with_table(crc: CRC32, buffer: UnsafeBufferPointer<UInt8>, table: [CRC32]) -> CRC32 {
// use unsafe buffer pointer to avoid array bounds checking on table
return table.withUnsafeBufferPointer { table in
var crc = crc
Expand Down
2 changes: 2 additions & 0 deletions Sources/SotoTestUtils/TestServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ extension AWSTestServer {
"Content-Type": "application/json",
]
return .result(.init(httpStatus: .ok, headers: headers, body: responseBody), continueProcessing: false)

default:
return .error(.badRequest, continueProcessing: false)
}
Expand Down Expand Up @@ -431,6 +432,7 @@ extension AWSTestServer {
if case .none = status {
status = .finished
}

case .finished:
throw Error.corruptChunkedData
}
Expand Down
57 changes: 28 additions & 29 deletions Tests/SotoCoreTests/AWSClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,41 @@ class AWSClientTests: XCTestCase {
let awsServer = AWSTestServer(serviceProtocol: .json)
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(elg))
defer {
try? awsServer.stop()
try? httpClient.syncShutdown()
try? elg.syncShutdownGracefully()
}
let config = createServiceConfig(
serviceProtocol: .json(version: "1.1"),
endpoint: awsServer.address
)
let client = createAWSClient(
credentialProvider: .static(accessKeyId: "foo", secretAccessKey: "bar"),
httpClient: httpClient
)
defer {
XCTAssertNoThrow(try client.syncShutdown())
}
async let responseTask: AWSTestServer.HTTPBinResponse = client.execute(
operation: "test",
path: "/",
httpMethod: .POST,
serviceConfig: config,
input: Input(content: "test"),
logger: TestEnvironment.logger
)
try await withTeardown {
let config = createServiceConfig(
serviceProtocol: .json(version: "1.1"),
endpoint: awsServer.address
)
async let responseTask: AWSTestServer.HTTPBinResponse = client.execute(
operation: "test",
path: "/",
httpMethod: .POST,
serviceConfig: config,
input: Input(content: "test"),
logger: TestEnvironment.logger
)

XCTAssertNoThrow(try awsServer.httpBin())
XCTAssertNoThrow(try awsServer.httpBin())

let httpBinResponse = try await responseTask
let httpHeaders = HTTPHeaders(httpBinResponse.headers.map { ($0, $1) })
let httpBinResponse = try await responseTask
let httpHeaders = HTTPHeaders(httpBinResponse.headers.map { ($0, $1) })

XCTAssertEqual(httpHeaders["content-length"].first, "18")
XCTAssertEqual(httpHeaders["content-type"].first, "application/x-amz-json-1.1")
XCTAssertNotNil(httpHeaders["authorization"].first)
XCTAssertNotNil(httpHeaders["x-amz-date"].first)
XCTAssertEqual(httpHeaders["user-agent"].first, "Soto/6.0")
XCTAssertEqual(httpHeaders["host"].first, "localhost:\(awsServer.serverPort)")
XCTAssertEqual(httpHeaders["content-length"].first, "18")
XCTAssertEqual(httpHeaders["content-type"].first, "application/x-amz-json-1.1")
XCTAssertNotNil(httpHeaders["authorization"].first)
XCTAssertNotNil(httpHeaders["x-amz-date"].first)
XCTAssertEqual(httpHeaders["user-agent"].first, "Soto/6.0")
XCTAssertEqual(httpHeaders["host"].first, "localhost:\(awsServer.serverPort)")
} teardown: {
try? awsServer.stop()
try? await client.shutdown()
try? await httpClient.shutdown()
try? await elg.shutdownGracefully()
}
}

func testClientNoInputNoOutput() async throws {
Expand Down
Loading
Loading