Skip to content
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

feat: Publish releases on Swift Package Registry #1623

Open
wants to merge 106 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
18c72f9
feat: SPR CLI tool added
jbelkins Jun 22, 2024
a5bf6fb
Reorg project into Swift packages
jbelkins Jun 26, 2024
ab35029
Fix list issues
jbelkins Jun 27, 2024
ff8ec99
Fix Package.swift for runtime modules
jbelkins Jun 27, 2024
f301c24
Merge remote-tracking branch 'origin/main' into jbe/spr
jbelkins Jun 27, 2024
6e1197c
Fix tests in runtime modules
jbelkins Jun 27, 2024
abc6e16
Separate common CLI modules & SPR commands out from CLI tools
jbelkins Jun 27, 2024
71f8a11
Multi-publish implemented
jbelkins Jun 28, 2024
071e733
Add per-service versioning
jbelkins Jun 28, 2024
7333369
Fix main Package.swift so it builds
jbelkins Jun 28, 2024
70d5f30
Correct AWSClientRuntime Resource location
jbelkins Jun 28, 2024
91220cb
Add resources to target in main Package.swift
jbelkins Jun 28, 2024
ddc9cc4
Fix lint, fix CI failure
jbelkins Jun 29, 2024
eb409a0
Wrap URL.path() to be platform dependent
jbelkins Jun 29, 2024
5266077
Fix one more path()
jbelkins Jun 29, 2024
4db4cef
Fix paths in Package.swift
jbelkins Jun 29, 2024
29a476d
Code cleanup
jbelkins Jun 29, 2024
9bd23a9
Update Package.swift to match base
jbelkins Jun 29, 2024
a559104
Rename runtime manifests
jbelkins Jun 29, 2024
e0708bc
Revert "Rename runtime manifests"
jbelkins Jun 29, 2024
6e0c822
Ignore changes in generated code
jbelkins Jun 30, 2024
c29b53f
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 2, 2024
326115a
Use version var in user agent middleware
jbelkins Jul 2, 2024
1af916f
Merge branch 'main' into jbe/spr2
jbelkins Jul 2, 2024
9bc9189
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 2, 2024
4ad4523
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 3, 2024
6eedca9
Merge remote-tracking branch 'origin/main' into jbe/spr
jbelkins Jul 3, 2024
5a5c304
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 3, 2024
2402c80
Rearrange files to support Xcode edit mode
jbelkins Jul 3, 2024
d0f7420
Merge branch 'main' into jbe/spr
jbelkins Jul 5, 2024
3aad806
Merge branch 'jbe/spr' of github.com:awslabs/aws-sdk-swift into jbe/spr
jbelkins Jul 5, 2024
8c825cc
Merge remote-tracking branch 'origin/main' into jbe/spr
jbelkins Jul 5, 2024
168e1dd
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 5, 2024
8ab7558
Merge branch 'main' into jbe/spr
jbelkins Jul 5, 2024
2b69fe8
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 5, 2024
1367871
Merge branch 'main' into jbe/spr
jbelkins Jul 5, 2024
867c338
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 5, 2024
bc0c5a9
Pin to exact versions; extract versions to vars
jbelkins Jul 6, 2024
3d7c2b5
Shift to smithy-swift fork
jbelkins Jul 6, 2024
f35f3b6
Configure SDK 0.0.14, cache control
jbelkins Jul 6, 2024
a4048de
Update to SDK 0.0.15
jbelkins Jul 6, 2024
63eb711
Merge branch 'main' into jbe/spr
jbelkins Jul 8, 2024
1bd0c35
Merge branch 'jbe/spr' of github.com:awslabs/aws-sdk-swift into jbe/spr
jbelkins Jul 8, 2024
8c0b05c
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 8, 2024
7fc9342
Merge branch 'main' into jbe/spr
jbelkins Jul 9, 2024
5e448f2
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 9, 2024
7a873a3
Merge remote-tracking branch 'origin/main' into jbe/spr
jbelkins Jul 9, 2024
3d62431
Merge branch 'jbe/spr' into jbe/spr2
jbelkins Jul 9, 2024
9a6903b
Merge remote-tracking branch 'origin' into jbe/spr
jbelkins Jul 9, 2024
050b69a
Merge remote-tracking branch 'origin/jbe/spr' into jbe/spr2
jbelkins Jul 9, 2024
8cd6871
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 9, 2024
a74c128
Merge branch 'main' into jbe/spr2
jbelkins Jul 10, 2024
8b7299d
Merge branch 'main' into jbe/spr2
jbelkins Jul 10, 2024
61ef710
Correct SDK paths, use TestInitializer in endpoint tests
jbelkins Jul 11, 2024
f2bad7f
Merge branch 'main' into jbe/spr2
jbelkins Jul 11, 2024
c2116f5
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 11, 2024
f7afc10
Adapt main Package.swift for new directories
jbelkins Jul 11, 2024
0c71dea
Fix codegen tests, swiftlint config
jbelkins Jul 11, 2024
c9dd00c
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Jul 11, 2024
37ac8e8
Adjust docs index for new directory name
jbelkins Jul 11, 2024
f293050
Code cleanup
jbelkins Jul 11, 2024
380239d
Add Gradle property for including service client manifests
jbelkins Jul 12, 2024
4f7dead
Fix Gradle build script
jbelkins Jul 12, 2024
1cb4212
Build script cleanup
jbelkins Jul 12, 2024
d860d57
Merge branch 'main' into jbe/spr2
jbelkins Jul 16, 2024
2727ea6
Merge branch 'main' into jbe/spr2
jbelkins Jul 17, 2024
6cbeaa3
Revert generated code
jbelkins Jul 17, 2024
df5e62f
Merge branch 'main' into jbe/spr2
jbelkins Jul 30, 2024
e0fa510
Move bearer token resolvers to correct location
jbelkins Jul 30, 2024
6e4bfa5
Remove unused AWSSDKIdentity source files
jbelkins Jul 30, 2024
ab3ea5f
Re-add bearer token test, copy manifest when running codegen script
jbelkins Jul 30, 2024
fe67bc2
Merge branch 'main' into jbe/spr2
jbelkins Jul 30, 2024
29a2f00
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Aug 1, 2024
8cc5218
Handle URL with path components correctly
jbelkins Aug 2, 2024
666cb13
Update package versions
jbelkins Aug 5, 2024
6757b8b
Merge branch 'main' into jbe/spr2
jbelkins Aug 5, 2024
52f62a8
Merge branch 'main' into jbe/spr2
jbelkins Aug 5, 2024
35848f4
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Aug 7, 2024
0b6338a
Merge branch 'main' into jbe/spr2
jbelkins Aug 8, 2024
6bb4939
Merge branch 'main' into jbe/spr2
jbelkins Aug 13, 2024
7aedd19
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Aug 14, 2024
a5d2fe9
Merge branch 'main' into jbe/spr2
jbelkins Aug 16, 2024
bbc6b95
Merge branch 'main' into jbe/spr2
jbelkins Aug 17, 2024
c169187
Merge branch 'main' into jbe/spr2
jbelkins Aug 22, 2024
8d58558
Merge branch 'main' into jbe/spr2
jbelkins Sep 3, 2024
7275b19
Merge branch 'main' into jbe/spr2
jbelkins Sep 3, 2024
acab93a
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Sep 5, 2024
640eeb0
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Sep 9, 2024
6d6bcf6
Merge branch 'main' into jbe/spr2
jbelkins Sep 12, 2024
c961c4d
Merge branch 'main' into jbe/spr2
jbelkins Oct 16, 2024
f76483c
Adapt to new paths
jbelkins Oct 17, 2024
3094a1f
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Oct 17, 2024
e33f0b4
Merge branch 'main' into jbe/spr2
jbelkins Oct 22, 2024
7d08048
Add manifest regen script
jbelkins Oct 22, 2024
4ed4e5e
Parameterize Package.scope
jbelkins Oct 24, 2024
7a1554e
Merge branch 'main' into jbe/spr2
jbelkins Oct 24, 2024
9968a66
Merge branch 'main' into jbe/spr2
jbelkins Oct 24, 2024
882ae39
Restore Kotlin toList import
jbelkins Oct 24, 2024
548c035
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Oct 25, 2024
3c07859
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Oct 29, 2024
f394546
Merge remote-tracking branch 'origin/main' into jbe/spr2
jbelkins Nov 1, 2024
39bfdbd
Merge branch 'main' into jbe/spr2
jbelkins Nov 1, 2024
6842a81
Fix SPRCLI build
jbelkins Nov 1, 2024
df25f44
Merge branch 'jbe/spr2' of github.com:awslabs/aws-sdk-swift into jbe/…
jbelkins Nov 1, 2024
ea4d3e1
Merge branch 'main' into jbe/spr2
jbelkins Nov 6, 2024
19ebbef
Merge branch 'main' into jbe/spr2
jbelkins Nov 9, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SmokeTests/
# VS Code config files
.vscode/

