Skip to content

Commit

Permalink
Merge branch 'main' into feat/operation-context-params
Browse files Browse the repository at this point in the history
  • Loading branch information
Sichan Yoo committed Aug 17, 2024
2 parents 4588b82 + 241b55d commit 036edec
Show file tree
Hide file tree
Showing 433 changed files with 16,949 additions and 16,065 deletions.
27 changes: 0 additions & 27 deletions AWSSDKSwiftCLI/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
"version" : "1.3.1"
}
},
{
"identity" : "swift-llbuild",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-llbuild.git",
"state" : {
"revision" : "fb7ebf0b06c0d7c45ca8e18b3371424503a38b5c",
"version" : "0.3.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
Expand All @@ -44,24 +35,6 @@
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-package-manager",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-package-manager",
"state" : {
"revision" : "f5ea3972d7d6c574e8bb16a19b2a7bca98ea131b",
"version" : "0.6.0"
}
},
{
"identity" : "swift-tools-support-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-tools-support-core.git",
"state" : {
"revision" : "98a5916a811fcaaed770f1ed812e9405be762945",
"version" : "0.1.0"
}
}
],
"version" : 2
Expand Down
2 changes: 0 additions & 2 deletions AWSSDKSwiftCLI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-package-manager", from: "0.6.0"),
.package(url: "https://github.com/apple/swift-algorithms", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
],
Expand All @@ -34,7 +33,6 @@ let package = Package(
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Logging", package: "swift-log"),
.product(name: "PackageDescription", package: "swift-package-manager"),
]
),
.testTarget(
Expand Down
1 change: 0 additions & 1 deletion AWSSDKSwiftCLI/Sources/AWSCLIUtils/Process+Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription
import struct ArgumentParser.ExitCode

public extension Process {
Expand Down
1 change: 0 additions & 1 deletion AWSSDKSwiftCLI/Sources/AWSCLIUtils/Process+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription

public extension Process {
struct Swift {
Expand Down
8 changes: 8 additions & 0 deletions AWSSDKSwiftCLI/Sources/AWSCLIUtils/Process+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public func _run(_ process: Process) throws {
}

public func _runReturningStdOut(_ process: Process) throws -> String? {
// If debug and we have a non-nil test runner, then use that
// This allows developers to intercept processes when they run to assert that it is the expected process
#if DEBUG
if let testRunner = ProcessRunner.testRunner {
try testRunner.run(process)
return nil
}
#endif
let stdOut = Pipe()
process.standardOutput = stdOut

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,46 @@

import Foundation
import ArgumentParser
import PackageDescription

// MARK: - Decodable
public struct Version: Equatable {
public let major: Int
public let minor: Int
public let patch: Int

private var versionString: String { "\(major).\(minor).\(patch)" }

init(_ major: Int, _ minor: Int, _ patch: Int) {
self.major = major
self.minor = minor
self.patch = patch
}

public init(_ value: String) throws {
let components = value.split(separator: ".")
guard components.count == 3 else {
throw Error("Version does not have three components")
}
guard let major = Int(components[0]), let minor = Int(components[1]), let patch = Int(components[2]) else {
throw Error("Version components are not all Int")
}
self.init(major, minor, patch)
}
}

extension Version: CustomStringConvertible {
public var description: String { versionString }
}

// MARK: - Codable

extension Version: Codable {

extension Version: Decodable {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let value = try container.decode(String.self)
self.init(stringLiteral: value)
try self.init(try String(from: decoder))
}

public func encode(to encoder: any Encoder) throws {
try versionString.encode(to: encoder)
}
}

Expand All @@ -37,11 +68,7 @@ public extension Version {

let normalizedVersionString = versionString.trimmingCharacters(in: .whitespacesAndNewlines)

guard let version = Version.init(normalizedVersionString) else {
throw Error("Failed to parse version from string \(normalizedVersionString)")
}

return version
return try Version(normalizedVersionString)
}
}

Expand All @@ -55,9 +82,7 @@ public extension Version {
Version(
self.major + 1,
0,
0,
prereleaseIdentifiers: prereleaseIdentifiers,
buildMetadataIdentifiers: buildMetadataIdentifiers
0
)
}

Expand All @@ -68,9 +93,7 @@ public extension Version {
Version(
self.major,
self.minor + 1,
0,
prereleaseIdentifiers: prereleaseIdentifiers,
buildMetadataIdentifiers: buildMetadataIdentifiers
0
)
}

Expand All @@ -81,17 +104,16 @@ public extension Version {
Version(
self.major,
self.minor,
self.patch + 1,
prereleaseIdentifiers: prereleaseIdentifiers,
buildMetadataIdentifiers: buildMetadataIdentifiers
self.patch + 1
)
}
}

// MARK: - ExpressibleByArgument

extension Version: ExpressibleByArgument {

public init?(argument: String) {
self.init(argument)
try? self.init(argument)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ArgumentParser
import Foundation
import PackageDescription
import AWSCLIUtils

// MARK: - Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ArgumentParser
import Foundation
import PackageDescription
import AWSCLIUtils

// MARK: - Command
Expand Down Expand Up @@ -147,7 +146,7 @@ struct PrepareRelease {
func createNewVersion(_ previousVersion: Version) throws -> Version {
let newVersion = previousVersion.incrementingMinor()
do {
try "\(newVersion)".write(toFile: "Package.version" , atomically: true, encoding: .utf8)
try "\(newVersion)".write(toFile: "Package.version" , atomically: true, encoding: .utf8)
} catch {
throw Error("Failed to write version \(newVersion) to Package.version")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ArgumentParser
import Foundation
import PackageDescription
import AWSCLIUtils

// MARK: - Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Algorithms
import ArgumentParser
import Foundation
import PackageDescription
import AWSCLIUtils

// MARK: - Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription
import AWSCLIUtils

/// Builds the contents of the package manifest file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import PackageDescription
import AWSCLIUtils

/// `PackageDependencies` is a representation of contents of the .plist stored at packageDependencies.plist
struct PackageDependencies: Codable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription
import AWSCLIUtils

/// Builds the contents of the package manifest file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription

struct ReleaseManifest: Codable {
let name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import PackageDescription
import AWSCLIUtils

// Builds the release notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

@testable import AWSSDKSwiftCLI
import PackageDescription
import AWSCLIUtils
import XCTest

class GeneratePackageManifestTests: CLITestCase {
Expand All @@ -16,10 +16,10 @@ class GeneratePackageManifestTests: CLITestCase {
func createPackageDependencies(
crtVersion: String,
clientRuntimeVersion: String
) {
let packageDependencies = PackageDependencies(
awsCRTSwiftVersion: .init(crtVersion)!,
clientRuntimeVersion: .init(clientRuntimeVersion)!
) throws {
let packageDependencies = try PackageDependencies(
awsCRTSwiftVersion: .init(crtVersion),
clientRuntimeVersion: .init(clientRuntimeVersion)
)
try! packageDependencies.save()
}
Expand All @@ -41,11 +41,11 @@ class GeneratePackageManifestTests: CLITestCase {

// MARK: Golden Path

func testGoldenPath() {
func testGoldenPath() throws {
let clientRuntimeVersion = "1.2.3"
let crtVersion = "3.2.1"
let services = ["EC2", "S3"]
createPackageDependencies(
try createPackageDependencies(
crtVersion: crtVersion,
clientRuntimeVersion: clientRuntimeVersion
)
Expand All @@ -61,10 +61,10 @@ class GeneratePackageManifestTests: CLITestCase {

// MARK: resolveVersions()

func testResolveVersionsRetrievesVersionsFromPackageDependencies() {
func testResolveVersionsRetrievesVersionsFromPackageDependencies() throws {
let clientRuntimeVersion = "1.2.3"
let crtVersion = "3.2.1"
createPackageDependencies(
try createPackageDependencies(
crtVersion: crtVersion,
clientRuntimeVersion: clientRuntimeVersion
)
Expand All @@ -74,10 +74,10 @@ class GeneratePackageManifestTests: CLITestCase {
XCTAssertEqual(versions.crt.description, crtVersion)
}

func testResolveVersionsWithExplicitVersions() {
func testResolveVersionsWithExplicitVersions() throws {
let clientRuntimeVersion = "1.2.3"
let crtVersion = "3.2.1"
let subject = GeneratePackageManifest.mock(
let subject = try GeneratePackageManifest.mock(
clientRuntimeVersion: .init(clientRuntimeVersion),
crtVersion: .init(crtVersion)
)
Expand Down
Loading

0 comments on commit 036edec

Please sign in to comment.