From 231adf4fceaf02a7fb1d6bb3ad91c3b02676eb34 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 10:35:44 -0500 Subject: [PATCH 01/21] chore: Run CLI unit tests in CI --- .github/workflows/continuous-integration.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ab5ca4f7c1d..ada9da6a34e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -101,6 +101,13 @@ jobs: java-version: 17 - name: Tools Versions run: ./scripts/ci_steps/log_tool_versions.sh + - name: Run CLI Unit Tests + if: ${{ matrix.destination == 'platform=macOS' && matrix.runner == 'macos-15' }} + run: | + cd AWSSDKSwiftCLI + swift test + cd ../SPRCLI + swift test - name: Prepare Protocol & Unit Tests run: | ./scripts/ci_steps/prepare_protocol_and_unit_tests.sh From f18b7e8bf36d2b8f95220b37718c3221c08cf1eb Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 10:47:08 -0500 Subject: [PATCH 02/21] Fix 'Failed to load data for file at path ../build-request.json' error --- .../Subcommands/PrepareRelease.swift | 7 +++++-- .../AWSSDKSwiftCLI/Models/Features.swift | 19 ++++++++++--------- .../Models/ReleaseNotesBuilder.swift | 7 +++---- .../Models/ReleaseNotesBuilderTests.swift | 6 ++---- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift index 1d21c45ea1c..9fd1ec4828f 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift @@ -235,13 +235,16 @@ struct PrepareRelease { previousVersion: Version ) throws { let commits = try Process.git.listOfCommitsBetween("HEAD", "\(previousVersion)") - + let featuresReader = FeaturesReader(repoPath: repoPath) + let releaseNotes = try ReleaseNotesBuilder( previousVersion: previousVersion, newVersion: newVersion, repoOrg: repoOrg, repoType: repoType, - commits: commits + commits: commits, + features: featuresReader.getFeaturesFromFile(), + featuresIDToServiceName: featuresReader.getFeaturesIDToServiceNameDictFromFile() ).build() let manifest = ReleaseManifest( diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift index 93e749c74ed..b309a7d8420 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift @@ -8,25 +8,26 @@ import Foundation import AWSCLIUtils -struct FeaturesReader: Decodable { - private let requestFilePath: String - private let mappingFilePath: String +struct FeaturesReader { + private let repoPath: String + private let requestFile = "build-request.json" + private let mappingFile = "feature-service-id.json" public init( - requestFilePath: String = "../build-request.json", - mappingFilePath: String = "../feature-service-id.json" + repoPath: String = "." ) { - self.requestFilePath = requestFilePath - self.mappingFilePath = mappingFilePath + self.repoPath = repoPath } public func getFeaturesFromFile() throws -> Features { - let fileContents = try FileManager.default.loadContents(atPath: requestFilePath) + let path = URL(filePath: repoPath).appending(component: requestFile).path() + let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode(Features.self, from: fileContents) } public func getFeaturesIDToServiceNameDictFromFile() throws -> [String: String] { - let fileContents = try FileManager.default.loadContents(atPath: mappingFilePath) + let path = URL(filePath: repoPath).appending(component: mappingFile).path() + let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode([String: String].self, from: fileContents) } } diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/ReleaseNotesBuilder.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/ReleaseNotesBuilder.swift index 43ce814578b..b2a6f9a32b6 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/ReleaseNotesBuilder.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/ReleaseNotesBuilder.swift @@ -15,7 +15,8 @@ struct ReleaseNotesBuilder { let repoOrg: PrepareRelease.Org let repoType: PrepareRelease.Repo let commits: [String] - var featuresReader: FeaturesReader = FeaturesReader() + let features: Features + let featuresIDToServiceName: [String: String] // MARK: - Build @@ -41,9 +42,7 @@ struct ReleaseNotesBuilder { } func buildServiceChangeSection() throws -> [String] { - let features = try featuresReader.getFeaturesFromFile() - let mapping = try featuresReader.getFeaturesIDToServiceNameDictFromFile() - return buildServiceFeatureSection(features, mapping) + buildServiceDocSection(features, mapping) + return buildServiceFeatureSection(features, featuresIDToServiceName) + buildServiceDocSection(features, featuresIDToServiceName) } private func buildServiceFeatureSection( diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift index ee1ee2f8958..bfa3a88ec4d 100644 --- a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift @@ -209,10 +209,8 @@ class ReleaseNotesBuilderTests: XCTestCase { repoType: .awsSdkSwift, commits: testCommits, // Parametrize behavior of FeaturesReader with paths used to create JSON test files - featuresReader: FeaturesReader( - requestFilePath: "build-request.json", - mappingFilePath: "feature-service-id.json" - ) + features: FeaturesReader().getFeaturesFromFile(), + featuresIDToServiceName: FeaturesReader().getFeaturesIDToServiceNameDictFromFile() ) } } From dd803d8256e800d67b6571d081fa8f984095311c Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:04:29 -0500 Subject: [PATCH 03/21] Fix SPRCLI tests, fix path methods --- .github/workflows/continuous-integration.yml | 1 + AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ada9da6a34e..fc2df70cca5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -107,6 +107,7 @@ jobs: cd AWSSDKSwiftCLI swift test cd ../SPRCLI + unset AWS_SWIFT_SDK_USE_LOCAL_DEPS swift test - name: Prepare Protocol & Unit Tests run: | diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift index b309a7d8420..931e2759233 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift @@ -20,13 +20,13 @@ struct FeaturesReader { } public func getFeaturesFromFile() throws -> Features { - let path = URL(filePath: repoPath).appending(component: requestFile).path() + let path = URL(filePath: repoPath).appendingPathComponent(requestFile, isDirectory: false).path let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode(Features.self, from: fileContents) } public func getFeaturesIDToServiceNameDictFromFile() throws -> [String: String] { - let path = URL(filePath: repoPath).appending(component: mappingFile).path() + let path = URL(filePath: repoPath).appendingPathComponent(mappingFile, isDirectory: false).path let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode([String: String].self, from: fileContents) } From e26ee0dd8b0bb01fcf2fbcf9a5bda71a5e5c14b0 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:11:48 -0500 Subject: [PATCH 04/21] Remove reference to PackageDescription from SPRCLI --- SPRCLI/Sources/SPR/Process+SPR.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/SPRCLI/Sources/SPR/Process+SPR.swift b/SPRCLI/Sources/SPR/Process+SPR.swift index 513c162a3cc..e6c2e4c5179 100644 --- a/SPRCLI/Sources/SPR/Process+SPR.swift +++ b/SPRCLI/Sources/SPR/Process+SPR.swift @@ -6,7 +6,6 @@ // import Foundation -import PackageDescription import AWSCLIUtils extension Process { From 5c17a4d136f15178e3bbc6f09aa6c0996a10657c Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:18:33 -0500 Subject: [PATCH 05/21] Use older form of file URL initializer --- AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift index 931e2759233..7e9e94f1392 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift @@ -20,13 +20,13 @@ struct FeaturesReader { } public func getFeaturesFromFile() throws -> Features { - let path = URL(filePath: repoPath).appendingPathComponent(requestFile, isDirectory: false).path + let path = URL(fileURLWithPath: repoPath).appendingPathComponent(requestFile, isDirectory: false).path let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode(Features.self, from: fileContents) } public func getFeaturesIDToServiceNameDictFromFile() throws -> [String: String] { - let path = URL(filePath: repoPath).appendingPathComponent(mappingFile, isDirectory: false).path + let path = URL(fileURLWithPath: repoPath).appendingPathComponent(mappingFile, isDirectory: false).path let fileContents = try FileManager.default.loadContents(atPath: path) return try JSONDecoder().decode([String: String].self, from: fileContents) } From e6aa350db0c9df022b7b7124dd9e621c55f890a0 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:30:13 -0500 Subject: [PATCH 06/21] Fix SPRCLI build, move it to AWS SDK 1.0+ --- SPRCLI/Package.swift | 2 +- SPRCLI/Sources/SPR/SPRPublisher.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SPRCLI/Package.swift b/SPRCLI/Package.swift index 24cded5cd2b..5aaf8a7c057 100644 --- a/SPRCLI/Package.swift +++ b/SPRCLI/Package.swift @@ -9,7 +9,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"), - .package(url: "https://github.com/awslabs/aws-sdk-swift", from: "0.46.0"), + .package(url: "https://github.com/awslabs/aws-sdk-swift", from: "1.0.0"), .package(path: "../AWSSDKSwiftCLI"), ], targets: [ diff --git a/SPRCLI/Sources/SPR/SPRPublisher.swift b/SPRCLI/Sources/SPR/SPRPublisher.swift index 681b0875b34..c9798f8413e 100644 --- a/SPRCLI/Sources/SPR/SPRPublisher.swift +++ b/SPRCLI/Sources/SPR/SPRPublisher.swift @@ -65,7 +65,7 @@ public struct SPRPublisher { } private mutating func setOptions() async { - await SDKLoggingSystem.initialize(logLevel: .error) + await SDKLoggingSystem().initialize(logLevel: .error) let env = ProcessInfo.processInfo.environment bucket = bucket ?? env["AWS_SDK_SPR_BUCKET"] if region.isEmpty { From 45a3bbf4966da4b4efbc7a3ad36013be4b6b3ae5 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:35:37 -0500 Subject: [PATCH 07/21] Move CI from macos-13 to macos-14 --- .github/workflows/continuous-integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fc2df70cca5..e98d3d5c847 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -15,7 +15,7 @@ jobs: matrix: # This matrix runs tests on iOS sim & Mac, on oldest & newest supported Xcodes runner: - - macos-13 + - macos-14 - macos-15 xcode: - Xcode_15.2 @@ -30,7 +30,7 @@ jobs: - 'platform=macOS' exclude: # Don't run old macOS with new Xcode - - runner: macos-13 + - runner: macos-14 xcode: Xcode_16 # Don't run new macOS with old Xcode - runner: macos-15 @@ -102,7 +102,7 @@ jobs: - name: Tools Versions run: ./scripts/ci_steps/log_tool_versions.sh - name: Run CLI Unit Tests - if: ${{ matrix.destination == 'platform=macOS' && matrix.runner == 'macos-15' }} + if: ${{ matrix.destination == 'platform=macOS' }} run: | cd AWSSDKSwiftCLI swift test From 1288bf2eb933180dd722c6006271473dc1c080fc Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 11:59:17 -0500 Subject: [PATCH 08/21] build SPRCLI only, no tests --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e98d3d5c847..87523c8ee9c 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -108,7 +108,7 @@ jobs: swift test cd ../SPRCLI unset AWS_SWIFT_SDK_USE_LOCAL_DEPS - swift test + swift build - name: Prepare Protocol & Unit Tests run: | ./scripts/ci_steps/prepare_protocol_and_unit_tests.sh From c5bffb5750221c202f2a2cd3321fa19f1a36627a Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 12:45:13 -0500 Subject: [PATCH 09/21] Run CLI unit tests on Linux too --- .github/workflows/continuous-integration.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 87523c8ee9c..524c32eb5d3 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -190,6 +190,13 @@ jobs: run: ./scripts/ci_steps/install_native_linux_dependencies.sh - name: Tools Versions run: ./scripts/ci_steps/log_tool_versions.sh + - name: Run CLI Unit Tests + run: | + cd AWSSDKSwiftCLI + swift test + cd ../SPRCLI + unset AWS_SWIFT_SDK_USE_LOCAL_DEPS + swift build - name: Prepare Protocol & Unit Tests run: | ./scripts/ci_steps/prepare_protocol_and_unit_tests.sh From 17f8c725764efa6fdedddb1ba53196ed79e36a2d Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 13:11:32 -0500 Subject: [PATCH 10/21] Update path references --- SPRCLI/Sources/SPR/UpdateList.swift | 6 +++--- SPRCLI/Sources/SPR/UploadArchive.swift | 2 +- SPRCLI/Sources/SPR/UploadManifest.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SPRCLI/Sources/SPR/UpdateList.swift b/SPRCLI/Sources/SPR/UpdateList.swift index 1e6aa876b3b..40769c6c958 100644 --- a/SPRCLI/Sources/SPR/UpdateList.swift +++ b/SPRCLI/Sources/SPR/UpdateList.swift @@ -63,9 +63,9 @@ extension SPRPublisher { throw Error("URL is invalid") } return baseURL - .appending(component: scope) - .appending(component: name) - .appending(component: version) + .appendingPathComponent(scope) + .appendingPathComponent(name) + .appendingPathComponent(version) } } } diff --git a/SPRCLI/Sources/SPR/UploadArchive.swift b/SPRCLI/Sources/SPR/UploadArchive.swift index 4298d47f6ba..edf53311983 100644 --- a/SPRCLI/Sources/SPR/UploadArchive.swift +++ b/SPRCLI/Sources/SPR/UploadArchive.swift @@ -15,7 +15,7 @@ extension SPRPublisher { mutating func uploadArchive() async throws { let tmpDirFileURL = FileManager.default.temporaryDirectory - let archiveFileURL = tmpDirFileURL.appending(component: "\(UUID().uuidString).zip") + let archiveFileURL = tmpDirFileURL.appendingPathComponent("\(UUID().uuidString).zip") let archiveProcess = Process.SPR.archive(name: name, packagePath: path, archiveFileURL: archiveFileURL) _ = try _runReturningStdOut(archiveProcess) guard FileManager.default.fileExists(atPath: urlPath(archiveFileURL)) else { diff --git a/SPRCLI/Sources/SPR/UploadManifest.swift b/SPRCLI/Sources/SPR/UploadManifest.swift index 99e54001700..13ad90d68da 100644 --- a/SPRCLI/Sources/SPR/UploadManifest.swift +++ b/SPRCLI/Sources/SPR/UploadManifest.swift @@ -15,7 +15,7 @@ extension SPRPublisher { func uploadManifest() async throws { let packageFileURL = URL(fileURLWithPath: path).standardizedFileURL - let manifestFileURL = packageFileURL.appending(component: "Package.swift") + let manifestFileURL = packageFileURL.appendingPathComponent("Package.swift") let s3Client = try S3Client(region: region) try await verify(s3Client: s3Client) try await upload(s3Client: s3Client, manifestFileURL: manifestFileURL) From 84d92202da90124122dc704ad00543531849c936 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 13:13:53 -0500 Subject: [PATCH 11/21] Fix date formatter --- SPRCLI/Sources/SPR/UploadMetadata.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SPRCLI/Sources/SPR/UploadMetadata.swift b/SPRCLI/Sources/SPR/UploadMetadata.swift index f1af783de45..3e192320df1 100644 --- a/SPRCLI/Sources/SPR/UploadMetadata.swift +++ b/SPRCLI/Sources/SPR/UploadMetadata.swift @@ -47,7 +47,8 @@ extension SPRPublisher { } private func createMetadata() -> PackageInfo { - let now = Date().ISO8601Format() + let formatter = ISO8601DateFormatter() + let now = formatter.string(from: Date()) let organization = PackageInfo.Metadata.Author.Organization(name: "Amazon Web Services", email: nil, description: nil, url: URL(string: "https://aws.amazon.com/")!) let author = PackageInfo.Metadata.Author(name: "AWS SDK for Swift Team", email: nil, description: nil, organization: organization, url: nil) let resource = Resource(name: "source-archive", type: "application/zip", checksum: checksum, signing: nil) From cdd65acedfbdeb9b3f189d21e33c1770179cd599 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 15:09:05 -0500 Subject: [PATCH 12/21] Dummy build request & mapping files added --- build-request.json | 31 +++++++++++++++++++++++++++++++ feature-service-id.json | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 build-request.json create mode 100644 feature-service-id.json diff --git a/build-request.json b/build-request.json new file mode 100644 index 00000000000..f0eef7bbd4e --- /dev/null +++ b/build-request.json @@ -0,0 +1,31 @@ +{ + "features": [ + { + "releaseNotes": "New feature description A.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-a", + "featureType": "NEW_FEATURE" + } + } + }, + { + "releaseNotes": "New feature description B.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-b", + "featureType": "NEW_FEATURE" + } + } + }, + { + "releaseNotes": "Doc update description C.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-c", + "featureType": "DOC_UPDATE" + } + } + } + ] +} diff --git a/feature-service-id.json b/feature-service-id.json new file mode 100644 index 00000000000..dddab1daf84 --- /dev/null +++ b/feature-service-id.json @@ -0,0 +1,7 @@ +{ + "feature-id-a": "Service 1", + "feature-id-b": "Service 2", + "feature-id-c": "Service 3", + "feature-id-d": "Service 4" +} + From 97822798f0530dadea71248dfe4d4b55e1cf94b8 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 15:26:39 -0500 Subject: [PATCH 13/21] FeaturesReader now always reads from CWD --- .../Subcommands/PrepareRelease.swift | 4 ++-- .../Sources/AWSSDKSwiftCLI/Models/Features.swift | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift index 9fd1ec4828f..8052a3017f1 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/PrepareRelease.swift @@ -76,7 +76,7 @@ struct PrepareRelease { let diffChecker: DiffChecker /// Prepares a release for the specified repository. - /// If the respository doesn't have any changes, then this does nothing. + /// If the repository doesn't have any changes, then this does nothing. func run() throws { try FileManager.default.changeWorkingDirectory(repoPath) @@ -235,7 +235,7 @@ struct PrepareRelease { previousVersion: Version ) throws { let commits = try Process.git.listOfCommitsBetween("HEAD", "\(previousVersion)") - let featuresReader = FeaturesReader(repoPath: repoPath) + let featuresReader = FeaturesReader() let releaseNotes = try ReleaseNotesBuilder( previousVersion: previousVersion, diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift index 7e9e94f1392..b6e1cc345fc 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift @@ -8,26 +8,18 @@ import Foundation import AWSCLIUtils +/// Reads the Trebuchet request & service mapping files from the current working directory. struct FeaturesReader { - private let repoPath: String private let requestFile = "build-request.json" private let mappingFile = "feature-service-id.json" - public init( - repoPath: String = "." - ) { - self.repoPath = repoPath - } - public func getFeaturesFromFile() throws -> Features { - let path = URL(fileURLWithPath: repoPath).appendingPathComponent(requestFile, isDirectory: false).path - let fileContents = try FileManager.default.loadContents(atPath: path) + let fileContents = try FileManager.default.loadContents(atPath: requestFile) return try JSONDecoder().decode(Features.self, from: fileContents) } public func getFeaturesIDToServiceNameDictFromFile() throws -> [String: String] { - let path = URL(fileURLWithPath: repoPath).appendingPathComponent(mappingFile, isDirectory: false).path - let fileContents = try FileManager.default.loadContents(atPath: path) + let fileContents = try FileManager.default.loadContents(atPath: mappingFile) return try JSONDecoder().decode([String: String].self, from: fileContents) } } From 3bba2eb45e6a86208eac33e610e472351a20853b Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 15:30:41 -0500 Subject: [PATCH 14/21] Revert "Dummy build request & mapping files added" This reverts commit cdd65acedfbdeb9b3f189d21e33c1770179cd599. --- build-request.json | 31 ------------------------------- feature-service-id.json | 7 ------- 2 files changed, 38 deletions(-) delete mode 100644 build-request.json delete mode 100644 feature-service-id.json diff --git a/build-request.json b/build-request.json deleted file mode 100644 index f0eef7bbd4e..00000000000 --- a/build-request.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "features": [ - { - "releaseNotes": "New feature description A.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-a", - "featureType": "NEW_FEATURE" - } - } - }, - { - "releaseNotes": "New feature description B.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-b", - "featureType": "NEW_FEATURE" - } - } - }, - { - "releaseNotes": "Doc update description C.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-c", - "featureType": "DOC_UPDATE" - } - } - } - ] -} diff --git a/feature-service-id.json b/feature-service-id.json deleted file mode 100644 index dddab1daf84..00000000000 --- a/feature-service-id.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "feature-id-a": "Service 1", - "feature-id-b": "Service 2", - "feature-id-c": "Service 3", - "feature-id-d": "Service 4" -} - From d3cdd340612dde55187d0fa728acb43cda4418d3 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 16:43:13 -0500 Subject: [PATCH 15/21] Code & tests now fixed to read Trebuchet files from parent of project dir --- .../Sources/AWSSDKSwiftCLI/Models/Features.swift | 6 +++--- .../Tests/AWSSDKSwiftCLITests/CLITestCase.swift | 11 +++++++++++ .../Commands/PrepareReleaseTests.swift | 4 ++-- .../Models/ReleaseNotesBuilderTests.swift | 8 ++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift index b6e1cc345fc..4040a9816a5 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Models/Features.swift @@ -8,10 +8,10 @@ import Foundation import AWSCLIUtils -/// Reads the Trebuchet request & service mapping files from the current working directory. +/// Reads the Trebuchet request & service mapping files from the parent of the current working directory. struct FeaturesReader { - private let requestFile = "build-request.json" - private let mappingFile = "feature-service-id.json" + private let requestFile = "../build-request.json" + private let mappingFile = "../feature-service-id.json" public func getFeaturesFromFile() throws -> Features { let fileContents = try FileManager.default.loadContents(atPath: requestFile) diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/CLITestCase.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/CLITestCase.swift index c5a6698db4c..c37c582451f 100644 --- a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/CLITestCase.swift +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/CLITestCase.swift @@ -11,8 +11,14 @@ import AWSCLIUtils class CLITestCase: XCTestCase { let tmpPath = "tmp" + let projectPath = "aws-sdk-swift-or-smithy-swift" private var originalWorkingDirectory: String! + /// Creates a temp directory that contains a project dir. + /// + /// The project dir is set as CWD when setup is complete. + /// This folder structure permits Trebuchet artifacts to be written in the parent of the project directory. + /// At the conclusion of the test, the tear-down method deletes the entire temp directory. override func setUp() { super.setUp() try? FileManager.default.removeItem(atPath: tmpPath) @@ -23,6 +29,11 @@ class CLITestCase: XCTestCase { ) originalWorkingDirectory = FileManager.default.currentDirectoryPath try! FileManager.default.changeWorkingDirectory(tmpPath) + try! FileManager.default.createDirectory( + atPath: projectPath, + withIntermediateDirectories: false + ) + try! FileManager.default.changeWorkingDirectory(projectPath) } override func tearDown() { diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Commands/PrepareReleaseTests.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Commands/PrepareReleaseTests.swift index fac35a2bc75..974192fc5ab 100644 --- a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Commands/PrepareReleaseTests.swift +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Commands/PrepareReleaseTests.swift @@ -50,10 +50,10 @@ class PrepareReleaseTests: CLITestCase { "features": [] } """ - FileManager.default.createFile(atPath: "build-request.json", contents: Data(buildRequest.utf8)) + FileManager.default.createFile(atPath: "../build-request.json", contents: Data(buildRequest.utf8)) let mapping = "{}" - FileManager.default.createFile(atPath: "feature-service-id.json", contents: Data(mapping.utf8)) + FileManager.default.createFile(atPath: "../feature-service-id.json", contents: Data(mapping.utf8)) let subject = PrepareRelease.mock(repoType: .awsSdkSwift, diffChecker: { _,_ in true }) try! subject.run() diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift index bfa3a88ec4d..bdc1f4c999a 100644 --- a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift @@ -12,7 +12,7 @@ import XCTest /* * Regression tests for protection against change in generated release notes markdown content. */ -class ReleaseNotesBuilderTests: XCTestCase { +class ReleaseNotesBuilderTests: CLITestCase { /* Reusable feature strings */ // New feature 1 @@ -197,8 +197,8 @@ class ReleaseNotesBuilderTests: XCTestCase { // In real scenario, the JSON files we need are located one level above, in the workspace directory. // For tests, due to sandboxing, the dummy files are created in current directory instead of // in parent directory. - FileManager.default.createFile(atPath: "build-request.json", contents: Data(buildRequest.utf8)) - FileManager.default.createFile(atPath: "feature-service-id.json", contents: Data(mapping.utf8)) + FileManager.default.createFile(atPath: "../build-request.json", contents: Data(buildRequest.utf8)) + FileManager.default.createFile(atPath: "../feature-service-id.json", contents: Data(mapping.utf8)) } private func setUpBuilder(testCommits: [String] = []) throws -> ReleaseNotesBuilder { @@ -208,7 +208,7 @@ class ReleaseNotesBuilderTests: XCTestCase { repoOrg: .awslabs, repoType: .awsSdkSwift, commits: testCommits, - // Parametrize behavior of FeaturesReader with paths used to create JSON test files + // Parameterize behavior of FeaturesReader with paths used to create JSON test files features: FeaturesReader().getFeaturesFromFile(), featuresIDToServiceName: FeaturesReader().getFeaturesIDToServiceNameDictFromFile() ) From 465ee53eb3e737eb2b968947cefc0ecbbe136345 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 16:43:30 -0500 Subject: [PATCH 16/21] Revert "Revert "Dummy build request & mapping files added"" This reverts commit 3bba2eb45e6a86208eac33e610e472351a20853b. --- build-request.json | 31 +++++++++++++++++++++++++++++++ feature-service-id.json | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 build-request.json create mode 100644 feature-service-id.json diff --git a/build-request.json b/build-request.json new file mode 100644 index 00000000000..f0eef7bbd4e --- /dev/null +++ b/build-request.json @@ -0,0 +1,31 @@ +{ + "features": [ + { + "releaseNotes": "New feature description A.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-a", + "featureType": "NEW_FEATURE" + } + } + }, + { + "releaseNotes": "New feature description B.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-b", + "featureType": "NEW_FEATURE" + } + } + }, + { + "releaseNotes": "Doc update description C.", + "featureMetadata": { + "trebuchet": { + "featureId": "feature-id-c", + "featureType": "DOC_UPDATE" + } + } + } + ] +} diff --git a/feature-service-id.json b/feature-service-id.json new file mode 100644 index 00000000000..dddab1daf84 --- /dev/null +++ b/feature-service-id.json @@ -0,0 +1,7 @@ +{ + "feature-id-a": "Service 1", + "feature-id-b": "Service 2", + "feature-id-c": "Service 3", + "feature-id-d": "Service 4" +} + From 5604554df1e04e49774e2a0fcbd84bee17dca42f Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 16:44:42 -0500 Subject: [PATCH 17/21] chore: Updates version to 1.0.27 --- Package.version | 2 +- Package.version.next | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.version b/Package.version index 7717884db13..3f11ef63078 100644 --- a/Package.version +++ b/Package.version @@ -1 +1 @@ -1.0.26 \ No newline at end of file +1.0.27 \ No newline at end of file diff --git a/Package.version.next b/Package.version.next index 3f11ef63078..f8536a434c8 100644 --- a/Package.version.next +++ b/Package.version.next @@ -1 +1 @@ -1.0.27 \ No newline at end of file +1.0.28 \ No newline at end of file From 835f09790451d988ee0540c301233289fec343bb Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 16:46:47 -0500 Subject: [PATCH 18/21] Remove Trebuchet build files --- build-request.json | 31 ------------------------------- feature-service-id.json | 7 ------- 2 files changed, 38 deletions(-) delete mode 100644 build-request.json delete mode 100644 feature-service-id.json diff --git a/build-request.json b/build-request.json deleted file mode 100644 index f0eef7bbd4e..00000000000 --- a/build-request.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "features": [ - { - "releaseNotes": "New feature description A.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-a", - "featureType": "NEW_FEATURE" - } - } - }, - { - "releaseNotes": "New feature description B.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-b", - "featureType": "NEW_FEATURE" - } - } - }, - { - "releaseNotes": "Doc update description C.", - "featureMetadata": { - "trebuchet": { - "featureId": "feature-id-c", - "featureType": "DOC_UPDATE" - } - } - } - ] -} diff --git a/feature-service-id.json b/feature-service-id.json deleted file mode 100644 index dddab1daf84..00000000000 --- a/feature-service-id.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "feature-id-a": "Service 1", - "feature-id-b": "Service 2", - "feature-id-c": "Service 3", - "feature-id-d": "Service 4" -} - From cc376b270b8e26e13394ce93ab71507a0e21a142 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 16:58:19 -0500 Subject: [PATCH 19/21] Fix comment --- .../AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift index bdc1f4c999a..4e39b0b9705 100644 --- a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Models/ReleaseNotesBuilderTests.swift @@ -195,8 +195,7 @@ class ReleaseNotesBuilderTests: CLITestCase { private func setUpBuildRequestAndMappingJSONs(_ buildRequest: String, _ mapping: String) { // In real scenario, the JSON files we need are located one level above, in the workspace directory. - // For tests, due to sandboxing, the dummy files are created in current directory instead of - // in parent directory. + // So, the dummy files are created in the parent of the current directory to match a real build. FileManager.default.createFile(atPath: "../build-request.json", contents: Data(buildRequest.utf8)) FileManager.default.createFile(atPath: "../feature-service-id.json", contents: Data(mapping.utf8)) } From df0351069385cb279119ba08a3f7d54b1c13c03a Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 17:06:22 -0500 Subject: [PATCH 20/21] Revert version files --- Package.version | 2 +- Package.version.next | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.version b/Package.version index 3f11ef63078..855f7029535 100644 --- a/Package.version +++ b/Package.version @@ -1 +1 @@ -1.0.27 \ No newline at end of file +1.0.25 \ No newline at end of file diff --git a/Package.version.next b/Package.version.next index f8536a434c8..7717884db13 100644 --- a/Package.version.next +++ b/Package.version.next @@ -1 +1 @@ -1.0.28 \ No newline at end of file +1.0.26 \ No newline at end of file From 681870b6e2aaddcf68258fdb711eb276d52ba1cc Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 23 Oct 2024 17:08:05 -0500 Subject: [PATCH 21/21] Revert version files --- Package.version | 2 +- Package.version.next | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.version b/Package.version index 855f7029535..7717884db13 100644 --- a/Package.version +++ b/Package.version @@ -1 +1 @@ -1.0.25 \ No newline at end of file +1.0.26 \ No newline at end of file diff --git a/Package.version.next b/Package.version.next index 7717884db13..3f11ef63078 100644 --- a/Package.version.next +++ b/Package.version.next @@ -1 +1 @@ -1.0.26 \ No newline at end of file +1.0.27 \ No newline at end of file