diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 89d8099519..1b44001899 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -52,7 +52,7 @@ jobs: name: Acquire Base Image needs: save-docker-login-token if: ${{ github.event.pull_request.head.repo.full_name == 'awslabs/smithy-rs' }} - runs-on: ubuntu-latest + runs-on: smithy_ubuntu-latest_8-core env: ENCRYPTED_DOCKER_PASSWORD: ${{ needs.save-docker-login-token.outputs.docker-login-password }} DOCKER_LOGIN_TOKEN_PASSPHRASE: ${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }} diff --git a/.github/workflows/update-sdk-next.yml b/.github/workflows/update-sdk-next.yml index 155924020a..a06bf21ad8 100644 --- a/.github/workflows/update-sdk-next.yml +++ b/.github/workflows/update-sdk-next.yml @@ -1,8 +1,21 @@ # This workflow updates the `next` branch with freshly generated # code from the latest smithy-rs and models that reside in aws-sdk-rust. + +# Allow only one release to run at a time +concurrency: + group: update-aws-sdk-next + cancel-in-progress: true + name: Update `aws-sdk-rust/next` on: workflow_dispatch: + inputs: + generate_ref: + description: | + Which branch/commit/tag of smithy-rs to use to generate aws-sdk-rust/next. Defaults to `main`. + required: true + type: string + default: main jobs: update-next: @@ -13,7 +26,7 @@ jobs: uses: actions/checkout@v3 with: repository: awslabs/smithy-rs - ref: main + ref: ${{ inputs.generate_ref }} path: smithy-rs - name: Check out `aws-sdk-rust` uses: actions/checkout@v3 diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 0d0121b35d..5559e01980 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -35,6 +35,18 @@ references = ["smithy-rs#2907", "aws-sdk-rust#864"] meta = { "breaking" = false, "tada" = false, "bug" = true } author = "jdisanti" +[[aws-sdk-rust]] +message = "Fixed re-exported `SdkError` type. The previous release had the wrong type for `SdkError`, which caused projects to fail to compile when upgrading." +references = ["smithy-rs#2931", "aws-sdk-rust#875"] +meta = { "breaking" = true, "tada" = false, "bug" = true } +author = "jdisanti" + +[[smithy-rs]] +message = "Fixed re-exported `SdkError` type. The previous release had the wrong type for `SdkError` when generating code for orchestrator mode, which caused projects to fail to compile when upgrading." +references = ["smithy-rs#2931", "aws-sdk-rust#875"] +meta = { "breaking" = true, "tada" = false, "bug" = true, "target" = "client" } +author = "jdisanti" + [[smithy-rs]] message = "Logging via `#[instrument]` in the `aws_smithy_runtime::client::orchestrator` module is now emitted at the `DEBUG` level to reduce the amount of logging when emitted at the `INFO` level." references = ["smithy-rs#2934", "aws-sdk-rust#872"] diff --git a/aws/sdk/build.gradle.kts b/aws/sdk/build.gradle.kts index 03e9bcfde5..339af759a3 100644 --- a/aws/sdk/build.gradle.kts +++ b/aws/sdk/build.gradle.kts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import aws.sdk.AwsExamplesLayout import aws.sdk.AwsServices import aws.sdk.Membership import aws.sdk.discoverServices @@ -246,22 +245,12 @@ tasks.register("fixExampleManifests") { toolPath = sdkVersionerToolPath binaryName = "sdk-versioner" - arguments = when (AwsExamplesLayout.detect(project)) { - AwsExamplesLayout.Flat -> listOf( - "use-path-and-version-dependencies", - "--isolate-crates", - "--sdk-path", "../../sdk", - "--versions-toml", outputDir.resolve("versions.toml").absolutePath, - outputDir.resolve("examples").absolutePath, - ) - AwsExamplesLayout.Workspaces -> listOf( - "use-path-and-version-dependencies", - "--isolate-crates", - "--sdk-path", sdkOutputDir.absolutePath, - "--versions-toml", outputDir.resolve("versions.toml").absolutePath, - outputDir.resolve("examples").absolutePath, - ) - } + arguments = listOf( + "use-path-and-version-dependencies", + "--sdk-path", sdkOutputDir.absolutePath, + "--versions-toml", outputDir.resolve("versions.toml").absolutePath, + outputDir.resolve("examples").absolutePath, + ) outputs.dir(outputDir) dependsOn("relocateExamples", "generateVersionManifest") diff --git a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt index 189bce6a67..9871741ad5 100644 --- a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt +++ b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt @@ -19,38 +19,6 @@ data class RootTest( val manifestName: String, ) -// TODO(https://github.com/awslabs/smithy-rs/issues/2810): We can remove the `Flat` layout after the switch -// to `Workspaces` has been released. This can be checked by looking at the `examples/` directory in aws-sdk-rust's -// main branch. -// -// The `Flat` layout is retained for backwards compatibility so that the next release process can succeed. -enum class AwsExamplesLayout { - /** - * Directory layout for examples used prior to June 26, 2023, - * where each example was in the `rust_dev_preview/` root directory and - * was considered to be its own workspace. - * - * This layout had issues with CI in terms of time to compile and disk space required - * since the dependencies would get recompiled for every example. - */ - Flat, - - /** - * Current directory layout where there are a small number of workspaces - * rooted in `rust_dev_preview/`. - */ - Workspaces, - ; - - companion object { - fun detect(project: Project): AwsExamplesLayout = if (project.projectDir.resolve("examples/Cargo.toml").exists()) { - AwsExamplesLayout.Flat - } else { - AwsExamplesLayout.Workspaces - } - } -} - class AwsServices( private val project: Project, services: List, @@ -77,15 +45,9 @@ class AwsServices( val examples: List by lazy { val examplesRoot = project.projectDir.resolve("examples") - if (AwsExamplesLayout.detect(project) == AwsExamplesLayout.Flat) { - examplesRoot.listFiles { file -> !file.name.startsWith(".") }.orEmpty().toList() - .filter { file -> manifestCompatibleWithGeneratedServices(file) } - .map { "examples/${it.name}" } - } else { - examplesRoot.listFiles { file -> - !file.name.startsWith(".") && file.isDirectory() && file.resolve("Cargo.toml").exists() - }.orEmpty().toList().map { "examples/${it.name}" } - } + examplesRoot.listFiles { file -> + !file.name.startsWith(".") && file.isDirectory() && file.resolve("Cargo.toml").exists() + }.orEmpty().toList().map { "examples/${it.name}" } } /** diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt index 46de4940a0..98cb2bad7d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt @@ -24,10 +24,12 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationCus import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceRuntimePluginCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.rust +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customizations.AllowLintsCustomization import software.amazon.smithy.rust.codegen.core.smithy.customizations.CrateVersionCustomization -import software.amazon.smithy.rust.codegen.core.smithy.customizations.pubUseSmithyErrorTypes import software.amazon.smithy.rust.codegen.core.smithy.customizations.pubUseSmithyPrimitives import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.core.util.letIf @@ -79,6 +81,8 @@ class RequiredCustomizations : ClientCodegenDecorator { baseCustomizations + AllowLintsCustomization() override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { + val rc = codegenContext.runtimeConfig + // Add rt-tokio feature for `ByteStream::from_path` rustCrate.mergeFeature(Feature("rt-tokio", true, listOf("aws-smithy-http/rt-tokio"))) @@ -91,7 +95,29 @@ class RequiredCustomizations : ClientCodegenDecorator { pubUseSmithyPrimitives(codegenContext, codegenContext.model)(this) } rustCrate.withModule(ClientRustModule.Error) { - pubUseSmithyErrorTypes(codegenContext)(this) + // TODO(enableNewSmithyRuntimeCleanup): Change SdkError to a `pub use` after changing the generic's default + rust("/// Error type returned by the client.") + if (codegenContext.smithyRuntimeMode.generateOrchestrator) { + rustTemplate( + "pub type SdkError = #{SdkError};", + "SdkError" to RuntimeType.sdkError(rc), + "R" to RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::HttpResponse"), + ) + } else { + rustTemplate( + "pub type SdkError = #{SdkError};", + "SdkError" to RuntimeType.sdkError(rc), + "R" to RuntimeType.smithyHttp(rc).resolve("operation::Response"), + ) + } + rustTemplate( + """ + pub use #{DisplayErrorContext}; + pub use #{ProvideErrorMetadata}; + """, + "DisplayErrorContext" to RuntimeType.smithyTypes(rc).resolve("error::display::DisplayErrorContext"), + "ProvideErrorMetadata" to RuntimeType.smithyTypes(rc).resolve("error::metadata::ProvideErrorMetadata"), + ) } ClientRustModule.Meta.also { metaModule -> diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt index 301ee11da8..14d081b2cb 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt @@ -9,20 +9,12 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.Shape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.rust +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.CodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.util.hasEventStreamMember import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember -import software.amazon.smithy.rust.codegen.core.util.letIf - -private data class PubUseType( - val type: RuntimeType, - val shouldExport: (Model) -> Boolean, - val alias: String? = null, -) /** Returns true if the model has normal streaming operations (excluding event streams) */ private fun hasStreamingOperations(model: Model): Boolean { @@ -48,62 +40,34 @@ private fun hasBlobs(model: Model): Boolean = structUnionMembersMatchPredicate(m /** Returns true if the model uses any timestamp shapes */ private fun hasDateTimes(model: Model): Boolean = structUnionMembersMatchPredicate(model, Shape::isTimestampShape) -/** Returns a list of types that should be re-exported for the given model */ -internal fun pubUseTypes(codegenContext: CodegenContext, model: Model): List = - pubUseTypesThatShouldBeExported(codegenContext, model).map { it.type } - -private fun pubUseTypesThatShouldBeExported(codegenContext: CodegenContext, model: Model): List { - val runtimeConfig = codegenContext.runtimeConfig - return ( - listOf( - PubUseType(RuntimeType.blob(runtimeConfig), ::hasBlobs), - PubUseType(RuntimeType.dateTime(runtimeConfig), ::hasDateTimes), - PubUseType(RuntimeType.format(runtimeConfig), ::hasDateTimes, "DateTimeFormat"), - ) + RuntimeType.smithyHttp(runtimeConfig).let { http -> - listOf( - PubUseType(http.resolve("byte_stream::ByteStream"), ::hasStreamingOperations), - PubUseType(http.resolve("byte_stream::AggregatedBytes"), ::hasStreamingOperations), - PubUseType(http.resolve("byte_stream::error::Error"), ::hasStreamingOperations, "ByteStreamError"), - PubUseType(http.resolve("body::SdkBody"), ::hasStreamingOperations), - ) - } - ).filter { pubUseType -> pubUseType.shouldExport(model) } -} - /** Adds re-export statements for Smithy primitives */ fun pubUseSmithyPrimitives(codegenContext: CodegenContext, model: Model): Writable = writable { - val types = pubUseTypesThatShouldBeExported(codegenContext, model) - if (types.isNotEmpty()) { - types.forEach { - val useStatement = if (it.alias == null) { - "pub use #T;" - } else { - "pub use #T as ${it.alias};" - } - rust(useStatement, it.type) - } + val rc = codegenContext.runtimeConfig + if (hasBlobs(model)) { + rustTemplate("pub use #{Blob};", "Blob" to RuntimeType.blob(rc)) } -} - -/** Adds re-export statements for error types */ -fun pubUseSmithyErrorTypes(codegenContext: CodegenContext): Writable = writable { - val runtimeConfig = codegenContext.runtimeConfig - val reexports = listOf( - listOf( - RuntimeType.smithyHttp(runtimeConfig).let { http -> - PubUseType(http.resolve("result::SdkError"), { _ -> true }) - }, - ), - RuntimeType.smithyTypes(runtimeConfig).let { types -> - listOf(PubUseType(types.resolve("error::display::DisplayErrorContext"), { _ -> true })) - // Only re-export `ProvideErrorMetadata` for clients - .letIf(codegenContext.target == CodegenTarget.CLIENT) { list -> - list + - listOf(PubUseType(types.resolve("error::metadata::ProvideErrorMetadata"), { _ -> true })) - } - }, - ).flatten() - reexports.forEach { reexport -> - rust("pub use #T;", reexport.type) + if (hasDateTimes(model)) { + rustTemplate( + """ + pub use #{DateTime}; + pub use #{Format} as DateTimeFormat; + """, + "DateTime" to RuntimeType.dateTime(rc), + "Format" to RuntimeType.format(rc), + ) + } + if (hasStreamingOperations(model)) { + rustTemplate( + """ + pub use #{ByteStream}; + pub use #{AggregatedBytes}; + pub use #{Error} as ByteStreamError; + pub use #{SdkBody}; + """, + "ByteStream" to RuntimeType.smithyHttp(rc).resolve("byte_stream::ByteStream"), + "AggregatedBytes" to RuntimeType.smithyHttp(rc).resolve("byte_stream::AggregatedBytes"), + "Error" to RuntimeType.smithyHttp(rc).resolve("byte_stream::error::Error"), + "SdkBody" to RuntimeType.smithyHttp(rc).resolve("body::SdkBody"), + ) } } diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt index 55b792218f..b02574e6a5 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt @@ -7,7 +7,7 @@ package software.amazon.smithy.rust.codegen.core.smithy.customizations import org.junit.jupiter.api.Test import software.amazon.smithy.model.Model -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGeneratorTest.Companion.model import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.core.testutil.testCodegenContext @@ -43,61 +43,61 @@ class SmithyTypesPubUseExtraTest { """.asSmithyModel() } - private fun typesWithEmptyModel() = typesWithMember() - private fun typesWithMember( + private fun reexportsWithEmptyModel() = reexportsWithMember() + private fun reexportsWithMember( inputMember: String = "", outputMember: String = "", unionMember: String = "", additionalShape: String = "", - ) = pubUseTypes(testCodegenContext(model), modelWithMember(inputMember, outputMember, unionMember, additionalShape)) + ) = RustWriter.root().let { writer -> + pubUseSmithyPrimitives(testCodegenContext(model), modelWithMember(inputMember, outputMember, unionMember, additionalShape))(writer) + writer.toString() + } - private fun assertDoesntHaveTypes(types: List, expectedTypes: List) = - expectedTypes.forEach { assertDoesntHaveType(types, it) } + private fun assertDoesntHaveReexports(reexports: String, expectedTypes: List) = + expectedTypes.forEach { assertDoesntHaveReexports(reexports, it) } - private fun assertDoesntHaveType(types: List, type: String) { - if (types.any { t -> t.fullyQualifiedName() == type }) { + private fun assertDoesntHaveReexports(reexports: String, type: String) { + if (reexports.contains(type)) { throw AssertionError("Expected $type to NOT be re-exported, but it was.") } } - private fun assertHasTypes(types: List, expectedTypes: List) = - expectedTypes.forEach { assertHasType(types, it) } + private fun assertHasReexports(reexports: String, expectedTypes: List) = + expectedTypes.forEach { assertHasReexport(reexports, it) } - private fun assertHasType(types: List, type: String) { - if (types.none { t -> t.fullyQualifiedName() == type }) { - throw AssertionError( - "Expected $type to be re-exported. Re-exported types: " + - types.joinToString { it.fullyQualifiedName() }, - ) + private fun assertHasReexport(reexports: String, type: String) { + if (!reexports.contains(type)) { + throw AssertionError("Expected $type to be re-exported. Re-exported types:\n$reexports") } } @Test fun `it re-exports Blob when a model uses blobs`() { - assertDoesntHaveType(typesWithEmptyModel(), "::aws_smithy_types::Blob") - assertHasType(typesWithMember(inputMember = "foo: Blob"), "::aws_smithy_types::Blob") - assertHasType(typesWithMember(outputMember = "foo: Blob"), "::aws_smithy_types::Blob") - assertHasType( - typesWithMember(inputMember = "foo: SomeUnion", unionMember = "foo: Blob"), + this.assertDoesntHaveReexports(reexportsWithEmptyModel(), "::aws_smithy_types::Blob") + assertHasReexport(reexportsWithMember(inputMember = "foo: Blob"), "::aws_smithy_types::Blob") + assertHasReexport(reexportsWithMember(outputMember = "foo: Blob"), "::aws_smithy_types::Blob") + assertHasReexport( + reexportsWithMember(inputMember = "foo: SomeUnion", unionMember = "foo: Blob"), "::aws_smithy_types::Blob", ) - assertHasType( - typesWithMember(outputMember = "foo: SomeUnion", unionMember = "foo: Blob"), + assertHasReexport( + reexportsWithMember(outputMember = "foo: SomeUnion", unionMember = "foo: Blob"), "::aws_smithy_types::Blob", ) } @Test fun `it re-exports DateTime when a model uses timestamps`() { - assertDoesntHaveType(typesWithEmptyModel(), "aws_smithy_types::DateTime") - assertHasType(typesWithMember(inputMember = "foo: Timestamp"), "::aws_smithy_types::DateTime") - assertHasType(typesWithMember(outputMember = "foo: Timestamp"), "::aws_smithy_types::DateTime") - assertHasType( - typesWithMember(inputMember = "foo: SomeUnion", unionMember = "foo: Timestamp"), + this.assertDoesntHaveReexports(reexportsWithEmptyModel(), "aws_smithy_types::DateTime") + assertHasReexport(reexportsWithMember(inputMember = "foo: Timestamp"), "::aws_smithy_types::DateTime") + assertHasReexport(reexportsWithMember(outputMember = "foo: Timestamp"), "::aws_smithy_types::DateTime") + assertHasReexport( + reexportsWithMember(inputMember = "foo: SomeUnion", unionMember = "foo: Timestamp"), "::aws_smithy_types::DateTime", ) - assertHasType( - typesWithMember(outputMember = "foo: SomeUnion", unionMember = "foo: Timestamp"), + assertHasReexport( + reexportsWithMember(outputMember = "foo: SomeUnion", unionMember = "foo: Timestamp"), "::aws_smithy_types::DateTime", ) } @@ -108,20 +108,20 @@ class SmithyTypesPubUseExtraTest { listOf("::aws_smithy_http::byte_stream::ByteStream", "::aws_smithy_http::byte_stream::AggregatedBytes") val streamingShape = "@streaming blob Streaming" - assertDoesntHaveTypes(typesWithEmptyModel(), streamingTypes) - assertHasTypes(typesWithMember(additionalShape = streamingShape, inputMember = "m: Streaming"), streamingTypes) - assertHasTypes(typesWithMember(additionalShape = streamingShape, outputMember = "m: Streaming"), streamingTypes) + this.assertDoesntHaveReexports(reexportsWithEmptyModel(), streamingTypes) + assertHasReexports(reexportsWithMember(additionalShape = streamingShape, inputMember = "m: Streaming"), streamingTypes) + assertHasReexports(reexportsWithMember(additionalShape = streamingShape, outputMember = "m: Streaming"), streamingTypes) // Event streams don't re-export the normal streaming types - assertDoesntHaveTypes( - typesWithMember( + this.assertDoesntHaveReexports( + reexportsWithMember( additionalShape = "@streaming union EventStream { foo: SomeStruct }", inputMember = "m: EventStream", ), streamingTypes, ) - assertDoesntHaveTypes( - typesWithMember( + this.assertDoesntHaveReexports( + reexportsWithMember( additionalShape = "@streaming union EventStream { foo: SomeStruct }", outputMember = "m: EventStream", ), diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt index ceba38691b..5fc86ee04f 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/customizations/ServerRequiredCustomizations.kt @@ -6,10 +6,11 @@ package software.amazon.smithy.rust.codegen.server.smithy.customizations import software.amazon.smithy.rust.codegen.core.rustlang.Feature +import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customizations.AllowLintsCustomization import software.amazon.smithy.rust.codegen.core.smithy.customizations.CrateVersionCustomization -import software.amazon.smithy.rust.codegen.core.smithy.customizations.pubUseSmithyErrorTypes import software.amazon.smithy.rust.codegen.core.smithy.customizations.pubUseSmithyPrimitives import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext @@ -34,12 +35,23 @@ class ServerRequiredCustomizations : ServerCodegenDecorator { baseCustomizations + AllowLintsCustomization() override fun extras(codegenContext: ServerCodegenContext, rustCrate: RustCrate) { + val rc = codegenContext.runtimeConfig + // Add rt-tokio feature for `ByteStream::from_path` rustCrate.mergeFeature(Feature("rt-tokio", true, listOf("aws-smithy-http/rt-tokio"))) rustCrate.withModule(ServerRustModule.Types) { pubUseSmithyPrimitives(codegenContext, codegenContext.model)(this) - pubUseSmithyErrorTypes(codegenContext)(this) + // TODO(enableNewSmithyRuntimeCleanup): Remove re-export of SdkError in server and add changelog entry + rustTemplate( + """ + pub type SdkError = #{SdkError}; + pub use #{DisplayErrorContext}; + """, + "SdkError" to RuntimeType.smithyHttp(rc).resolve("result::SdkError"), + "Response" to RuntimeType.smithyHttp(rc).resolve("operation::Response"), + "DisplayErrorContext" to RuntimeType.smithyTypes(rc).resolve("error::display::DisplayErrorContext"), + ) } rustCrate.withModule(ServerRustModule.root) { diff --git a/tools/ci-build/Dockerfile b/tools/ci-build/Dockerfile index f1e74fc79f..2254dfb5b1 100644 --- a/tools/ci-build/Dockerfile +++ b/tools/ci-build/Dockerfile @@ -148,6 +148,7 @@ RUN cargo +${rust_nightly_version} -Z sparse-registry install mdbook-mermaid --l # # Final image # +# `clang` needed by SDK examples for `libxlsxwriter-sys` FROM bare_base_image AS final_image ARG rust_stable_version ARG rust_nightly_version @@ -155,6 +156,7 @@ RUN set -eux; \ yum -y install \ bc \ ca-certificates \ + clang \ gcc \ git \ java-11-amazon-corretto-headless \ diff --git a/tools/ci-scripts/check-aws-sdk-examples b/tools/ci-scripts/check-aws-sdk-examples index db5880b499..2efc2752a1 100755 --- a/tools/ci-scripts/check-aws-sdk-examples +++ b/tools/ci-scripts/check-aws-sdk-examples @@ -13,6 +13,7 @@ cd aws-sdk/examples for example in *; do echo -e "${C_YELLOW}Checking examples/${example}...${C_RESET}" pushd "${example}" &>/dev/null - cargo check && cargo clean + cargo check + cargo clean popd &>/dev/null done