-
Notifications
You must be signed in to change notification settings - Fork 80
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: Run CLI unit tests in CI #1799
Changes from 11 commits
231adf4
f18b7e8
dd803d8
e26ee0d
5c17a4d
e6aa350
45a3bbf
1288bf2
c5bffb5
17f8c72
84d9220
4bac8e3
cdd65ac
9782279
3bba2eb
d3cdd34
465ee53
5604554
835f097
3ed9e1d
cc376b2
df03510
681870b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -101,6 +101,14 @@ 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' }} | ||
run: | | ||
cd AWSSDKSwiftCLI | ||
swift test | ||
cd ../SPRCLI | ||
unset AWS_SWIFT_SDK_USE_LOCAL_DEPS | ||
swift build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Macs test & build CLI tools only directly on the Mac, not on simulators. |
||
- name: Prepare Protocol & Unit Tests | ||
run: | | ||
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh | ||
|
@@ -182,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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All Linux jobs build & test the CLI tools. |
||
- name: Prepare Protocol & Unit Tests | ||
run: | | ||
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,13 +235,16 @@ struct PrepareRelease { | |
previousVersion: Version | ||
) throws { | ||
let commits = try Process.git.listOfCommitsBetween("HEAD", "\(previousVersion)") | ||
|
||
let featuresReader = FeaturesReader(repoPath: repoPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PrepareRelease configures & runs the FeatureReader with its own |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Features reader is used to read the build message & mapping, then the read data is passed into the release notes builder. |
||
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( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,25 +8,26 @@ | |
import Foundation | ||
import AWSCLIUtils | ||
|
||
struct FeaturesReader: Decodable { | ||
private let requestFilePath: String | ||
private let mappingFilePath: String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of taking individual paths to files, this type assumes the individual files are in the parent of the current working directory (which will be the repo's root). |
||
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(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 fileContents = try FileManager.default.loadContents(atPath: mappingFilePath) | ||
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) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReleaseNotesBuilders takes the feature list & mapping as inputs rather than reading them itself. |
||
|
||
// 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, the injected features & mapping are used directly to generate the release notes content. |
||
} | ||
|
||
private func buildServiceFeatureSection( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During tests, the FeaturesReader just reads the feature & map files out of the temp project root created for testing. |
||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GA AWS SDK now used by the SPRCLI tools. |
||
.package(path: "../AWSSDKSwiftCLI"), | ||
], | ||
targets: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
// | ||
|
||
import Foundation | ||
import PackageDescription | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an old remnant of the AWSSDKSwiftCLI dependency on the |
||
import AWSCLIUtils | ||
|
||
extension Process { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ public struct SPRPublisher { | |
} | ||
|
||
private mutating func setOptions() async { | ||
await SDKLoggingSystem.initialize(logLevel: .error) | ||
await SDKLoggingSystem().initialize(logLevel: .error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We changed this interface before GA. |
||
let env = ProcessInfo.processInfo.environment | ||
bucket = bucket ?? env["AWS_SDK_SPR_BUCKET"] | ||
if region.isEmpty { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will see several places where the method |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ extension SPRPublisher { | |
} | ||
|
||
private func createMetadata() -> PackageInfo { | ||
let now = Date().ISO8601Format() | ||
let formatter = ISO8601DateFormatter() | ||
let now = formatter.string(from: Date()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another new method replaced by an older one for compatibility with older Swift. |
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macos-14 is used for running min Xcode instead of macos-13. This matches the macOS used in Catapult.