awslabs / aws-sdk-swift

Apache License 2.0
360 stars 71 forks source link

Protocol tests intermittently fail to compile #1612

Open jbelkins opened 2 weeks ago

jbelkins commented 2 weeks ago

Describe the bug

On infrequent occasions in CI, protocol tests will fail to compile due to multiple conformances of Equatable in the types used in response protocol tests

Expected Behavior

Protocol test code compiles correctly every time.

Current Behavior

Protocol test compile fails intermittently with an error such as:

[Ec2QueryTestSDKTests] Compiling DatetimeOffsetsInput+Equatable.swift
Error: extension outside of file declaring struct 'DatetimeOffsetsInput' prevents automatic synthesis of '==' for protocol 'Equatable'
extension DatetimeOffsetsInput: Swift.Equatable {
^
Error: invalid redeclaration of '=='
    public static func ==(lhs: DatetimeOffsetsInput, rhs: DatetimeOffsetsInput) -> Bool {
                       ^
Error: redundant conformance of 'DatetimeOffsetsInput' to protocol 'Equatable'
extension DatetimeOffsetsInput: Swift.Equatable {
                                      ^

https://github.com/awslabs/aws-sdk-swift/actions/runs/9752044774/job/26914820124

Reproduction Steps

Observe routine runs of aws-sdk-swift CI. This usually happens a couple times a week.

Possible Solution

I believe the cause of this is that response test codegen uses a global variable here: https://github.com/smithy-lang/smithy-swift/blob/main/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/HttpProtocolUnitTestResponseGenerator.kt#L200

When two codegen tasks are generating Equatable conformance for the same type at approximately the same time, the conformance can be generated twice.

Solution is to either:

Additional Information/Context

No response

AWS SWIFT SDK version used

latest

Compiler and Version used

latest

Operating System and version

latest

sichanyoo commented 2 weeks ago

Not marked GA since it doesn't affect customers. But still given high priority for awareness.