From f783467c60f93b3806c016497004dd32049dec10 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Mon, 17 Apr 2023 10:46:14 +0100 Subject: [PATCH] Swift 5.8 (#44) * Update workflows * Update minimum required swift version to 5.6 * _SotoSendable -> Sendable * Remove #if compiler( checks --- .github/workflows/api-breakage.yml | 2 +- .github/workflows/ci.yml | 8 ++++---- .github/workflows/validate.yml | 2 +- Package.swift | 4 ++-- .../Authenticatable+JWT+async.swift | 4 ---- .../AsyncAwaitSupport/Authenticatable+async.swift | 4 ---- .../AsyncAwaitSupport/Identifiable+async.swift | 4 ---- .../Authenticatable.swift | 14 ++++++-------- .../Configuration.swift | 4 ++-- .../Identifiable.swift | 2 +- .../Authenticatable+SRP+async.swift | 4 ---- .../CognitoAsyncTests.swift | 8 -------- .../CognitoSRPAsyncTests.swift | 8 -------- 13 files changed, 17 insertions(+), 51 deletions(-) diff --git a/.github/workflows/api-breakage.yml b/.github/workflows/api-breakage.yml index 2e0e405..234d551 100644 --- a/.github/workflows/api-breakage.yml +++ b/.github/workflows/api-breakage.yml @@ -7,7 +7,7 @@ jobs: linux: runs-on: ubuntu-latest container: - image: swift:5.6-focal + image: swift:5.8 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c4c2ab..803e23e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: runs-on: macOS-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: swift test --enable-code-coverage - name: Convert coverage files @@ -41,15 +41,15 @@ jobs: strategy: matrix: image: - - swift:5.4 - - swift:5.5 - swift:5.6 + - swift:5.7 + - swift:5.8 runs-on: ubuntu-latest container: image: ${{ matrix.image }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: swift test --enable-code-coverage - name: Convert coverage files diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 7dbc124..acd7fc1 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -10,7 +10,7 @@ jobs: runs-on: macOS-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: fetch-depth: 1 - name: Install Dependencies diff --git a/Package.swift b/Package.swift index fddb664..0b0c428 100644 --- a/Package.swift +++ b/Package.swift @@ -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 @@ -30,7 +30,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "1.0.0")), - .package(url: "https://github.com/soto-project/soto.git", from: "6.0.0"), + .package(url: "https://github.com/soto-project/soto.git", from: "6.6.0"), .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.10.0"), .package(url: "https://github.com/vapor/jwt-kit.git", .upToNextMajor(from: "4.2.6")), // for SRP diff --git a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+JWT+async.swift b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+JWT+async.swift index 7012ec0..0d329c4 100644 --- a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+JWT+async.swift +++ b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+JWT+async.swift @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import AsyncHTTPClient import Foundation import JWTKit @@ -101,5 +99,3 @@ extension CognitoAuthenticatable { return signers } } - -#endif // compiler(>=5.5) && canImport(_Concurrency) diff --git a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+async.swift b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+async.swift index 8811afb..4821a30 100644 --- a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+async.swift +++ b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Authenticatable+async.swift @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import Crypto import Foundation import JWTKit @@ -516,5 +514,3 @@ public extension CognitoAuthenticatable { } } } - -#endif // compiler(>=5.5) && canImport(_Concurrency) diff --git a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Identifiable+async.swift b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Identifiable+async.swift index 38cc8d3..015ac5d 100644 --- a/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Identifiable+async.swift +++ b/Sources/SotoCognitoAuthenticationKit/AsyncAwaitSupport/Identifiable+async.swift @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import NIO import SotoCognitoIdentity @@ -72,5 +70,3 @@ extension CognitoIdentifiable { } } } - -#endif // compiler(>=5.5) && canImport(_Concurrency) diff --git a/Sources/SotoCognitoAuthenticationKit/Authenticatable.swift b/Sources/SotoCognitoAuthenticationKit/Authenticatable.swift index d7d802e..19ce822 100644 --- a/Sources/SotoCognitoAuthenticationKit/Authenticatable.swift +++ b/Sources/SotoCognitoAuthenticationKit/Authenticatable.swift @@ -35,7 +35,7 @@ public enum SotoCognitoError: Error { } /// Response to `createUser` -public struct CognitoCreateUserResponse: Codable, _SotoSendable { +public struct CognitoCreateUserResponse: Codable, Sendable { /// name of user public var userName: String /// status of user account @@ -43,14 +43,14 @@ public struct CognitoCreateUserResponse: Codable, _SotoSendable { } /// Authentication response -public enum CognitoAuthenticateResponse: Codable, _SotoSendable { +public enum CognitoAuthenticateResponse: Codable, Sendable { /// Response with authentication details case authenticated(AuthenticatedResponse) /// Response containing a challenge case challenged(ChallengedResponse) /// Authenticated Response - public struct AuthenticatedResponse: Codable, _SotoSendable { + public struct AuthenticatedResponse: Codable, Sendable { public let accessToken: String? public let idToken: String? public let refreshToken: String? @@ -58,7 +58,7 @@ public enum CognitoAuthenticateResponse: Codable, _SotoSendable { } /// Response containing an authentication challenge - public struct ChallengedResponse: Codable, _SotoSendable { + public struct ChallengedResponse: Codable, Sendable { /// Name of challenge public let name: CognitoChallengeName? /// Challenge parameters @@ -107,7 +107,7 @@ public final class CognitoAuthenticatable { } private var _jwtSigners: JWTSigners? - private let jwtSignersLock: Lock + private let jwtSignersLock: NIOLock // MARK: Initialization @@ -650,7 +650,5 @@ public extension CognitoAuthenticatable { } } -#if compiler(>=5.6) -// jwtSigners is mutable so required to use @unchecked here. +// jwtSigners is mutable but access is controlled by a lock so required to use @unchecked here. extension CognitoAuthenticatable: @unchecked Sendable {} -#endif diff --git a/Sources/SotoCognitoAuthenticationKit/Configuration.swift b/Sources/SotoCognitoAuthenticationKit/Configuration.swift index fbd99b7..34dce2a 100644 --- a/Sources/SotoCognitoAuthenticationKit/Configuration.swift +++ b/Sources/SotoCognitoAuthenticationKit/Configuration.swift @@ -20,7 +20,7 @@ import SotoCognitoIdentityProvider /// /// See [Cognito Userpool](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html) /// documention for more information. -public struct CognitoConfiguration: _SotoSendable { +public struct CognitoConfiguration: Sendable { /// user pool id public let userPoolId: String /// app client id @@ -60,7 +60,7 @@ public struct CognitoConfiguration: _SotoSendable { /// /// See [Cognito Identity Pools](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html) /// documention for more information. -public struct CognitoIdentityConfiguration: _SotoSendable { +public struct CognitoIdentityConfiguration: Sendable { /// Cognito identity pool id public let identityPoolId: String /// Identity provider diff --git a/Sources/SotoCognitoAuthenticationKit/Identifiable.swift b/Sources/SotoCognitoAuthenticationKit/Identifiable.swift index 8b20609..afa866b 100644 --- a/Sources/SotoCognitoAuthenticationKit/Identifiable.swift +++ b/Sources/SotoCognitoAuthenticationKit/Identifiable.swift @@ -15,7 +15,7 @@ import NIO import SotoCognitoIdentity -public final class CognitoIdentifiable: _SotoSendable { +public final class CognitoIdentifiable: Sendable { // MARK: Member variables /// Configuration diff --git a/Sources/SotoCognitoAuthenticationSRP/Authenticatable+SRP+async.swift b/Sources/SotoCognitoAuthenticationSRP/Authenticatable+SRP+async.swift index 826578b..b6e19b9 100644 --- a/Sources/SotoCognitoAuthenticationSRP/Authenticatable+SRP+async.swift +++ b/Sources/SotoCognitoAuthenticationSRP/Authenticatable+SRP+async.swift @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import BigNum import Crypto import Foundation @@ -110,5 +108,3 @@ public extension CognitoAuthenticatable { ) } } - -#endif // compiler(>=5.5) && canImport(_Concurrency) diff --git a/Tests/SotoCognitoAuthenticationKitTests/CognitoAsyncTests.swift b/Tests/SotoCognitoAuthenticationKitTests/CognitoAsyncTests.swift index e31dbf8..e64df7b 100644 --- a/Tests/SotoCognitoAuthenticationKitTests/CognitoAsyncTests.swift +++ b/Tests/SotoCognitoAuthenticationKitTests/CognitoAsyncTests.swift @@ -12,15 +12,9 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import AsyncHTTPClient import Crypto -#if compiler(>=5.6) -@preconcurrency import Foundation -#else import Foundation -#endif import NIO @testable import SotoCognitoAuthenticationKit import SotoCognitoIdentity @@ -416,5 +410,3 @@ final class CognitoAsyncTests: XCTestCase { } } } - -#endif // compiler(>=5.5) && canImport(_Concurrency) diff --git a/Tests/SotoCognitoAuthenticationSRPTests/CognitoSRPAsyncTests.swift b/Tests/SotoCognitoAuthenticationSRPTests/CognitoSRPAsyncTests.swift index 33389d0..43025b4 100644 --- a/Tests/SotoCognitoAuthenticationSRPTests/CognitoSRPAsyncTests.swift +++ b/Tests/SotoCognitoAuthenticationSRPTests/CognitoSRPAsyncTests.swift @@ -12,15 +12,9 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) - import BigNum import Crypto -#if compiler(>=5.6) -@preconcurrency import Foundation -#else import Foundation -#endif import NIO import SotoCognitoAuthenticationKit @testable import SotoCognitoAuthenticationSRP @@ -178,5 +172,3 @@ final class CognitoSRPAsyncTests: XCTestCase { } } } - -#endif // compiler(>=5.5) && canImport(_Concurrency)