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

chore: Clean up integration test manifest #1856

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
138 changes: 42 additions & 96 deletions IntegrationTests/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import PackageDescription

// MARK: - Target dependencies
Expand All @@ -21,13 +20,10 @@ extension Target.Dependency {
static var awsSDKCommon: Self { .product(name: "AWSSDKCommon", package: "aws-sdk-swift") }
static var awsSDKIdentity: Self { .product(name: "AWSSDKIdentity", package: "aws-sdk-swift") }

// CRT module
static var crt: Self { .product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift") }

// Smithy modules
static var clientRuntime: Self { .product(name: "ClientRuntime", package: "smithy-swift") }
static var smithyIdentity: Self { .product(name: "SmithyIdentity", package: "smithy-swift") }
static var smithyTestUtils: Self { .product(name: "SmithyTestUtil", package: "smithy-swift") }
static var smithyTestUtil: Self { .product(name: "SmithyTestUtil", package: "smithy-swift") }
}

// MARK: - Base Package
Expand All @@ -40,57 +36,33 @@ let package = Package(
.tvOS(.v13),
.watchOS(.v6)
],
targets: [
.target(
name: "AWSIntegrationTestUtils",
path: "./AWSIntegrationTestUtils"
)
]
dependencies: [
.package(path: "../../smithy-swift"),
.package(path: "../../aws-sdk-swift"),
],
targets: integrationTestTargets
)

// MARK: - CRT, Smithy ClientRuntime, AWS ClientRuntime Dependencies

func addDependencies() {
addRuntimeDependencies()
addCRTDependency()
}

func addRuntimeDependencies() {
let smithySwiftURL = "https://github.com/smithy-lang/smithy-swift"
let awsSDKSwiftURL = "https://github.com/awslabs/aws-sdk-swift"
let useLocalDeps = ProcessInfo.processInfo.environment["AWS_SWIFT_SDK_USE_LOCAL_DEPS"] != nil
let useMainDeps = ProcessInfo.processInfo.environment["AWS_SWIFT_SDK_USE_MAIN_DEPS"] != nil
switch (useLocalDeps, useMainDeps) {
case (true, true):
fatalError("Unable to determine which dependencies to use. Please only specify one of AWS_SWIFT_SDK_USE_LOCAL_DEPS or AWS_SWIFT_SDK_USE_MAIN_DEPS.")
case (true, false):
package.dependencies += [
.package(path: "../../smithy-swift"),
.package(path: "../../aws-sdk-swift")
]
case (false, true):
package.dependencies += [
.package(url: smithySwiftURL, branch: "main"),
.package(url: awsSDKSwiftURL, branch: "main")
]
case (false, false):
package.dependencies += [
.package(url: smithySwiftURL, .upToNextMajor(from: "0.0.0")),
.package(url: awsSDKSwiftURL, .upToNextMajor(from: "0.0.0"))
]
}
private var integrationTestTargets: [Target] {
let integrationTests = [
"AWSCloudFrontKeyValueStore",
"AWSEC2",
"AWSECS",
"AWSEventBridge",
"AWSGlacier",
"AWSKinesis",
"AWSMediaConvert",
"AWSRoute53",
"AWSS3",
"AWSSQS",
"AWSSTS",
"AWSTranscribeStreaming",
"AWSCognitoIdentity",
].map { integrationTestTarget($0) }
return integrationTests + [.target(name: "AWSIntegrationTestUtils", path: "./AWSIntegrationTestUtils")]
}

func addCRTDependency() {
package.dependencies += [
.package(url: "https://github.com/awslabs/aws-crt-swift", .upToNextMajor(from: "0.0.0"))
]
}

// MARK: - Integration test target helper functions


func addIntegrationTestTarget(_ name: String) {
private func integrationTestTarget(_ name: String) -> Target {
let integrationTestName = "\(name)IntegrationTests"
var additionalDependencies: [String] = []
var exclusions: [String] = []
Expand Down Expand Up @@ -121,48 +93,22 @@ func addIntegrationTestTarget(_ name: String) {
default:
break
}
package.targets += [
.testTarget(
name: integrationTestName,
dependencies: [
.crt,
.clientRuntime,
.awsClientRuntime,
.smithyTestUtils,
.awsSDKIdentity,
.smithyIdentity,
.awsSDKCommon,
.awsIntegrationTestUtils,
.product(name: name, package: "aws-sdk-swift")
] + additionalDependencies.map {
Target.Dependency.product(name: $0, package: "aws-sdk-swift", condition: nil)
},
path: "./Services/\(integrationTestName)",
exclude: exclusions,
resources: [.process("Resources")]
)
]
return .testTarget(
name: integrationTestName,
dependencies: [
.clientRuntime,
.awsClientRuntime,
.smithyTestUtil,
.awsSDKIdentity,
.smithyIdentity,
.awsSDKCommon,
.awsIntegrationTestUtils,
.product(name: name, package: "aws-sdk-swift")
] + additionalDependencies.map {
Target.Dependency.product(name: $0, package: "aws-sdk-swift", condition: nil)
},
path: "./Services/\(integrationTestName)",
exclude: exclusions,
resources: [.process("Resources")]
)
}

let servicesWithIntegrationTests: [String] = [
"AWSCloudFrontKeyValueStore",
"AWSEC2",
"AWSECS",
"AWSEventBridge",
"AWSGlacier",
"AWSKinesis",
"AWSMediaConvert",
"AWSRoute53",
"AWSS3",
"AWSSQS",
"AWSSTS",
"AWSTranscribeStreaming",
"AWSCognitoIdentity",
]

func addIntegrationTests() {
servicesWithIntegrationTests.forEach { addIntegrationTestTarget($0) }
}

addDependencies()
addIntegrationTests()
Loading