Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0586443
chore: Opt-in service client tests
jbelkins Nov 17, 2025
18d5df5
Enable service tests on CI
jbelkins Nov 17, 2025
1da879e
Move dependency JSON in from SDK as a SwiftIntegration
jbelkins Nov 17, 2025
ecf5a57
Fix ktlint
jbelkins Nov 17, 2025
d0abf40
Add Dependencies.json for internal clients
jbelkins Nov 17, 2025
a62423a
Refactor CLI, fix CLI tests
jbelkins Nov 17, 2025
01184eb
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Nov 17, 2025
395de59
Don't publish internal modules
jbelkins Nov 18, 2025
c1be323
Fix protocol tests
jbelkins Nov 18, 2025
63fedc1
Don't test internal clients
jbelkins Nov 18, 2025
565b61b
Make ServiceClientData Sendable
jbelkins Nov 18, 2025
f70827e
Move package JSON generator to last integration run
jbelkins Nov 18, 2025
77740b8
Fix Swift 6 language mode in manifest
jbelkins Nov 18, 2025
ed6e759
Omit SmithyTestUtil from dependencies
jbelkins Nov 18, 2025
0d653a1
Refactor isInternal bool to an enum
jbelkins Nov 18, 2025
bc4dbfa
Fix tests
jbelkins Nov 18, 2025
0358490
Revert continuous-integration workflow
jbelkins Nov 19, 2025
bb3b0cb
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Nov 19, 2025
5090eb9
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Nov 25, 2025
cc6fb28
Correct caps in AWSSignin
jbelkins Nov 25, 2025
1aa9c18
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Nov 25, 2025
da5a648
Fix PrepareRelease CLI tests
jbelkins Nov 25, 2025
128b5cf
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Dec 2, 2025
0d41c80
Refactor service client logic, sort services
jbelkins Dec 2, 2025
39a5572
Update Package.swift
jbelkins Dec 2, 2025
2b217b3
Merge branch 'main' into jbe/remove_service_client_tests
jbelkins Dec 3, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
AWS_SWIFT_SDK_USE_LOCAL_DEPS: 1
AWS_SWIFT_SDK_ENABLE_SERVICE_TESTS: 1

jobs:
apple:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,29 @@ struct PackageManifestBuilder {
/// and calls the `addServiceTarget` for each item.
private func buildServiceTargets() -> String {
guard !services.isEmpty else {
return "let serviceTargets: [String: [Target.Dependency]] = [:]"
return "let serviceClientData: [ServiceClientData] = []"
}
var lines: [String] = []
lines += ["let serviceTargets: [String: [Target.Dependency]] = ["]
lines += services.map {
let jsonFilePath = "Sources/Services/\($0.name)/Dependencies.json"
let dependencies = clientDependencies(service: $0, jsonFilePath: jsonFilePath)
return " \($0.name.wrappedInQuotes()): \(dependencies),"
}
lines += ["let serviceClientData: [ServiceClientData] = ["]
lines += services.flatMap { serviceTargetData(name: $0.name, internal: false) }
lines += ["]"]
return lines.joined(separator: .newline)
}

private func serviceTargetData(name: String, internal: Bool) -> [String] {
let jsonFilePath = `internal` ?
"Sources/Core/AWSSDKIdentity/InternalClients/Internal\(name)/Dependencies.json" :
"Sources/Services/\(name)/Dependencies.json"
let dependencies = clientDependencies(service: name, jsonFilePath: jsonFilePath)
return [
" .init(",
" \(name.wrappedInQuotes()),",
" \(dependencies.0),",
" \(dependencies.1)",
" )\(`internal` ? "" : ",")"
]
}

private func buildInternalAWSSTSDependencies() -> String {
buildInternalClientDependencies(name: "AWSSTS")
}
Expand All @@ -176,17 +186,25 @@ struct PackageManifestBuilder {
}

private func buildInternalClientDependencies(name: String) -> String {
let jsonFilePath = "Sources/Core/AWSSDKIdentity/InternalClients/Internal\(name)/Dependencies.json"
let service = Service(name: name)
let dependencies = clientDependencies(service: service, jsonFilePath: jsonFilePath)
return "let internal\(name)Dependencies: [Target.Dependency] = \(dependencies)"
var lines = ["private let internal\(name)Data: ServiceClientData ="]
lines.append(contentsOf: serviceTargetData(name: name, internal: true))
_ = lines[lines.indices.last!].dropLast() // get rid of the trailing comma
return lines.joined(separator: "\n")
}

private func clientDependencies(service: Service, jsonFilePath: String) -> String {
let jsonFileData = FileManager.default.contents(atPath: jsonFilePath) ?? Data("[]".utf8)
let dependencies = try! JSONDecoder().decode([String].self, from: jsonFileData)
.filter { $0 != "SmithyTestUtil" } // links to test files only
return "[" + dependencies.map { ".\($0)" }.joined(separator: ", ") + "]"
private func clientDependencies(service: String, jsonFilePath: String) -> (String, String) {

struct ServiceClientInfo: Decodable {
let modelPath: String
let dependencies: [String]
}

print("CWD: \(FileManager.default.currentDirectoryPath)")
print("jsonFilePath: \(jsonFilePath)")
let jsonFileData = FileManager.default.contents(atPath: jsonFilePath)
let info = try! JSONDecoder().decode(ServiceClientInfo.self, from: jsonFileData!)
let modelFileName = info.modelPath
return (modelFileName.wrappedInQuotes(), "[" + info.dependencies.map { ".\($0)" }.joined(separator: ", ") + "]")
}
}

66 changes: 48 additions & 18 deletions AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Resources/Package.Base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

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 Package initializer above has been extracted to helper methods below.

)

// MARK: Products
Expand All @@ -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"
Expand Down Expand Up @@ -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"
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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(
Expand Down Expand Up @@ -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 [] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service test targets now default to [] if the new env var isn't set.

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)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type has been created to keep multiple pieces of data per service.

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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PackageManifestBuilderTests: XCTestCase {
let subject = try PackageManifestBuilder(
clientRuntimeVersion: .init("1.2.3"),
crtVersion: .init("4.5.6"),
services: ["A","B","C","D","E"].map { PackageManifestBuilder.Service(name: $0) },
services: ["A","B","C","D","E"].map { .init(name: $0) },
excludeRuntimeTests: false,
previewBuild: false,
prefixContents: { "<contents of prefix>" },
Expand Down
Loading
Loading