-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into jmes…
…path-flatten
- Loading branch information
Showing
44 changed files
with
615 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Kat Transform | ||
|
||
on: | ||
pull_request: | ||
types: [ opened, synchronize, reopened, labeled, unlabeled ] | ||
branches: [ main ] | ||
|
||
# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed | ||
concurrency: | ||
group: kat-pr-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
RUN: ${{ github.run_id }}-${{ github.run_number }} | ||
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dkotlin.incremental=false" | ||
|
||
jobs: | ||
verify-transform: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
with: | ||
path: 'smithy-kotlin' | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | ||
aws-region: us-west-2 | ||
|
||
- name: Setup kat | ||
uses: awslabs/aws-kotlin-repo-tools/.github/actions/setup-kat@main | ||
|
||
- name: Configure JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Build | ||
working-directory: ./smithy-kotlin | ||
shell: bash | ||
run: | | ||
pwd | ||
ls -lsa | ||
kat bump-version # Bump from `vNext-SNAPSHOT` to `vNext`. kat transform only works on non-SNAPSHOT versions | ||
kat bump-version --property codegenVersion | ||
./gradlew build | ||
./gradlew publishAllPublicationsToTestLocalRepository | ||
- name: Transform | ||
working-directory: ./smithy-kotlin | ||
shell: bash | ||
run: | | ||
pwd | ||
ls -lsa | ||
kat brazil transform -i ./build/m2 -o ./transformed -t .brazil.json -v live | ||
# Check for manifest file | ||
if [ ! -f "./transformed/brazil-import-manifest.json" ]; then | ||
echo "Error: brazil-import-manifest.json not found in the transformed artifact" | ||
exit 1 | ||
fi | ||
echo "Transformation succeeded!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...egen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/aws/protocols/RpcV2CborTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.kotlin.codegen.aws.protocols | ||
|
||
import software.amazon.smithy.kotlin.codegen.test.* | ||
import kotlin.test.Test | ||
|
||
class RpcV2CborTest { | ||
val model = """ | ||
${"$"}version: "2" | ||
namespace com.test | ||
use smithy.protocols#rpcv2Cbor | ||
use aws.api#service | ||
@rpcv2Cbor | ||
@service(sdkId: "CborExample") | ||
service CborExample { | ||
version: "1.0.0", | ||
operations: [GetFoo, GetFooStreaming] | ||
} | ||
@http(method: "POST", uri: "/foo") | ||
operation GetFoo {} | ||
@http(method: "POST", uri: "/foo-streaming") | ||
operation GetFooStreaming { | ||
input := {} | ||
output := { | ||
events: FooEvents | ||
} | ||
} | ||
// Model taken from https://smithy.io/2.0/spec/streaming.html#event-streams | ||
@streaming | ||
union FooEvents { | ||
up: Movement | ||
down: Movement | ||
left: Movement | ||
right: Movement | ||
throttlingError: ThrottlingError | ||
} | ||
structure Movement { | ||
velocity: Float | ||
} | ||
@error("client") | ||
@retryable(throttling: true) | ||
structure ThrottlingError {} | ||
""".toSmithyModel() | ||
|
||
@Test | ||
fun testStandardAcceptHeader() { | ||
val ctx = model.newTestContext("CborExample") | ||
|
||
val generator = RpcV2Cbor() | ||
generator.generateProtocolClient(ctx.generationCtx) | ||
|
||
ctx.generationCtx.delegator.finalize() | ||
ctx.generationCtx.delegator.flushWriters() | ||
|
||
val actual = ctx.manifest.expectFileString("/src/main/kotlin/com/test/DefaultTestClient.kt") | ||
val getFooMethod = actual.lines(" override suspend fun getFoo(input: GetFooRequest): GetFooResponse {", " }") | ||
|
||
val expectedHeaderMutation = """ | ||
op.install( | ||
MutateHeaders().apply { | ||
append("Accept", "application/cbor") | ||
} | ||
) | ||
""".replaceIndent(" ") | ||
getFooMethod.shouldContainOnlyOnceWithDiff(expectedHeaderMutation) | ||
} | ||
|
||
@Test | ||
fun testEventStreamAcceptHeader() { | ||
val ctx = model.newTestContext("CborExample") | ||
|
||
val generator = RpcV2Cbor() | ||
generator.generateProtocolClient(ctx.generationCtx) | ||
|
||
ctx.generationCtx.delegator.finalize() | ||
ctx.generationCtx.delegator.flushWriters() | ||
|
||
val actual = ctx.manifest.expectFileString("/src/main/kotlin/com/test/DefaultTestClient.kt") | ||
val getFooMethod = actual.lines(" override suspend fun <T> getFooStreaming(input: GetFooStreamingRequest, block: suspend (GetFooStreamingResponse) -> T): T {", " }") | ||
|
||
val expectedHeaderMutation = """ | ||
op.install( | ||
MutateHeaders().apply { | ||
append("Accept", "application/vnd.amazon.eventstream") | ||
} | ||
) | ||
""".replaceIndent(" ") | ||
getFooMethod.shouldContainOnlyOnceWithDiff(expectedHeaderMutation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,6 @@ Neptune | |
neptunedata | ||
Network Firewall | ||
NetworkManager | ||
nimble | ||
OAM | ||
Omics | ||
OpenSearch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.