-
Notifications
You must be signed in to change notification settings - Fork 95
chore: Opt-in service client tests #2059
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
0586443
18d5df5
1da879e
ecf5a57
d0abf40
a62423a
01184eb
395de59
c1be323
63fedc1
565b61b
f70827e
77740b8
ed6e759
0d653a1
bc4dbfa
0358490
bb3b0cb
5090eb9
cc6fb28
1aa9c18
da5a648
128b5cf
0d41c80
39a5572
2b217b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ on: | |
|
|
||
| env: | ||
| AWS_SWIFT_SDK_USE_LOCAL_DEPS: 1 | ||
| AWS_SWIFT_SDK_ENABLE_SERVICE_TESTS: 1 | ||
|
|
||
| jobs: | ||
| apple: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,14 +54,14 @@ let package = Package( | |
| ], | ||
| products: | ||
| runtimeProducts + | ||
| serviceTargets.map(productForService(_:_:)), | ||
| serviceProducts, | ||
| dependencies: | ||
| [smithySwiftDependency, crtDependency, doccDependencyOrNil].compactMap { $0 }, | ||
| dependencies, | ||
| targets: | ||
| runtimeTargets + | ||
| runtimeTestTargets + | ||
| serviceTargets.map(target(_:_:)) + | ||
| serviceTargets.map(unitTestTarget(_:_:)) | ||
| serviceTargets + | ||
| serviceTestTargets | ||
| ) | ||
|
|
||
| // MARK: Products | ||
|
|
@@ -78,12 +78,20 @@ private var runtimeProducts: [Product] { | |
| ].map { .library(name: $0, targets: [$0]) } | ||
| } | ||
|
|
||
| private func productForService(_ service: String, _ dependencies: [Target.Dependency]) -> Product { | ||
| .library(name: service, targets: [service]) | ||
| private var serviceProducts: [Product] { | ||
| serviceClientData.map(productForService(_:)) | ||
| } | ||
|
|
||
| private func productForService(_ service: ServiceClientData) -> Product { | ||
| .library(name: service.name, targets: [service.name]) | ||
| } | ||
|
|
||
| // MARK: Dependencies | ||
|
|
||
| private var dependencies: [Package.Dependency] { | ||
| [smithySwiftDependency, crtDependency, doccDependencyOrNil].compactMap { $0 } | ||
| } | ||
|
|
||
| private var smithySwiftDependency: Package.Dependency { | ||
| let previewPath = "./smithy-swift" | ||
| let developmentPath = "../smithy-swift" | ||
|
|
@@ -197,22 +205,22 @@ private var runtimeTargets: [Target] { | |
| ), | ||
| .target( | ||
| name: "InternalAWSSTS", | ||
| dependencies: internalAWSSTSDependencies, | ||
| dependencies: internalAWSSTSData.dependencies, | ||
| path: "Sources/Core/AWSSDKIdentity/InternalClients/InternalAWSSTS/Sources/InternalAWSSTS" | ||
| ), | ||
| .target( | ||
| name: "InternalAWSSSO", | ||
| dependencies: internalAWSSSODependencies, | ||
| dependencies: internalAWSSSOData.dependencies, | ||
| path: "Sources/Core/AWSSDKIdentity/InternalClients/InternalAWSSSO/Sources/InternalAWSSSO" | ||
| ), | ||
| .target( | ||
| name: "InternalAWSSSOOIDC", | ||
| dependencies: internalAWSSSOOIDCDependencies, | ||
| dependencies: internalAWSSSOOIDCData.dependencies, | ||
| path: "Sources/Core/AWSSDKIdentity/InternalClients/InternalAWSSSOOIDC/Sources/InternalAWSSSOOIDC" | ||
| ), | ||
| .target( | ||
| name: "InternalAWSCognitoIdentity", | ||
| dependencies: internalAWSCognitoIdentityDependencies, | ||
| dependencies: internalAWSCognitoIdentityData.dependencies, | ||
| path: "Sources/Core/AWSSDKIdentity/InternalClients/InternalAWSCognitoIdentity/Sources/InternalAWSCognitoIdentity" | ||
| ), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These hard-coded internal client targets are removed, since internal clients are now listed along with the public ones. Instead, the internal services are filtered from the main list of services, and the targets for them are appended to runtime targets below. |
||
| .target( | ||
|
|
@@ -282,24 +290,46 @@ private var runtimeTestTargets: [Target] { | |
| ] | ||
| } | ||
|
|
||
| private func target(_ service: String, _ dependencies: [Target.Dependency]) -> Target { | ||
| private var serviceTargets: [Target] { | ||
| serviceClientData.map(target(_:)) | ||
| } | ||
|
|
||
| private func target(_ service: ServiceClientData) -> Target { | ||
| .target( | ||
| name: service, | ||
| dependencies: dependencies, | ||
| path: "Sources/Services/\(service)/Sources/\(service)" | ||
| name: service.name, | ||
| dependencies: service.dependencies, | ||
| path: "Sources/Services/\(service.name)/Sources/\(service.name)" | ||
| ) | ||
| } | ||
|
|
||
| private func unitTestTarget(_ service: String, _ dependencies: [Target.Dependency]) -> Target { | ||
| let testName = "\(service)Tests" | ||
| private var serviceTestTargets: [Target] { | ||
| guard ProcessInfo.processInfo.environment["AWS_SWIFT_SDK_ENABLE_SERVICE_TESTS"] != nil else { return [] } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Service test targets now default to |
||
| return serviceClientData.map(unitTestTarget(_:)) | ||
| } | ||
|
|
||
| private func unitTestTarget(_ service: ServiceClientData) -> Target { | ||
| let testName = "\(service.name)Tests" | ||
| let modelName = URL(fileURLWithPath: service.modelPath).lastPathComponent | ||
| return .testTarget( | ||
| name: "\(testName)", | ||
| dependencies: [ | ||
| .byName(name: service), | ||
| .byName(name: service.name), | ||
| .ClientRuntime, | ||
| .AWSClientRuntime, | ||
| .SmithyTestUtil, | ||
| ], | ||
| path: "Sources/Services/\(service)/Tests/\(testName)" | ||
| path: "codegen/sdk-codegen/build/smithyprojections/sdk-codegen/\(modelName)/swift-codegen/Tests/\(testName)" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The path for tests now points to the Smithy build folder, where the code generator places them at creation, since they are no longer copied into the project. |
||
| ) | ||
| } | ||
|
|
||
| struct ServiceClientData { | ||
|
||
| let name: String | ||
| let modelPath: String | ||
| let dependencies: [Target.Dependency] | ||
|
|
||
| init(_ name: String, _ modelPath: String, _ dependencies: [Target.Dependency]) { | ||
| self.name = name | ||
| self.modelPath = modelPath | ||
| self.dependencies = dependencies | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the logic in the
Packageinitializer above has been extracted to helper methods below.