Skip to content

Commit

Permalink
Swift 5.8 (#540)
Browse files Browse the repository at this point in the history
* Set minimum tools version to 5.6

* Remove 5.4/5.5 and add 5.8 to CI

* Remove #if compiler (>=5.5.2) preprocessor tests

* Fix up issues since updating to Atomics 1.1 and 5.8 warnings

* Fix warnings/Swift 5.6 issues

* swift format fixes

* Add _SotoSendable back in

* Remove Collections from SotoCode dependencies

* Remove #if compiler(>=5.5.2) tests
  • Loading branch information
adam-fowler authored Apr 11, 2023
1 parent 0997ca4 commit 80d1d56
Show file tree
Hide file tree
Showing 62 changed files with 60 additions and 233 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ jobs:
strategy:
matrix:
image:
- 'swift:5.4'
- 'swift:5.5'
- 'swift:5.6'
- 'swift:5.7'
- 'swift:5.8'
container:
image: ${{ matrix.image }}
steps:
Expand Down
6 changes: 2 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.2
// swift-tools-version:5.6
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
Expand All @@ -23,8 +23,7 @@ let package = Package(
.library(name: "SotoSignerV4", targets: ["SotoSignerV4"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0"..<"3.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"),
Expand All @@ -43,7 +42,6 @@ let package = Package(
.product(name: "Logging", package: "swift-log"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "Collections", package: "swift-collections"),
.product(name: "Metrics", package: "swift-metrics"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
Expand Down
4 changes: 0 additions & 4 deletions Sources/SotoCore/AWSClient+EndpointDiscovery+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import Logging
import NIOCore

Expand Down Expand Up @@ -263,5 +261,3 @@ extension AWSClient {
}
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
4 changes: 0 additions & 4 deletions Sources/SotoCore/AWSClient+Paginate+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import Logging
import NIOCore

Expand Down Expand Up @@ -88,5 +86,3 @@ extension AWSClient {
}
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
4 changes: 0 additions & 4 deletions Sources/SotoCore/AWSClient+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import Atomics
import Dispatch
import Foundation
Expand Down Expand Up @@ -415,5 +413,3 @@ extension AWSClient {
return AWSSigner(credentials: credential, name: serviceConfig.signingName, region: serviceConfig.region.rawValue)
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
8 changes: 1 addition & 7 deletions Sources/SotoCore/AWSClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.6)
@preconcurrency import Atomics
#else
import Atomics
#endif
import AsyncHTTPClient
import Atomics
import Dispatch
import struct Foundation.URL
import struct Foundation.URLQueryItem
Expand Down Expand Up @@ -745,8 +741,6 @@ extension Logger {
}
}

#if compiler(>=5.6)
extension AWSClient: Sendable {}
extension AWSClient.HTTPClientProvider: Sendable {}
extension AWSClient.Options: Sendable {}
#endif
2 changes: 0 additions & 2 deletions Sources/SotoCore/AWSEndpointDiscovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public struct AWSEndpointDiscovery {
}
}

#if compiler(>=5.6)
// can be set to Sendable as the contents are only set internally and they are
// protected by a lock
extension AWSEndpointStorage: @unchecked Sendable {}
Expand All @@ -133,4 +132,3 @@ extension AWSEndpointStorage: @unchecked Sendable {}
// which then requires multiple versions of that function if I am going to support backwards
// compatiblity
extension AWSEndpointDiscovery: @unchecked Sendable {}
#endif
4 changes: 0 additions & 4 deletions Sources/SotoCore/AWSService+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import struct Foundation.URL
import NIOCore

Expand Down Expand Up @@ -58,5 +56,3 @@ extension AWSService {
return try await self.client.signHeaders(url: url, httpMethod: httpMethod, headers: headers, body: body, serviceConfig: self.config, logger: logger)
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
2 changes: 1 addition & 1 deletion Sources/SotoCore/AWSService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import struct Foundation.URL
import NIOCore

/// Services object protocol. Contains a client to communicate with AWS and configuration for defining how to communicate.
public protocol AWSService: _SotoSendableProtocol {
public protocol AWSService: Sendable {
/// Client used to communicate with AWS
var client: AWSClient { get }
/// Service context details
Expand Down
7 changes: 1 addition & 6 deletions Sources/SotoCore/AWSServiceConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,8 @@ public final class AWSServiceConfig {

/// Details about endpoint variants eg fips, dualstack
public struct EndpointVariant {
#if compiler(>=5.6)
public typealias EndpointCallback = @Sendable (String) -> String
#else
public typealias EndpointCallback = (String) -> String
#endif

let defaultEndpoint: EndpointCallback?
let endpoints: [String: String]

Expand Down Expand Up @@ -367,8 +364,6 @@ public final class AWSServiceConfig {
}
}

#if compiler(>=5.6)
extension AWSServiceConfig: Sendable {}
extension AWSServiceConfig.Options: Sendable {}
extension AWSServiceConfig.EndpointVariant: Sendable {}
#endif
2 changes: 1 addition & 1 deletion Sources/SotoCore/AWSShapes/Base64Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

/// Holds request or response data that is encoded as base64 during transit
public struct AWSBase64Data: _SotoSendable, Codable, Equatable {
public struct AWSBase64Data: Sendable, Codable, Equatable {
let base64String: String

/// Initialise AWSBase64Data
Expand Down
4 changes: 0 additions & 4 deletions Sources/SotoCore/AWSShapes/Payload+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import NIOCore

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -43,5 +41,3 @@ extension AWSPayload {
)
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
2 changes: 0 additions & 2 deletions Sources/SotoCore/AWSShapes/Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,5 @@ extension AWSPayload: Decodable {
}
}

#if compiler(>=5.6)
extension AWSPayload: Sendable {}
extension AWSPayload.Payload: Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import NIOCore

/// An AsyncSequence that returns fixed size ByteBuffers from an AsyncSequence of ByteBuffers
Expand Down Expand Up @@ -89,5 +87,3 @@ extension AsyncSequence where Element == ByteBuffer {
return .init(byteBufferSequence: self, chunkSize: chunkSize)
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
4 changes: 0 additions & 4 deletions Sources/SotoCore/Concurrency/Sequence+concurrentMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Sequence where Element: Sendable {
/// Returns an array containing the results of mapping the given async closure over
Expand Down Expand Up @@ -106,5 +104,3 @@ extension Sequence where Element: Sendable {
}
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ final class ConfigFileCredentialProvider: CredentialProviderSelector {
}
}

#if compiler(>=5.6)
// can use @unchecked Sendable here as `_internalProvider`` is accessed via `internalProvider` which
// protects access with a `NIOLock`
extension ConfigFileCredentialProvider: @unchecked Sendable {}
#endif
4 changes: 0 additions & 4 deletions Sources/SotoCore/Credential/CredentialProvider+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=5.5.2) && canImport(_Concurrency)

import Logging
import NIOCore
import SotoSignerV4
Expand All @@ -36,5 +34,3 @@ extension AsyncCredentialProvider {
return promise.futureResult
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
2 changes: 1 addition & 1 deletion Sources/SotoCore/Credential/CredentialProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import NIOCore
import SotoSignerV4

/// Provides AWS credentials
public protocol CredentialProvider: _SotoSendableProtocol, CustomStringConvertible {
public protocol CredentialProvider: Sendable, CustomStringConvertible {
/// Return credential
/// - Parameters:
/// - eventLoop: EventLoop to run on
Expand Down
2 changes: 0 additions & 2 deletions Sources/SotoCore/Credential/DeferredCredentialProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ extension DeferredCredentialProvider: CustomStringConvertible {
public var description: String { return "\(type(of: self))(\(self.provider.description))" }
}

#if compiler(>=5.6)
// can use @unchecked Sendable here as `internalCredential` is accessed via `credential` which
// protects access with a `NIOLock`
extension DeferredCredentialProvider: @unchecked Sendable {}
#endif
8 changes: 4 additions & 4 deletions Sources/SotoCore/Credential/MetaDataCredentialProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct ECSMetaDataClient: MetaDataClient {

let httpClient: HTTPClient
let endpointURL: String
let decoder = Self.createJSONDecoder()
let decoder = UnsafeTransfer(Self.createJSONDecoder())

init?(httpClient: HTTPClient, host: String = ECSMetaDataClient.Host) {
guard let relativeURL = Environment[Self.RelativeURIEnvironmentName] else {
Expand All @@ -114,7 +114,7 @@ struct ECSMetaDataClient: MetaDataClient {
guard let body = response.body else {
throw MetaDataClientError.missingMetaData
}
return try self.decoder.decode(MetaData.self, from: body)
return try self.decoder.wrappedValue.decode(MetaData.self, from: body)
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ struct InstanceMetaDataClient: MetaDataClient {

let httpClient: HTTPClient
let host: String
let decoder = Self.createJSONDecoder()
let decoder = UnsafeTransfer(Self.createJSONDecoder())

init(httpClient: HTTPClient, host: String = InstanceMetaDataClient.Host) {
self.httpClient = httpClient
Expand Down Expand Up @@ -227,7 +227,7 @@ struct InstanceMetaDataClient: MetaDataClient {
throw MetaDataClientError.missingMetaData
}

return try self.decoder.decode(InstanceMetaData.self, from: body)
return try self.decoder.wrappedValue.decode(InstanceMetaData.self, from: body)
}
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/SotoCore/Credential/RotatingCredentialProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,5 @@ extension RotatingCredentialProvider: CustomStringConvertible {
public var description: String { return "\(type(of: self))(\(provider.description))" }
}

#if compiler(>=5.6)
// can use @unchecked Sendable here as access is protected by 'NIOLock'
extension RotatingCredentialProvider: @unchecked Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class RuntimeSelectorCredentialProvider: CredentialProviderSelector {
}
}

#if compiler(>=5.6)
// can use @unchecked Sendable here as `_internalProvider`` is accessed via `internalProvider` which
// protects access with a `NIOLock`
extension RuntimeSelectorCredentialProvider: @unchecked Sendable {}
#endif
2 changes: 1 addition & 1 deletion Sources/SotoCore/Doc/AWSShape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import struct Foundation.UUID
///
/// They need to be Codable so they can be serialized. They also need to provide details
/// on how their container classes are coded when serializing XML.
public protocol AWSShape: _SotoSendableProtocol {
public protocol AWSShape: Sendable {
/// The array of members serialization helpers
static var _encoding: [AWSMemberEncoding] { get }
static var _options: AWSShapeOptions { get }
Expand Down
2 changes: 0 additions & 2 deletions Sources/SotoCore/Doc/EndpointVariant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,4 @@ extension AWSServiceConfig.Options {
}
}

#if compiler(>=5.6)
extension EndpointVariantType: Sendable {}
#endif
2 changes: 0 additions & 2 deletions Sources/SotoCore/Doc/Region.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,5 @@ public extension Region {
}
}

#if compiler(>=5.6)
extension Region: Sendable {}
extension AWSPartition: Sendable {}
#endif
2 changes: 0 additions & 2 deletions Sources/SotoCore/Doc/ServiceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ extension ServiceProtocol {
}
}

#if compiler(>=5.6)
extension ServiceProtocol: Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import JMESPath

/// base protocol for encoder/decoder objects
public protocol CustomCoder {
associatedtype CodableValue: _SotoSendable
associatedtype CodableValue: Sendable
}

/// Protocol for object that will encode a value
Expand Down Expand Up @@ -156,7 +156,5 @@ internal struct EncodingWrapperKey: CodingKey {
}
}

#if compiler(>=5.6)
extension CustomCoding: Sendable {}
extension OptionalCustomCoding: Sendable {}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public protocol ArrayCoderProperties {

/// Coder for encoding/decoding Arrays.
/// This is extended to support encoding and decoding based on whether `Element` is `Encodable` or `Decodable`.
public struct ArrayCoder<Properties: ArrayCoderProperties, Element: _SotoSendable>: CustomCoder {
public struct ArrayCoder<Properties: ArrayCoderProperties, Element: Sendable>: CustomCoder {
public typealias CodableValue = [Element]
}

Expand Down Expand Up @@ -67,7 +67,7 @@ public protocol DictionaryCoderProperties {

/// Coder for encoding/decoding Dictionaries.
/// This is extended to support encoding and decoding based on whether `Key` and `Value` are `Encodable` or `Decodable`.
public struct DictionaryCoder<Properties: DictionaryCoderProperties, Key: Hashable & _SotoSendable, Value: _SotoSendable>: CustomCoder {
public struct DictionaryCoder<Properties: DictionaryCoderProperties, Key: Hashable & Sendable, Value: Sendable>: CustomCoder {
public typealias CodableValue = [Key: Value]
}

Expand Down
Loading

0 comments on commit 80d1d56

Please sign in to comment.