# Allow the AWSSDKSwiftCLI Package.resolved
# Allow the AWSSDKSwiftCLI & SPRCLI Package.resolved
# while excluding all other Package.resolved files
!/AWSSDKSwiftCLI/Package.resolved
!/SPRCLI/Package.resolved
12 changes: 6 additions & 6 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
included:
- Sources/Core/AWSClientRuntime/Sources
- Sources/Core/AWSSDKChecksums/Sources
- Sources/Core/AWSSDKCommon/Sources
- Sources/Core/AWSSDKEventStreamsAuth/Sources
- Sources/Core/AWSSDKHTTPAuth/Sources
- Sources/Core/AWSSDKIdentity/Sources
- Sources/Core/aws-sdk-swift.AWSClientRuntime/Sources
- Sources/Core/aws-sdk-swift.AWSSDKChecksums/Sources
- Sources/Core/aws-sdk-swift.AWSSDKCommon/Sources
- Sources/Core/aws-sdk-swift.AWSSDKEventStreamsAuth/Sources
- Sources/Core/aws-sdk-swift.AWSSDKHTTPAuth/Sources
- Sources/Core/aws-sdk-swift.AWSSDKIdentity/Sources
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated for new runtime directory locations


analyzer_rules:
- unused_import
Expand Down
3 changes: 3 additions & 0 deletions AWSSDKSwiftCLI/Sources/AWSCLIUtils/Process+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public func _run(_ process: Process) throws {
#if DEBUG
if let testRunner = ProcessRunner.testRunner {
try testRunner.run(process)
if let pipe = process.standardOutput as? Pipe {
try pipe.fileHandleForWriting.close()
}
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 test-only fix was necessary to ensure that CLI tests don't hang waiting for more data from stdout

return
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ struct GenerateDocIndexCommand: ParsableCommand {
log("Resolving services...")
let resolvedServices: [String]
log("Using list of services that exist within Sources/Services")
resolvedServices = try FileManager.default.enabledServices()
resolvedServices = try FileManager.default
.enabledServices()
.map { "\($0.trimmingPrefix("aws-sdk-swift."))" }
log("Resolved list of services: \(resolvedServices.count)")
return resolvedServices
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct GeneratePackageManifestCommand: ParsableCommand {
func run() throws {
let generatePackageManifest = GeneratePackageManifest.standard(
repoPath: repoPath,
packageScope: nil,
packageFileName: packageFileName,
clientRuntimeVersion: clientRuntimeVersion,
crtVersion: crtVersion,
Expand All @@ -54,6 +55,8 @@ struct GeneratePackageManifestCommand: ParsableCommand {
struct GeneratePackageManifest {
/// The path to the package repository
let repoPath: String
/// The package scope. Used for Swift Package Registry.
let packageScope: String?
/// The name of the package manifest file, usually `Package.swift`
let packageFileName: String
/// The version to set for the ClientRuntime dependency
Expand All @@ -69,6 +72,7 @@ struct GeneratePackageManifest {
let excludeRuntimeTests: Bool

typealias BuildPackageManifest = (
_ packageScope: String,
_ clientRuntimeVersion: Version,
_ crtVersion: Version,
_ services: [PackageManifestBuilder.Service]
Expand All @@ -90,10 +94,11 @@ struct GeneratePackageManifest {
///
/// - Returns: The contents of the generated package manifest.
func generatePackageManifestContents() throws -> String {
let packageScope = try resolvePackageScope()
let versions = try resolveVersions()
let services = try resolveServices().map { PackageManifestBuilder.Service(name: $0) }
let services = try resolveServices(packageScope: packageScope).map { PackageManifestBuilder.Service(name: $0) }
log("Creating package manifest contents...")
let contents = try buildPackageManifest(versions.clientRuntime, versions.crt, services)
let contents = try buildPackageManifest(packageScope, versions.clientRuntime, versions.crt, services)
log("Successfully created package manifest contents")
return contents
}
Expand All @@ -112,6 +117,21 @@ struct GeneratePackageManifest {
log("Successfully saved package manifest to \(packageFileName)")
}

func resolvePackageScope() throws -> String {
log("Resolving package scope...")
if let packageScope {
log("Using package scope provided: \(packageScope)")
return packageScope
}
let filename = "Package.scope"
let data = try FileManager.default.loadContents(atPath: filename)
guard let scope = String(data: data, encoding: .utf8) else {
throw Error("Package scope in file \(filename) is not valid UTF-8")
}
log("Using package scope loaded from file \(filename): \(scope)")
return scope
}

/// Returns the versions for ClientRuntime and CRT.
/// If explcit versions are provided by the command, then this returns the specified versions.
/// Otherwise, this returns the versions defined in `packageDependencies.plist`.
Expand Down Expand Up @@ -163,7 +183,7 @@ struct GeneratePackageManifest {
/// Otherwise, this returns the list of services that exist within `Sources/Services`
///
/// - Returns: The list of services to include in the package manifest
func resolveServices() throws -> [String] {
func resolveServices(packageScope: String) throws -> [String] {
log("Resolving services...")
let resolvedServices: [String]
if let services = self.services {
Expand All @@ -174,7 +194,7 @@ struct GeneratePackageManifest {
resolvedServices = try FileManager.default.enabledServices()
}
log("Resolved list of services: \(resolvedServices.count)")
return resolvedServices
return resolvedServices.map { $0.trimmingPrefix("\(packageScope).") }.map(String.init)
}
}

Expand All @@ -194,6 +214,7 @@ extension GeneratePackageManifest {
/// - Returns: the standard package manifest generator
static func standard(
repoPath: String,
packageScope: String? = nil,
packageFileName: String,
clientRuntimeVersion: Version? = nil,
crtVersion: Version? = nil,
Expand All @@ -203,13 +224,15 @@ extension GeneratePackageManifest {
) -> Self {
GeneratePackageManifest(
repoPath: repoPath,
packageScope: packageScope,
packageFileName: packageFileName,
clientRuntimeVersion: clientRuntimeVersion,
crtVersion: crtVersion,
services: services,
excludeRuntimeTests: excludeRuntimeTests
) { _clientRuntimeVersion, _crtVersion, _services in
) { _packageScope, _clientRuntimeVersion, _crtVersion, _services in
let builder = PackageManifestBuilder(
packageScope: _packageScope,
clientRuntimeVersion: _clientRuntimeVersion,
crtVersion: _crtVersion,
services: _services,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ struct PackageManifestBuilder {
let name: String
}

let packageScope: String
let clientRuntimeVersion: Version
let crtVersion: Version
let services: [Service]
let excludeRuntimeTests: Bool
let prefixContents: () throws -> String
let basePackageContents: () throws -> String

init(
packageScope: String,
clientRuntimeVersion: Version,
crtVersion: Version,
services: [Service],
excludeRuntimeTests: Bool,
prefixContents: @escaping () throws -> String,
basePackageContents: @escaping () throws -> String
) {
self.packageScope = packageScope
self.clientRuntimeVersion = clientRuntimeVersion
self.crtVersion = crtVersion
self.services = services
Expand All @@ -38,12 +41,14 @@ struct PackageManifestBuilder {
}

init(
packageScope: String,
clientRuntimeVersion: Version,
crtVersion: Version,
services: [Service],
excludeRuntimeTests: Bool
) {
self.init(
packageScope: packageScope,
clientRuntimeVersion: clientRuntimeVersion,
crtVersion: crtVersion,
services: services,
Expand Down Expand Up @@ -93,6 +98,9 @@ struct PackageManifestBuilder {
// Add the generated content that defines the dependencies' versions
buildDependencies(),
"",
// Add the package scope
buildPackageScope(),
"",
// Remove the runtime tests if needed
buildRuntimeTests(),
"",
Expand All @@ -119,6 +127,10 @@ struct PackageManifestBuilder {
"""
}

private func buildPackageScope() -> String {
"let packageScope = \(packageScope.wrappedInQuotes())"
}

private func buildRuntimeTests() -> String {
"let excludeRuntimeUnitTests = \(excludeRuntimeTests)"
}
Expand Down
32 changes: 20 additions & 12 deletions AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Resources/Package.Base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,35 @@ private var runtimeTargets: [Target] {
.awsSDKHTTPAuth,
.awsSDKIdentity
],
path: "Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime",
path: "Sources/Core/\("AWSClientRuntime".withScope)/Sources/AWSClientRuntime",
resources: [
.process("Resources"),
]
),
.target(
name: "AWSSDKCommon",
dependencies: [.crt],
path: "Sources/Core/AWSSDKCommon/Sources"
path: "Sources/Core/\("AWSSDKCommon".withScope)/Sources"
),
.target(
name: "AWSSDKEventStreamsAuth",
dependencies: [.smithyEventStreamsAPI, .smithyEventStreamsAuthAPI, .smithyEventStreams, .crt, .clientRuntime, "AWSSDKHTTPAuth"],
path: "Sources/Core/AWSSDKEventStreamsAuth/Sources"
path: "Sources/Core/\("AWSSDKEventStreamsAuth".withScope)/Sources"
),
.target(
name: "AWSSDKHTTPAuth",
dependencies: [.crt, .smithy, .clientRuntime, .smithyHTTPAuth, "AWSSDKIdentity", "AWSSDKChecksums"],
path: "Sources/Core/AWSSDKHTTPAuth/Sources"
path: "Sources/Core/\("AWSSDKHTTPAuth".withScope)/Sources"
),
.target(
name: "AWSSDKIdentity",
dependencies: [.crt, .smithy, .clientRuntime, .smithyIdentity, .smithyIdentityAPI, .smithyHTTPAPI, .awsSDKCommon],
path: "Sources/Core/AWSSDKIdentity/Sources"
path: "Sources/Core/\("AWSSDKIdentity".withScope)/Sources"
),
.target(
name: "AWSSDKChecksums",
dependencies: [.crt, .smithy, .clientRuntime, .smithyChecksumsAPI, .smithyChecksums, .smithyHTTPAPI],
path: "Sources/Core/AWSSDKChecksums/Sources"
path: "Sources/Core/\("AWSSDKChecksums".withScope)/Sources"
)
]
}
Expand All @@ -144,23 +144,23 @@ private var runtimeTestTargets: [Target] {
.testTarget(
name: "AWSClientRuntimeTests",
dependencies: [.awsClientRuntime, .clientRuntime, .smithyTestUtils, .awsSDKCommon],
path: "Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests",
path: "Sources/Core/\("AWSClientRuntime".withScope)/Tests/AWSClientRuntimeTests",
resources: [.process("Resources")]
),
.testTarget(
name: "AWSSDKEventStreamsAuthTests",
dependencies: ["AWSClientRuntime", "AWSSDKEventStreamsAuth", .smithyStreams, .smithyTestUtils],
path: "Sources/Core/AWSSDKEventStreamsAuth/Tests/AWSSDKEventStreamsAuthTests"
path: "Sources/Core/\("AWSSDKEventStreamsAuth".withScope)/Tests/AWSSDKEventStreamsAuthTests"
),
.testTarget(
name: "AWSSDKHTTPAuthTests",
dependencies: ["AWSSDKHTTPAuth", "AWSClientRuntime", "AWSSDKEventStreamsAuth", .crt, .clientRuntime, .smithyTestUtils],
path: "Sources/Core/AWSSDKHTTPAuth/Tests/AWSSDKHTTPAuthTests"
path: "Sources/Core/\("AWSSDKHTTPAuth".withScope)/Tests/AWSSDKHTTPAuthTests"
),
.testTarget(
name: "AWSSDKIdentityTests",
dependencies: [.smithy, .smithyIdentity, "AWSSDKIdentity", .awsClientRuntime],
path: "Sources/Core/AWSSDKIdentity/Tests/AWSSDKIdentityTests",
path: "Sources/Core/\("AWSSDKIdentity".withScope)/Tests/AWSSDKIdentityTests",
resources: [.process("Resources")]
),
]
Expand Down Expand Up @@ -189,7 +189,7 @@ private func target(_ service: String) -> Target {
.awsSDKEventStreamsAuth,
.awsSDKChecksums,
],
path: "Sources/Services/\(service)/Sources/\(service)"
path: "Sources/Services/\(service.withScope)/Sources/\(service)"
)
}

Expand All @@ -198,6 +198,14 @@ private func unitTestTarget(_ service: String) -> Target {
return .testTarget(
name: "\(testName)",
dependencies: [.clientRuntime, .awsClientRuntime, .byName(name: service), .smithyTestUtils],
path: "Sources/Services/\(service)/Tests/\(testName)"
path: "Sources/Services/\(service.withScope)/Tests/\(testName)"
)
}

private extension String {

var withScope: String {
guard !packageScope.isEmpty else { return self }
return "\(packageScope).\(self)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GeneratePackageManifestTests: CLITestCase {
// MARK: Golden Path

func testGoldenPath() throws {
let packageScope = "abc-def-ghi"
let clientRuntimeVersion = "1.2.3"
let crtVersion = "3.2.1"
let services = ["EC2", "S3"]
Expand All @@ -51,12 +52,12 @@ class GeneratePackageManifestTests: CLITestCase {
)
createServiceFolders(services)

let subject = GeneratePackageManifest.mock(buildPackageManifest: { _clientRuntimeVersion, _crtVersion, services in
"\(_clientRuntimeVersion)-\(_crtVersion)-\(services.map(\.name).joined(separator: "-"))"
let subject = GeneratePackageManifest.mock(packageScope: packageScope, buildPackageManifest: { _packageScope, _clientRuntimeVersion, _crtVersion, services in
"\(_packageScope)-\(_clientRuntimeVersion)-\(_crtVersion)-\(services.map(\.name).joined(separator: "-"))"
})
try! subject.run()
let result = try! String(contentsOfFile: "Package.swift", encoding: .utf8)
XCTAssertEqual(result, "1.2.3-3.2.1-EC2-S3")
XCTAssertEqual(result, "abc-def-ghi-1.2.3-3.2.1-EC2-S3")
}

// MARK: resolveVersions()
Expand Down Expand Up @@ -89,18 +90,20 @@ class GeneratePackageManifestTests: CLITestCase {
// MARK: resolveServices()

func testResolveServicesRetrievesServicesFromDisk() {
let packageScope = ""
let services = ["EC2", "S3"]
createServiceFolders(services)

let subject = GeneratePackageManifest.mock()
let result = try! subject.resolveServices()
let result = try! subject.resolveServices(packageScope: packageScope)
XCTAssertEqual(result, services)
}

func testResolveServicesWithExplicitServices() {
let packageScope = ""
let services = ["One", "Two", "Three"]
let subject = GeneratePackageManifest.mock(services: services)
let result = try! subject.resolveServices()
let result = try! subject.resolveServices(packageScope: packageScope)
XCTAssertEqual(result, services)
}
}
Expand All @@ -110,15 +113,16 @@ class GeneratePackageManifestTests: CLITestCase {
extension GeneratePackageManifest {
static func mock(
repoPath: String = ".",
packageScope: String = "",
packageFileName: String = "Package.swift",
clientRuntimeVersion: Version? = nil,
crtVersion: Version? = nil,
services: [String]? = nil,
excludeRuntimeTests: Bool = false,
buildPackageManifest: @escaping BuildPackageManifest = { (_,_,_) throws -> String in "" }
buildPackageManifest: @escaping BuildPackageManifest = { (_,_,_,_) throws -> String in "" }
) -> GeneratePackageManifest {
GeneratePackageManifest(
repoPath: repoPath,
repoPath: repoPath, packageScope: packageScope,
packageFileName: packageFileName,
clientRuntimeVersion: clientRuntimeVersion,
crtVersion: crtVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class PackageManifestBuilderTests: XCTestCase {
let clientRuntimeVersion: Version = "1.2.3"
let crtVersion: Version = "4.5.6"

let packageScope = "abc-def-ghi"

let excludeRuntimeUnitTests = false

let serviceTargets: [String] = [
Expand All @@ -32,6 +34,7 @@ let serviceTargets: [String] = [

func testBuild() throws {
let subject = try PackageManifestBuilder(
packageScope: "abc-def-ghi",
clientRuntimeVersion: .init("1.2.3"),
crtVersion: .init("4.5.6"),
services: ["A","B","C","D","E"].map { PackageManifestBuilder.Service(name: $0) },
Expand Down
1 change: 1 addition & 0 deletions Package.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws-sdk-swift
Loading
Loading