Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jbe/spr2
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Oct 29, 2024
2 parents 548c035 + 4a34c89 commit 3c07859
Show file tree
Hide file tree
Showing 121 changed files with 6,583 additions and 1,142 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Package.resolved
build/
codegen/protocol-test-codegen-local/smithy-build.json
codegen/protocol-test-codegen/smithy-build.json
SmokeTests/

# vim temporary files
*.swp
Expand Down
1 change: 1 addition & 0 deletions AWSSDKSwiftCLI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let package = Package(
resources: [
.process("Resources/Package.Prefix.txt"),
.process("Resources/Package.Base.txt"),
.process("Resources/SmokeTestsPackage.Base.txt"),
.process("Resources/DocIndex.Base.md")
]
),
Expand Down
13 changes: 13 additions & 0 deletions AWSSDKSwiftCLI/Sources/AWSCLIUtils/FileManager+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ public extension FileManager {
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of services that have smoke tests and test runner generated for them.
/// Service names are extracted from service name prefix of directory names under `SmokeTests/`.
/// E.g., extract `AWSS3` from `SmokeTests/AWSS3SmokeTestRunner/`.
///
/// - Returns: The list of services with generated smoke tests.
func servicesWithSmokeTests() throws -> [String] {
try FileManager.default
.contentsOfDirectory(atPath: "SmokeTests")
.sorted()
.filter { !$0.hasPrefix(".") && $0.hasSuffix("SmokeTestRunner") }
.map { $0.replacingOccurrences(of: "SmokeTestRunner", with: "") }
}

/// Returns the list of Smithy runtime modules within `../smithy-swift/Sources/Core`
///
/// - Returns: The list of Smithy runtime modules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ struct AWSSDKSwiftCLI: ParsableCommand {
PrepareReleaseCommand.self,
SyncClientRuntimeVersionCommand.self,
TestAWSSDKCommand.self,
GenerateDocIndexCommand.self
GenerateDocIndexCommand.self,
GenerateSmokeTestsPackageManifestCommand.self
]
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import ArgumentParser
import Foundation
import AWSCLIUtils

struct GenerateSmokeTestsPackageManifestCommand: ParsableCommand {
static var configuration = CommandConfiguration(
commandName: "generate-smoke-tests-package-manifest",
abstract: "Generates the Package.swift manifest for the aws-sdk-swift/SmokeTests package."
)

@Argument(help: "The path to the aws-sdk-swift repository")
var repoPath: String

func run() throws {
let generateSmokeTestsPackageManifest = GenerateSmokeTestsPackageManifest(
repoPath: repoPath
)
try generateSmokeTestsPackageManifest.run()
}
}

struct GenerateSmokeTestsPackageManifest {
/// The path to the package repository
let repoPath: String

func run() throws {
try FileManager.default.changeWorkingDirectory(repoPath)
// Generate package manifest for smoke tests and save it as aws-sdk-swift/SmokeTests/Package.swift
let smokeTestsContents = try generateSmokeTestsPackageManifestContents()
try savePackageManifest(smokeTestsContents)
}

// MARK: - Helpers

func generateSmokeTestsPackageManifestContents() throws -> String {
return [
// SmokeTests package manifest uses same prefix as one for aws-sdk-swift.
try PackageManifestBuilder.contentReader(filename: "Package.Prefix")(),
try generateServiceNamesArray(),
try PackageManifestBuilder.contentReader(filename: "SmokeTestsPackage.Base")()
].joined(separator: .newline)
}

func generateServiceNamesArray() throws -> String {
let servicesWithSmokeTests = try FileManager.default.servicesWithSmokeTests()
let formatedServiceList = servicesWithSmokeTests.map { "\t\"\($0)\"," }.joined(separator: .newline)
return [
"// All services that have smoke tests generated for them.",
"let serviceNames: [String] = [",
formatedServiceList,
"]"
].joined(separator: .newline)
}

func savePackageManifest(_ contents: String) throws {
let packageFilePath = "SmokeTests/Package.swift"
log("Saving package manifest to \(packageFilePath)...")
try contents.write(
toFile: packageFilePath,
atomically: true,
encoding: .utf8
)
log("Successfully saved package manifest to \(packageFilePath)")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// MARK: - Static Content

extension Target.Dependency {
// AWS runtime module
static var awsClientRuntime: Self { .product(name: "AWSClientRuntime", package: "aws-sdk-swift") }
// Smithy runtime module
static var clientRuntime: Self { .product(name: "ClientRuntime", package: "smithy-swift") }
}

let package = Package(
name: "SmokeTests",
platforms: [
.macOS(.v10_15)
],
products: serviceNames.map(productForRunner(_:)),
dependencies: [
.package(path: "../../smithy-swift"),
.package(path: "../../aws-sdk-swift")
],
targets: serviceNames.map(targetForRunner(_:))
)

// MARK: - Helper functions

private func productForRunner(_ serviceName: String) -> Product {
.executable(name: "\(serviceName)SmokeTestRunner", targets: ["\(serviceName)SmokeTestRunner"])
}

private func targetForRunner(_ serviceName: String) -> Target {
.executableTarget(
name: "\(serviceName)SmokeTestRunner",
dependencies: [
.clientRuntime,
.awsClientRuntime,
.product(name: "\(serviceName)", package: "aws-sdk-swift")
],
path: "\(serviceName)SmokeTestRunner"
)
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import PackageDescription

// MARK: - Dynamic Content

let clientRuntimeVersion: Version = "0.84.0"
let clientRuntimeVersion: Version = "0.86.0"
let crtVersion: Version = "0.37.0"

let packageScope = "aws-sdk-swift"
Expand Down
2 changes: 1 addition & 1 deletion Package.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.27
1.0.30
2 changes: 1 addition & 1 deletion Package.version.next
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.28
1.0.31
Empty file added SmokeTests/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions Sources/Services/AWSAutoScaling/Package.swift.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ let package = Package(
name: "AWSAutoScaling",
dependencies: [
.product(
name: "SmithyHTTPAuthAPI",
name: "ClientRuntime",
package: "aws-sdk-swift.smithy-swift"
),
.product(
name: "Smithy",
name: "SmithyHTTPAuthAPI",
package: "aws-sdk-swift.smithy-swift"
),
.product(
name: "ClientRuntime",
name: "Smithy",
package: "aws-sdk-swift.smithy-swift"
),
.product(
Expand Down
6 changes: 3 additions & 3 deletions Sources/Services/AWSBatch/Package.swift.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ let package = Package(
name: "AWSBatch",
dependencies: [
.product(
name: "SmithyHTTPAuthAPI",
name: "ClientRuntime",
package: "aws-sdk-swift.smithy-swift"
),
.product(
name: "Smithy",
name: "SmithyHTTPAuthAPI",
package: "aws-sdk-swift.smithy-swift"
),
.product(
name: "ClientRuntime",
name: "Smithy",
package: "aws-sdk-swift.smithy-swift"
),
.product(
Expand Down
Loading

0 comments on commit 3c07859

Please sign in to comment.