Skip to content

Commit

Permalink
chore: Clean up integration test manifest (#1856)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins authored Jan 7, 2025
1 parent 9221899 commit c0ea59d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 96 deletions.
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()
Empty file.

0 comments on commit c0ea59d

Please sign in to comment.