Skip to content
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

Add CI action to test aws-sdk-services #2251

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- action: check-aws-config
- action: check-aws-sdk-canary
- action: check-aws-sdk-cargo-deny
- action: check-aws-sdk-services
- action: check-only-aws-sdk-services
- action: check-aws-sdk-smoketest-docs-clippy-udeps
- action: check-aws-sdk-smoketest-unit-tests
- action: check-aws-sdk-standalone-integration-tests
Expand Down
8 changes: 7 additions & 1 deletion aws/sdk-adhoc-test/models/single-static-endpoint.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,25 @@ use smithy.rules#endpointTests
}
},
"params": { }
"operationInputs": [
{ "operationName": "TestOperation", "operationParams": {
"bar": { f: "blah" }
} }
]
}]
})
@restJson1
@title("Test Service")
@service(sdkId: "Test")
@aws.auth#sigv4(name: "test-service")
service TestService {
operations: [TestOperation]
}

@input
structure Foo { bar: Bar }

structure Bar {}
structure Bar { f: String }

@http(uri: "/foo", method: "POST")
operation TestOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.writable
import software.amazon.smithy.rust.codegen.core.smithy.PublicImportSymbolProvider
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate
import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName
import software.amazon.smithy.rust.codegen.core.testutil.integrationTest
Expand Down Expand Up @@ -113,7 +114,8 @@ fun usesDeprecatedBuiltIns(testOperationInput: EndpointTestOperationInput): Bool
* Doing this in AWS codegen allows us to actually integration test generated clients.
*/

class OperationInputTestGenerator(private val ctx: ClientCodegenContext, private val test: EndpointTestCase) {
class OperationInputTestGenerator(_ctx: ClientCodegenContext, private val test: EndpointTestCase) {
private val ctx = _ctx.copy(symbolProvider = PublicImportSymbolProvider(_ctx.symbolProvider, _ctx.moduleUseName()))
private val runtimeConfig = ctx.runtimeConfig
private val moduleName = ctx.moduleUseName()
private val endpointCustomizations = ctx.rootDecorator.endpointCustomizations(ctx)
Expand Down
4 changes: 4 additions & 0 deletions ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ check-aws-sdk-examples: generate-aws-sdk
check-aws-sdk-services: generate-aws-sdk
$(CI_ACTION) $@ $(ARGS)

.PHONY: check-only-aws-sdk-services
check-only-aws-sdk-services: generate-aws-sdk
$(CI_ACTION) $@ $(ARGS)

.PHONY: check-aws-sdk-smoketest-docs-clippy-udeps
check-aws-sdk-smoketest-docs-clippy-udeps: generate-aws-sdk-smoketest
$(CI_ACTION) $@ $(ARGS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class EndpointsDecoratorTest {
"Region": "test-region"
},
"operationInputs": [
{ "operationName": "TestOperation" }
{ "operationName": "TestOperation", "operationParams": { "nested": { "field": "test" } } }
],
"expect": {
"endpoint": {
Expand Down Expand Up @@ -110,7 +110,12 @@ class EndpointsDecoratorTest {

structure TestOperationInput {
@contextParam(name: "Bucket")
bucket: String
bucket: String,
nested: NestedStructure
}

structure NestedStructure {
field: String
}
""".asSmithyModel()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

package software.amazon.smithy.rust.codegen.core.smithy

import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.shapes.Shape
import software.amazon.smithy.rust.codegen.core.rustlang.RustType

/**
* Rewrite crate::* with `<moduleusename>::*`
*
* This enables generating code into `tests` and other public locations.
*/
class PublicImportSymbolProvider(private val base: RustSymbolProvider, private val publicUseName: String) :
WrappingSymbolProvider(base) {
override fun toSymbol(shape: Shape): Symbol {
val baseSymbol = base.toSymbol(shape)

val currentRustType = baseSymbol.rustType()
val currentNamespace = currentRustType.namespace
val newRustType =
if (currentRustType is RustType.Opaque && currentNamespace != null && currentNamespace.startsWith("crate::")) {
currentRustType.copy(namespace = currentNamespace.replace("crate::", "$publicUseName::"))
} else {
currentRustType
}
return baseSymbol.toBuilder().rustType(newRustType).build()
}
}
2 changes: 1 addition & 1 deletion tools/ci-build/scripts/check-aws-sdk-services
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cd aws-sdk
# Remove examples from workspace
sed -i '/"examples\//d' Cargo.toml

cargo check
cargo test --all-features
15 changes: 15 additions & 0 deletions tools/ci-build/scripts/check-only-aws-sdk-services
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#

# this job runs `cargo check` only instead of `cargo test --all-features`

set -eux
cd aws-sdk

# Remove examples from workspace
sed -i '/"examples\//d' Cargo.toml

cargo check --all-targets --all-features