Skip to content

Commit

Permalink
merge 'main' into otel-swift
Browse files Browse the repository at this point in the history
  • Loading branch information
dayaffe committed Aug 20, 2024
2 parents 918bc08 + ee75889 commit ffe332a
Show file tree
Hide file tree
Showing 549 changed files with 86,344 additions and 25,687 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/generate-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ jobs:
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- name: Checkout Sources
- name: Checkout aws-sdk-swift
uses: actions/checkout@v4
- name: Checkout smithy-swift
uses: actions/checkout@v4
with:
repository: smithy-lang/smithy-swift
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -50,10 +57,16 @@ jobs:
echo "Error: runs on a tag only"
exit 1
fi
- name: Generate docs
- name: Generate aws-sdk-swift docs
run: |
DOCS_BUCKET=${{ secrets.CD_API_REFS_BUCKET_NAME }} \
./scripts/generatedocc.sh "$VERSION" ${{ matrix.job }} ${{ strategy.job-total }} ${{ env.IGNORE }} ${{ 1 }}
- name: Generate smithy-swift docs
run: |
cd ../smithy-swift
DOCS_BUCKET=${{ secrets.CD_API_REFS_BUCKET_NAME }} \
./scripts/generatedocc.sh "$VERSION" ${{ matrix.job }} ${{ strategy.job-total }} ${{ env.IGNORE }}
./../aws-sdk-swift/scripts/generatedocc.sh "$VERSION" ${{ matrix.job }} ${{ strategy.job-total }} ${{ env.IGNORE }} ${{ 0 }}
cd ../aws-sdk-swift
update-latest:
needs: generate-docs
runs-on: ubuntu-latest
Expand Down
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
22 changes: 22 additions & 0 deletions AWSSDKSwiftCLI/Sources/AWSCLIUtils/FileManager+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ public extension FileManager {
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of Smithy runtime modules within `../smithy-swift/Sources/Core`
///
/// - Returns: The list of Smithy runtime modules.
func getSmithyRuntimeModules() throws -> [String] {
try FileManager.default
.contentsOfDirectory(atPath: "../smithy-swift/Sources")
.sorted()
.filter { $0 != "libxml2" } // Ignore libxml module
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of AWS runtime modules within `Sources/Core`
///
/// - Returns: The list of AWS runtime modules.
func getAWSRuntimeModules() throws -> [String] {
try FileManager.default
.contentsOfDirectory(atPath: "Sources/Core")
.sorted()
.filter { $0 != "AWSSDKForSwift" } // Ignore documentation module
.filter { !$0.hasPrefix(".") }
}

/// Returns the list of integration tests.
///
/// - Returns: The list of integration tests.
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 @@ -34,8 +34,14 @@ struct GenerateDocIndexCommand: ParsableCommand {
/// - Returns: The contents of the generated doc index.
func generateDocIndexContents() throws -> String {
let services = try resolveServices()
let smithyRuntimeModules = try resolveSmithyRuntimeModules()
let awsRuntimeModules = try resolveAWSRuntimeModules()
log("Creating doc index contents...")
let contents = try DocIndexBuilder(services: services).build()
let contents = try DocIndexBuilder(
services: services,
smithyRuntimeModules: smithyRuntimeModules,
awsRuntimeModules: awsRuntimeModules
).build()
log("Successfully created doc index contents")
return contents
}
Expand Down Expand Up @@ -68,4 +74,28 @@ struct GenerateDocIndexCommand: ParsableCommand {
log("Resolved list of services: \(resolvedServices.count)")
return resolvedServices
}

/// Returns the list of Smithy runtime modules within `../smithy-swift/Sources/Core` to include in the doc index.
///
/// - Returns: The list of Smithy runtime moduls to include in the doc index
func resolveSmithyRuntimeModules() throws -> [String] {
log("Resolving Smithy runtime modules...")
let resolvedSmithyRuntimeModules: [String]
log("Using list of Smithy runtime modules that exist within ../smithy-swift/Sources/Core")
resolvedSmithyRuntimeModules = try FileManager.default.getSmithyRuntimeModules()
log("Resolved list of Smithy runtime modules: \(resolvedSmithyRuntimeModules.count)")
return resolvedSmithyRuntimeModules
}

/// Returns the list of AWS runtime modules within `Sources/Core` to include in the doc index.
///
/// - Returns: The list of AWS runtime moduls to include in the doc index
func resolveAWSRuntimeModules() throws -> [String] {
log("Resolving AWS runtime modules...")
let resolvedAWSRuntimeModules: [String]
log("Using list of AWS runtime modules that exist within Sources/Core")
resolvedAWSRuntimeModules = try FileManager.default.getAWSRuntimeModules()
log("Resolved list of AWS runtime modules: \(resolvedAWSRuntimeModules.count)")
return resolvedAWSRuntimeModules
}
}
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
Loading

0 comments on commit ffe332a

Please sign in to comment.