From be8e7409615aa26917c3ab65205a3c0b7a8ac551 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 5 May 2022 12:18:11 +0100 Subject: [PATCH 1/9] Add Python subproject scaffolding --- codegen-server-test/python/build.gradle.kts | 102 ++++++++++++++++ codegen-server-test/python/model | 1 + codegen-server/python/build.gradle.kts | 109 ++++++++++++++++++ .../python/smithy/RustCodegenServerPlugin.kt | 78 +++++++++++++ ...ware.amazon.smithy.build.SmithyBuildPlugin | 5 + .../server/smithy/RustCodegenServerPlugin.kt | 1 + settings.gradle.kts | 2 + tools/codegen-diff-revisions.py | 15 ++- 8 files changed, 312 insertions(+), 1 deletion(-) create mode 100644 codegen-server-test/python/build.gradle.kts create mode 120000 codegen-server-test/python/model create mode 100644 codegen-server/python/build.gradle.kts create mode 100644 codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt create mode 100644 codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin diff --git a/codegen-server-test/python/build.gradle.kts b/codegen-server-test/python/build.gradle.kts new file mode 100644 index 0000000000..d0a16b23ce --- /dev/null +++ b/codegen-server-test/python/build.gradle.kts @@ -0,0 +1,102 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +extra["displayName"] = "Smithy :: Rust :: Codegen :: Server :: Python :: Test" +extra["moduleName"] = "software.amazon.smithy.rust.kotlin.codegen.server.python.test" + +tasks["jar"].enabled = false + +plugins { id("software.amazon.smithy") } + +val smithyVersion: String by project +val defaultRustFlags: String by project +val defaultRustDocFlags: String by project +val properties = PropertyRetriever(rootProject, project) + +val pluginName = "rust-server-codegen" +val workingDirUnderBuildDir = "smithyprojections/python/" + +buildscript { + val smithyVersion: String by project + dependencies { + classpath("software.amazon.smithy:smithy-cli:$smithyVersion") + } +} + +dependencies { + implementation(project(":codegen-server:python")) + implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion") + implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") + implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") +} + +val allCodegenTests = listOf( + CodegenTest("com.amazonaws.simple#SimpleService", "simple"), + CodegenTest("aws.protocoltests.restjson#RestJson", "rest_json"), + CodegenTest("aws.protocoltests.restjson.validation#RestJsonValidation", "rest_json_validation"), + CodegenTest("aws.protocoltests.json10#JsonRpc10", "json_rpc10"), + CodegenTest("aws.protocoltests.json#JsonProtocol", "json_rpc11"), + CodegenTest("aws.protocoltests.misc#MiscService", "misc"), + CodegenTest("com.amazonaws.ebs#Ebs", "ebs"), + CodegenTest("com.amazonaws.s3#AmazonS3", "s3"), + CodegenTest("com.aws.example#PokemonService", "pokemon_service_sdk") +) + +task("generateSmithyBuild") { + description = "generate smithy-build.json" + doFirst { + projectDir.resolve("smithy-build.json") + .writeText( + generateSmithyBuild( + rootProject.projectDir.absolutePath, + pluginName, + codegenTests(properties, allCodegenTests) + ) + ) + } +} + +task("generateCargoWorkspace") { + description = "generate Cargo.toml workspace file" + doFirst { + buildDir.resolve("$workingDirUnderBuildDir/Cargo.toml") + .writeText(generateCargoWorkspace(pluginName, codegenTests(properties, allCodegenTests))) + } +} + +tasks["smithyBuildJar"].dependsOn("generateSmithyBuild") +tasks["assemble"].finalizedBy("generateCargoWorkspace") + +tasks.register(Cargo.CHECK.toString) { + workingDir("$buildDir/$workingDirUnderBuildDir") + environment("RUSTFLAGS", defaultRustFlags) + commandLine("cargo", "check") + dependsOn("assemble") +} + +tasks.register(Cargo.TEST.toString) { + workingDir("$buildDir/$workingDirUnderBuildDir") + environment("RUSTFLAGS", defaultRustFlags) + commandLine("cargo", "test") + dependsOn("assemble") +} + +tasks.register(Cargo.DOCS.toString) { + workingDir("$buildDir/$workingDirUnderBuildDir") + environment("RUSTDOCFLAGS", defaultRustDocFlags) + commandLine("cargo", "doc", "--no-deps") + dependsOn("assemble") +} + +tasks.register(Cargo.CLIPPY.toString) { + workingDir("$buildDir/$workingDirUnderBuildDir") + environment("RUSTFLAGS", defaultRustFlags) + commandLine("cargo", "clippy") + dependsOn("assemble") +} + +tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString }) + +tasks["clean"].doFirst { delete("smithy-build.json") } diff --git a/codegen-server-test/python/model b/codegen-server-test/python/model new file mode 120000 index 0000000000..fe0e728f64 --- /dev/null +++ b/codegen-server-test/python/model @@ -0,0 +1 @@ +../model \ No newline at end of file diff --git a/codegen-server/python/build.gradle.kts b/codegen-server/python/build.gradle.kts new file mode 100644 index 0000000000..0ce0b44f29 --- /dev/null +++ b/codegen-server/python/build.gradle.kts @@ -0,0 +1,109 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + kotlin("jvm") + id("org.jetbrains.dokka") + jacoco + maven + `maven-publish` +} + +description = "Generates Rust/Python server-side code from Smithy models" + +extra["displayName"] = "Smithy :: Rust :: Codegen :: Server :: Python" + +extra["moduleName"] = "software.amazon.smithy.rust.codegen.server.python" + +group = "software.amazon.smithy.rust.codegen.server.python.smithy" + +version = "0.1.0" + +val smithyVersion: String by project +val kotestVersion: String by project + +dependencies { + implementation(kotlin("stdlib-jdk8")) + api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") + api("com.moandjiezana.toml:toml4j:0.7.2") + implementation(project(":codegen")) + implementation(project(":codegen-server")) + implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") + implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") + implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") + runtimeOnly(project(":rust-runtime")) + testImplementation("org.junit.jupiter:junit-jupiter:5.6.1") + testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") +} + +// unlike the client-runtime, software.amazon.smithy.rust.codegen.smithy-kotlin codegen package is +// not expected to run on Android...we can target 1.8 +tasks.compileKotlin { kotlinOptions.jvmTarget = "1.8" } + +tasks.compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } + +// Reusable license copySpec +val licenseSpec = copySpec { + from("${project.rootDir}/LICENSE") + from("${project.rootDir}/NOTICE") +} + +// Configure jars to include license related info +tasks.jar { + metaInf.with(licenseSpec) + inputs.property("moduleName", project.name) + manifest { attributes["Automatic-Module-Name"] = project.name } +} + +val sourcesJar by tasks.creating(Jar::class) { + group = "publishing" + description = "Assembles Kotlin sources jar" + classifier = "sources" + from(sourceSets.getByName("main").allSource) +} + +tasks.test { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + exceptionFormat = TestExceptionFormat.FULL + showCauses = true + showExceptions = true + showStackTraces = true + showStandardStreams = true + } +} + +tasks.dokka { + outputFormat = "html" + outputDirectory = "$buildDir/javadoc" +} + +// Always build documentation +tasks["build"].finalizedBy(tasks["dokka"]) + +// Configure jacoco (code coverage) to generate an HTML report +tasks.jacocoTestReport { + reports { + xml.isEnabled = false + csv.isEnabled = false + html.destination = file("$buildDir/reports/jacoco") + } +} + +// Always run the jacoco test report after testing. +tasks["test"].finalizedBy(tasks["jacocoTestReport"]) + +publishing { + publications { + create("default") { + from(components["java"]) + artifact(sourcesJar) + } + } + repositories { maven { url = uri("$buildDir/repository") } } +} diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt new file mode 100644 index 0000000000..55420a1410 --- /dev/null +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt @@ -0,0 +1,78 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +package software.amazon.smithy.rust.codegen.server.python.smithy + +import software.amazon.smithy.build.PluginContext +import software.amazon.smithy.build.SmithyBuildPlugin +import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider +import software.amazon.smithy.model.Model +import software.amazon.smithy.model.shapes.ServiceShape +import software.amazon.smithy.rust.codegen.rustlang.RustReservedWordSymbolProvider +import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenVisitor +import software.amazon.smithy.rust.codegen.smithy.BaseSymbolMetadataProvider +import software.amazon.smithy.rust.codegen.smithy.DefaultConfig +import software.amazon.smithy.rust.codegen.smithy.EventStreamSymbolProvider +import software.amazon.smithy.rust.codegen.smithy.StreamingShapeMetadataProvider +import software.amazon.smithy.rust.codegen.smithy.StreamingShapeSymbolProvider +import software.amazon.smithy.rust.codegen.smithy.SymbolVisitor +import software.amazon.smithy.rust.codegen.smithy.SymbolVisitorConfig +import software.amazon.smithy.rust.codegen.smithy.customize.CombinedCodegenDecorator +import java.util.logging.Level +import java.util.logging.Logger + +/** Rust Codegen Plugin + * This is the entrypoint for code generation, triggered by the smithy-build plugin. + * `resources/META-INF.services/software.amazon.smithy.build.SmithyBuildPlugin` refers to this class by name which + * enables the smithy-build plugin to invoke `execute` with all of the Smithy plugin context + models. + */ +class RustCodegenServerPlugin : SmithyBuildPlugin { + private val logger = Logger.getLogger(javaClass.name) + + override fun getName(): String = "rust-server-codegen" + + override fun execute(context: PluginContext) { + // Suppress extremely noisy logs about reserved words + Logger.getLogger(ReservedWordSymbolProvider::class.java.name).level = Level.OFF + // Discover [RustCodegenDecorators] on the classpath. [RustCodegenDectorator] return different types of + // customization. A customization is a function of: + // - location (e.g. the mutate section of an operation) + // - context (e.g. the of the operation) + // - writer: The active RustWriter at the given location + val codegenDecorator = CombinedCodegenDecorator.fromClasspath(context) + + // ServerCodegenVisitor is the main driver of code generation that traverses the model and generates code + logger.info("Loaded plugin to generate Rust/Python bindings for the server SSDK") + ServerCodegenVisitor(context, codegenDecorator).execute() + } + + companion object { + /** SymbolProvider + * When generating code, smithy types need to be converted into Rust types—that is the core role of the symbol provider + * + * The Symbol provider is composed of a base [SymbolVisitor] which handles the core functionality, then is layered + * with other symbol providers, documented inline, to handle the full scope of Smithy types. + */ + fun baseSymbolProvider( + model: Model, + serviceShape: ServiceShape, + symbolVisitorConfig: SymbolVisitorConfig = DefaultConfig + ) = + SymbolVisitor(model, serviceShape = serviceShape, config = symbolVisitorConfig) + // Generate different types for EventStream shapes (e.g. transcribe streaming) + .let { + EventStreamSymbolProvider(symbolVisitorConfig.runtimeConfig, it, model) + } + // Generate [ByteStream] instead of `Blob` for streaming binary shapes (e.g. S3 GetObject) + .let { StreamingShapeSymbolProvider(it, model) } + // Add Rust attributes (like `#[derive(PartialEq)]`) to generated shapes + .let { BaseSymbolMetadataProvider(it, additionalAttributes = listOf()) } + // Streaming shapes need different derives (e.g. they cannot derive Eq) + .let { StreamingShapeMetadataProvider(it, model) } + // Rename shapes that clash with Rust reserved words & and other SDK specific features e.g. `send()` cannot + // be the name of an operation input + .let { RustReservedWordSymbolProvider(it, model) } + } +} diff --git a/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin b/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin new file mode 100644 index 0000000000..45154e90a1 --- /dev/null +++ b/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin @@ -0,0 +1,5 @@ +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. +# +software.amazon.smithy.rust.codegen.server.python.smithy.RustCodegenServerPlugin diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt index bedb9440f8..0e39fed8e0 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/RustCodegenServerPlugin.kt @@ -43,6 +43,7 @@ class RustCodegenServerPlugin : SmithyBuildPlugin { val codegenDecorator = CombinedCodegenDecorator.fromClasspath(context) // ServerCodegenVisitor is the main driver of code generation that traverses the model and generates code + logger.info("Loaded plugin to generate pure Rust bindings for the server SSDK") ServerCodegenVisitor(context, codegenDecorator).execute() } diff --git a/settings.gradle.kts b/settings.gradle.kts index cbb4451ee1..ab84b0d82f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,7 +9,9 @@ enableFeaturePreview("GRADLE_METADATA") include(":codegen") include(":codegen-test") include(":codegen-server") +include(":codegen-server:python") include(":codegen-server-test") +include(":codegen-server-test:python") include(":rust-runtime") include(":aws:sdk-codegen") include(":aws:sdk-codegen-test") diff --git a/tools/codegen-diff-revisions.py b/tools/codegen-diff-revisions.py index 5116693d93..404d93c80b 100755 --- a/tools/codegen-diff-revisions.py +++ b/tools/codegen-diff-revisions.py @@ -94,18 +94,24 @@ def generate_and_commit_generated_code(revision_sha): # Generate code run("./gradlew --rerun-tasks :aws:sdk:assemble") run("./gradlew --rerun-tasks :codegen-server-test:assemble") + run("./gradlew --rerun-tasks :codegen-server-test:python:assemble") # Move generated code into codegen-diff/ directory run(f"rm -rf {OUTPUT_PATH}") run(f"mkdir {OUTPUT_PATH}") run(f"mv aws/sdk/build/aws-sdk {OUTPUT_PATH}") run(f"mv codegen-server-test/build/smithyprojections/codegen-server-test {OUTPUT_PATH}") + run(f"mv codegen-server-test/python/build/smithyprojections/python {OUTPUT_PATH}/codegen-server-test-python") # Clean up the server-test folder run(f"rm -rf {OUTPUT_PATH}/codegen-server-test/source") + run(f"rm -rf {OUTPUT_PATH}/codegen-server-test-python/source") run(f"find {OUTPUT_PATH}/codegen-server-test | " f"grep -E 'smithy-build-info.json|sources/manifest|model.json' | " f"xargs rm -f", shell=True) + run(f"find {OUTPUT_PATH}/codegen-server-test-python | " + f"grep -E 'smithy-build-info.json|sources/manifest|model.json' | " + f"xargs rm -f", shell=True) run(f"git add -f {OUTPUT_PATH}") run(f"git -c 'user.name=GitHub Action (generated code preview)' " @@ -187,15 +193,22 @@ def make_diffs(base_commit_sha, head_commit_sha): head_commit_sha, "server-test", whitespace=True) server_nows = make_diff("Server Test", f"{OUTPUT_PATH}/codegen-server-test", base_commit_sha, head_commit_sha, "server-test-ignore-whitespace", whitespace=False) + server_ws_python = make_diff("Server Test Python", f"{OUTPUT_PATH}/codegen-server-test-python", base_commit_sha, + head_commit_sha, "server-test-python", whitespace=True) + server_nows_python = make_diff("Server Test Python", f"{OUTPUT_PATH}/codegen-server-test-python", base_commit_sha, + head_commit_sha, "server-test-python-ignore-whitespace", whitespace=False) sdk_links = diff_link('AWS SDK', 'No codegen difference in the AWS SDK', sdk_ws, 'ignoring whitespace', sdk_nows) server_links = diff_link('Server Test', 'No codegen difference in the Server Test', server_ws, 'ignoring whitespace', server_nows) + server_links_python = diff_link('Server Test Python', 'No codegen difference in the Server Test Python', + server_ws_python, 'ignoring whitespace', server_nows_python) # Save escaped newlines so that the GitHub Action script gets the whole message return "A new generated diff is ready to view.\\n"\ f"- {sdk_links}\\n"\ - f"- {server_links}\\n" + f"- {server_links}\\n"\ + f"- {server_links_python}\\n" def write_to_file(path, text): From d3025b0c3ed5c6f822c46d706a2eb74f7a61a6aa Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 5 May 2022 12:21:08 +0100 Subject: [PATCH 2/9] Add codegen-server-python CI actions --- .github/workflows/ci.yml | 2 ++ ci.mk | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c2eff7371..0c621e8d20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,8 @@ jobs: - action: check-sdk-codegen-unit-tests - action: check-server-codegen-integration-tests - action: check-server-codegen-unit-tests + - action: check-server-codegen-integration-tests-python + - action: check-server-codegen-unit-tests-python - action: check-server-e2e-test - action: check-style-and-lints steps: diff --git a/ci.mk b/ci.mk index 0e60e46f46..a12b2d9810 100644 --- a/ci.mk +++ b/ci.mk @@ -59,6 +59,15 @@ check-server-codegen-integration-tests: check-server-codegen-unit-tests: $(CI_ACTION) $@ +.PHONY: check-server-codegen-integration-tests-python +check-server-codegen-integration-tests-python: + $(CI_ACTION) $@ + +.PHONY: check-server-codegen-unit-tests-python +check-server-codegen-unit-tests-python: + $(CI_ACTION) $@ + + .PHONY: check-server-e2e-test check-server-e2e-test: $(CI_ACTION) $@ From 68b34238b01afa1e4fb56a9b9d19c2c388fcd877 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 5 May 2022 13:07:25 +0100 Subject: [PATCH 3/9] Add CI script for python subproject --- .../check-server-codegen-integration-tests-python | 9 +++++++++ .../scripts/check-server-codegen-unit-tests-python | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100755 tools/ci-build/scripts/check-server-codegen-integration-tests-python create mode 100755 tools/ci-build/scripts/check-server-codegen-unit-tests-python diff --git a/tools/ci-build/scripts/check-server-codegen-integration-tests-python b/tools/ci-build/scripts/check-server-codegen-integration-tests-python new file mode 100755 index 0000000000..e8136227c3 --- /dev/null +++ b/tools/ci-build/scripts/check-server-codegen-integration-tests-python @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. +# + +set -eux +cd smithy-rs +./gradlew codegen-server-test:python:test diff --git a/tools/ci-build/scripts/check-server-codegen-unit-tests-python b/tools/ci-build/scripts/check-server-codegen-unit-tests-python new file mode 100755 index 0000000000..005417fdac --- /dev/null +++ b/tools/ci-build/scripts/check-server-codegen-unit-tests-python @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. +# + +set -eux +cd smithy-rs +./gradlew codegen-server:python:test From 9d0ee50364f24d8328d39e6b76541934719b025e Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 5 May 2022 16:57:20 +0100 Subject: [PATCH 4/9] Remove empty line from ci.mk --- ci.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/ci.mk b/ci.mk index a12b2d9810..209cec75eb 100644 --- a/ci.mk +++ b/ci.mk @@ -67,7 +67,6 @@ check-server-codegen-integration-tests-python: check-server-codegen-unit-tests-python: $(CI_ACTION) $@ - .PHONY: check-server-e2e-test check-server-e2e-test: $(CI_ACTION) $@ From ce7360fc683612022a0992939c64b67b85926bf0 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Thu, 5 May 2022 18:10:25 +0100 Subject: [PATCH 5/9] Cleanup dependencies from Grandle build scripts of server-codegen --- codegen-server/build.gradle.kts | 27 -------------------------- codegen-server/python/build.gradle.kts | 27 -------------------------- 2 files changed, 54 deletions(-) diff --git a/codegen-server/build.gradle.kts b/codegen-server/build.gradle.kts index 8b2a48cf52..33f6ca309b 100644 --- a/codegen-server/build.gradle.kts +++ b/codegen-server/build.gradle.kts @@ -7,8 +7,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { kotlin("jvm") - id("org.jetbrains.dokka") - jacoco maven `maven-publish` } @@ -27,14 +25,9 @@ val smithyVersion: String by project val kotestVersion: String by project dependencies { - implementation(kotlin("stdlib-jdk8")) - api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") - api("com.moandjiezana.toml:toml4j:0.7.2") implementation(project(":codegen")) implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") - implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") - runtimeOnly(project(":rust-runtime")) testImplementation("org.junit.jupiter:junit-jupiter:5.6.1") testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") } @@ -77,26 +70,6 @@ tasks.test { } } -tasks.dokka { - outputFormat = "html" - outputDirectory = "$buildDir/javadoc" -} - -// Always build documentation -tasks["build"].finalizedBy(tasks["dokka"]) - -// Configure jacoco (code coverage) to generate an HTML report -tasks.jacocoTestReport { - reports { - xml.isEnabled = false - csv.isEnabled = false - html.destination = file("$buildDir/reports/jacoco") - } -} - -// Always run the jacoco test report after testing. -tasks["test"].finalizedBy(tasks["jacocoTestReport"]) - publishing { publications { create("default") { diff --git a/codegen-server/python/build.gradle.kts b/codegen-server/python/build.gradle.kts index 0ce0b44f29..dc240f2aa9 100644 --- a/codegen-server/python/build.gradle.kts +++ b/codegen-server/python/build.gradle.kts @@ -7,8 +7,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat plugins { kotlin("jvm") - id("org.jetbrains.dokka") - jacoco maven `maven-publish` } @@ -27,15 +25,10 @@ val smithyVersion: String by project val kotestVersion: String by project dependencies { - implementation(kotlin("stdlib-jdk8")) - api("software.amazon.smithy:smithy-codegen-core:$smithyVersion") - api("com.moandjiezana.toml:toml4j:0.7.2") implementation(project(":codegen")) implementation(project(":codegen-server")) implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion") implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion") - implementation("software.amazon.smithy:smithy-waiters:$smithyVersion") - runtimeOnly(project(":rust-runtime")) testImplementation("org.junit.jupiter:junit-jupiter:5.6.1") testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") } @@ -78,26 +71,6 @@ tasks.test { } } -tasks.dokka { - outputFormat = "html" - outputDirectory = "$buildDir/javadoc" -} - -// Always build documentation -tasks["build"].finalizedBy(tasks["dokka"]) - -// Configure jacoco (code coverage) to generate an HTML report -tasks.jacocoTestReport { - reports { - xml.isEnabled = false - csv.isEnabled = false - html.destination = file("$buildDir/reports/jacoco") - } -} - -// Always run the jacoco test report after testing. -tasks["test"].finalizedBy(tasks["jacocoTestReport"]) - publishing { publications { create("default") { From 5a20d5b59d9d3e73aec1e85e1c258dbce96bee1b Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Fri, 6 May 2022 12:03:48 +0100 Subject: [PATCH 6/9] Configure codegen-server-test-python smithy-cli output directory. Fix comments --- codegen-server-test/python/build.gradle.kts | 6 +++++- codegen-server/build.gradle.kts | 3 --- codegen-server/python/build.gradle.kts | 3 --- .../codegen/server/python/smithy/RustCodegenServerPlugin.kt | 4 ++-- tools/codegen-diff-revisions.py | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/codegen-server-test/python/build.gradle.kts b/codegen-server-test/python/build.gradle.kts index d0a16b23ce..3392970125 100644 --- a/codegen-server-test/python/build.gradle.kts +++ b/codegen-server-test/python/build.gradle.kts @@ -16,7 +16,11 @@ val defaultRustDocFlags: String by project val properties = PropertyRetriever(rootProject, project) val pluginName = "rust-server-codegen" -val workingDirUnderBuildDir = "smithyprojections/python/" +val workingDirUnderBuildDir = "smithyprojections/codegen-server-test-python/" + +configure { + outputDirectory = file("$buildDir/$workingDirUnderBuildDir") +} buildscript { val smithyVersion: String by project diff --git a/codegen-server/build.gradle.kts b/codegen-server/build.gradle.kts index 33f6ca309b..a45fd0f188 100644 --- a/codegen-server/build.gradle.kts +++ b/codegen-server/build.gradle.kts @@ -32,10 +32,7 @@ dependencies { testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") } -// unlike the client-runtime, software.amazon.smithy.rust.codegen.smithy-kotlin codegen package is -// not expected to run on Android...we can target 1.8 tasks.compileKotlin { kotlinOptions.jvmTarget = "1.8" } - tasks.compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } // Reusable license copySpec diff --git a/codegen-server/python/build.gradle.kts b/codegen-server/python/build.gradle.kts index dc240f2aa9..3707666540 100644 --- a/codegen-server/python/build.gradle.kts +++ b/codegen-server/python/build.gradle.kts @@ -33,10 +33,7 @@ dependencies { testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") } -// unlike the client-runtime, software.amazon.smithy.rust.codegen.smithy-kotlin codegen package is -// not expected to run on Android...we can target 1.8 tasks.compileKotlin { kotlinOptions.jvmTarget = "1.8" } - tasks.compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } // Reusable license copySpec diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt index 55420a1410..be71190d77 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt @@ -23,7 +23,7 @@ import software.amazon.smithy.rust.codegen.smithy.customize.CombinedCodegenDecor import java.util.logging.Level import java.util.logging.Logger -/** Rust Codegen Plugin +/** Rust with Python bindings Codegen Plugin * This is the entrypoint for code generation, triggered by the smithy-build plugin. * `resources/META-INF.services/software.amazon.smithy.build.SmithyBuildPlugin` refers to this class by name which * enables the smithy-build plugin to invoke `execute` with all of the Smithy plugin context + models. @@ -31,7 +31,7 @@ import java.util.logging.Logger class RustCodegenServerPlugin : SmithyBuildPlugin { private val logger = Logger.getLogger(javaClass.name) - override fun getName(): String = "rust-server-codegen" + override fun getName(): String = "rust-server-codegen-python" override fun execute(context: PluginContext) { // Suppress extremely noisy logs about reserved words diff --git a/tools/codegen-diff-revisions.py b/tools/codegen-diff-revisions.py index 404d93c80b..78933b8e70 100755 --- a/tools/codegen-diff-revisions.py +++ b/tools/codegen-diff-revisions.py @@ -101,7 +101,7 @@ def generate_and_commit_generated_code(revision_sha): run(f"mkdir {OUTPUT_PATH}") run(f"mv aws/sdk/build/aws-sdk {OUTPUT_PATH}") run(f"mv codegen-server-test/build/smithyprojections/codegen-server-test {OUTPUT_PATH}") - run(f"mv codegen-server-test/python/build/smithyprojections/python {OUTPUT_PATH}/codegen-server-test-python") + run(f"mv codegen-server-test/python/build/smithyprojections/codegen-server-test-python {OUTPUT_PATH}") # Clean up the server-test folder run(f"rm -rf {OUTPUT_PATH}/codegen-server-test/source") From fa5b4465e56378d6f95bd7a2bc36562a8cd0099e Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Fri, 6 May 2022 16:28:38 +0100 Subject: [PATCH 7/9] Add decriptions to codegen-server-test projects --- codegen-server-test/build.gradle.kts | 1 + codegen-server-test/python/build.gradle.kts | 1 + .../codegen/server/python/smithy/RustCodegenServerPlugin.kt | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codegen-server-test/build.gradle.kts b/codegen-server-test/build.gradle.kts index f0f156dfcf..cc4e6d058c 100644 --- a/codegen-server-test/build.gradle.kts +++ b/codegen-server-test/build.gradle.kts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +description = "Generates Rust code from Smithy models and runs the protocol tests" extra["displayName"] = "Smithy :: Rust :: Codegen :: Server :: Test" extra["moduleName"] = "software.amazon.smithy.rust.kotlin.codegen.server.test" diff --git a/codegen-server-test/python/build.gradle.kts b/codegen-server-test/python/build.gradle.kts index 3392970125..0b1d519141 100644 --- a/codegen-server-test/python/build.gradle.kts +++ b/codegen-server-test/python/build.gradle.kts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0. */ +description = "Generates Rust/Python code from Smithy models and runs the protocol tests" extra["displayName"] = "Smithy :: Rust :: Codegen :: Server :: Python :: Test" extra["moduleName"] = "software.amazon.smithy.rust.kotlin.codegen.server.python.test" diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt index be71190d77..2fd02527d8 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt @@ -23,7 +23,7 @@ import software.amazon.smithy.rust.codegen.smithy.customize.CombinedCodegenDecor import java.util.logging.Level import java.util.logging.Logger -/** Rust with Python bindings Codegen Plugin +/** Rust with Python bindings Codegen Plugin. * This is the entrypoint for code generation, triggered by the smithy-build plugin. * `resources/META-INF.services/software.amazon.smithy.build.SmithyBuildPlugin` refers to this class by name which * enables the smithy-build plugin to invoke `execute` with all of the Smithy plugin context + models. From aad9ed40c818ac358f167b3a42b6d75f263918c0 Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Wed, 18 May 2022 14:20:51 +0100 Subject: [PATCH 8/9] Fix python RustCodegenServerPlugin license header --- .../codegen/server/python/smithy/RustCodegenServerPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt index 2fd02527d8..1bd6ac5405 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/RustCodegenServerPlugin.kt @@ -1,6 +1,6 @@ /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. + * SPDX-License-Identifier: Apache-2.0 */ package software.amazon.smithy.rust.codegen.server.python.smithy From 26c6d0bb19f6c1a62882cf738a9b7962dc85951a Mon Sep 17 00:00:00 2001 From: Bigo <1781140+crisidev@users.noreply.github.com> Date: Wed, 18 May 2022 14:26:52 +0100 Subject: [PATCH 9/9] Fix multiple license headers --- codegen-server-test/python/build.gradle.kts | 2 +- codegen-server/python/build.gradle.kts | 2 +- .../services/software.amazon.smithy.build.SmithyBuildPlugin | 2 +- .../scripts/check-server-codegen-integration-tests-python | 2 +- tools/ci-build/scripts/check-server-codegen-unit-tests-python | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen-server-test/python/build.gradle.kts b/codegen-server-test/python/build.gradle.kts index 0b1d519141..9bc81a5f24 100644 --- a/codegen-server-test/python/build.gradle.kts +++ b/codegen-server-test/python/build.gradle.kts @@ -1,6 +1,6 @@ /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. + * SPDX-License-Identifier: Apache-2.0 */ description = "Generates Rust/Python code from Smithy models and runs the protocol tests" diff --git a/codegen-server/python/build.gradle.kts b/codegen-server/python/build.gradle.kts index 3707666540..c042410caf 100644 --- a/codegen-server/python/build.gradle.kts +++ b/codegen-server/python/build.gradle.kts @@ -1,6 +1,6 @@ /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0. + * SPDX-License-Identifier: Apache-2.0 */ import org.gradle.api.tasks.testing.logging.TestExceptionFormat diff --git a/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin b/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin index 45154e90a1..ea7c4546af 100644 --- a/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin +++ b/codegen-server/python/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin @@ -1,5 +1,5 @@ # # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0. +# SPDX-License-Identifier: Apache-2.0 # software.amazon.smithy.rust.codegen.server.python.smithy.RustCodegenServerPlugin diff --git a/tools/ci-build/scripts/check-server-codegen-integration-tests-python b/tools/ci-build/scripts/check-server-codegen-integration-tests-python index e8136227c3..d0ea58026f 100755 --- a/tools/ci-build/scripts/check-server-codegen-integration-tests-python +++ b/tools/ci-build/scripts/check-server-codegen-integration-tests-python @@ -1,7 +1,7 @@ #!/bin/bash # # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0. +# SPDX-License-Identifier: Apache-2.0 # set -eux diff --git a/tools/ci-build/scripts/check-server-codegen-unit-tests-python b/tools/ci-build/scripts/check-server-codegen-unit-tests-python index 005417fdac..0338f4d686 100755 --- a/tools/ci-build/scripts/check-server-codegen-unit-tests-python +++ b/tools/ci-build/scripts/check-server-codegen-unit-tests-python @@ -1,7 +1,7 @@ #!/bin/bash # # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0. +# SPDX-License-Identifier: Apache-2.0 # set -eux