Skip to content

Commit

Permalink
Swift 5.8 (#44)
Browse files Browse the repository at this point in the history
* Update workflows

* Update minimum required swift version to 5.6

* _SotoSendable -> Sendable

* Remove #if compiler( checks
  • Loading branch information
adam-fowler authored Apr 17, 2023
1 parent 345dfcf commit f783467
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-breakage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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.2
// swift-tools-version:5.6
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

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

import AsyncHTTPClient
import Foundation
import JWTKit
Expand Down Expand Up @@ -101,5 +99,3 @@ extension CognitoAuthenticatable {
return signers
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

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

import Crypto
import Foundation
import JWTKit
Expand Down Expand Up @@ -516,5 +514,3 @@ public extension CognitoAuthenticatable {
}
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

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

import NIO
import SotoCognitoIdentity

Expand Down Expand Up @@ -72,5 +70,3 @@ extension CognitoIdentifiable {
}
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)
14 changes: 6 additions & 8 deletions Sources/SotoCognitoAuthenticationKit/Authenticatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ 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
public var userStatus: CognitoUserStatusType
}

/// 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?
public let expiresIn: Date?
}

/// Response containing an authentication challenge
public struct ChallengedResponse: Codable, _SotoSendable {
public struct ChallengedResponse: Codable, Sendable {
/// Name of challenge
public let name: CognitoChallengeName?
/// Challenge parameters
Expand Down Expand Up @@ -107,7 +107,7 @@ public final class CognitoAuthenticatable {
}

private var _jwtSigners: JWTSigners?
private let jwtSignersLock: Lock
private let jwtSignersLock: NIOLock

// MARK: Initialization

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions Sources/SotoCognitoAuthenticationKit/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/SotoCognitoAuthenticationKit/Identifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import NIO
import SotoCognitoIdentity

public final class CognitoIdentifiable: _SotoSendable {
public final class CognitoIdentifiable: Sendable {
// MARK: Member variables

/// Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
//
//===----------------------------------------------------------------------===//

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

import BigNum
import Crypto
import Foundation
Expand Down Expand Up @@ -110,5 +108,3 @@ public extension CognitoAuthenticatable {
)
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -416,5 +410,3 @@ final class CognitoAsyncTests: XCTestCase {
}
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -178,5 +172,3 @@ final class CognitoSRPAsyncTests: XCTestCase {
}
}
}

#endif // compiler(>=5.5) && canImport(_Concurrency)

0 comments on commit f783467

Please sign in to comment.