Skip to content

Commit

Permalink
Merge branch 'main' into davidpz/check-content-type-in-all-protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
david-perez authored Apr 4, 2023
2 parents 83fab65 + c901c0b commit 651824f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
5 changes: 2 additions & 3 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import aws.sdk.AwsServices
import aws.sdk.Membership
import aws.sdk.RootTest
import aws.sdk.discoverServices
import aws.sdk.docsLandingPage
import aws.sdk.parseMembership
Expand Down Expand Up @@ -302,9 +301,9 @@ tasks.register<Copy>("relocateChangelog") {
fun generateCargoWorkspace(services: AwsServices): String {
return """
|[workspace]
|exclude = [${"\n"}${services.rootTests.map(RootTest::manifestName).joinToString(",\n") { "| \"$it\"" }}
|exclude = [${"\n"}${services.excludedFromWorkspace().joinToString(",\n") { "| \"$it\"" }}
|]
|members = [${"\n"}${services.allModules.joinToString(",\n") { "| \"$it\"" }}
|members = [${"\n"}${services.includedInWorkspace().joinToString(",\n") { "| \"$it\"" }}
|]
""".trimMargin()
}
Expand Down
16 changes: 13 additions & 3 deletions buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class AwsServices(
(
services.map(AwsService::module).map { "sdk/$it" } +
CrateSet.AWS_SDK_SMITHY_RUNTIME.map { "sdk/$it" } +
CrateSet.AWS_SDK_RUNTIME.map { "sdk/$it" } +
examples
CrateSet.AWS_SDK_RUNTIME.map { "sdk/$it" }
// Root tests should not be included since they can't be part of the root Cargo workspace
// in order to test differences in Cargo features.
// in order to test differences in Cargo features. Examples should not be included either
// because each example itself is a workspace.
).toSortedSet()
}

Expand Down Expand Up @@ -78,6 +78,16 @@ class AwsServices(
false
}
}

/**
* Returns a sorted set of members included in the workspace.
*/
fun includedInWorkspace() = allModules

/**
* Returns a list of crates excluded from the workspace.
*/
fun excludedFromWorkspace() = examples + rootTests.map(RootTest::manifestName)
}

/**
Expand Down
27 changes: 17 additions & 10 deletions tools/ci-scripts/codegen-diff/diff_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,37 @@

CDN_URL = "https://d2luzm2xt3nokh.cloudfront.net"

target_codegen_client = 'codegen-client-test'
target_codegen_server = 'codegen-server-test'
target_aws_sdk = 'aws:sdk'


def generate_and_commit_generated_code(revision_sha, targets=None):
targets = targets or ['codegen-client-test', 'codegen-server-test', 'aws:sdk']
targets = targets or [target_codegen_client, target_codegen_server, target_aws_sdk]
# Clean the build artifacts before continuing
get_cmd_output("rm -rf aws/sdk/build")
if 'codegen-server-test' in targets:
if target_codegen_server in targets:
get_cmd_output("cd rust-runtime/aws-smithy-http-server-python/examples && make distclean", shell=True)
get_cmd_output("./gradlew codegen-core:clean codegen-client:clean codegen-server:clean aws:sdk-codegen:clean")

# Generate code
tasks = ' '.join([f'{t}:assemble' for t in targets])
get_cmd_output(f"./gradlew --rerun-tasks {tasks}")
if 'codegen-server-test' in targets:
if target_codegen_server in targets:
get_cmd_output("cd rust-runtime/aws-smithy-http-server-python/examples && make build", shell=True, check=False)

# Move generated code into codegen-diff/ directory
get_cmd_output(f"rm -rf {OUTPUT_PATH}")
get_cmd_output(f"mkdir {OUTPUT_PATH}")
if 'aws:sdk' in targets:
if target_aws_sdk in targets:
get_cmd_output(f"mv aws/sdk/build/aws-sdk {OUTPUT_PATH}/")
for target in ['codegen-client', 'codegen-server']:
for target in [target_codegen_client, target_codegen_server]:
if target in targets:
get_cmd_output(f"mv {target}/build/smithyprojections/{target} {OUTPUT_PATH}/")
if target == 'codegen-server-test':
get_cmd_output(f"mv rust-runtime/aws-smithy-http-server-python/examples/pokemon-service-server-sdk/ {OUTPUT_PATH}/codegen-server-test-python/", check=False)
if target == target_codegen_server:
get_cmd_output(
f"mv rust-runtime/aws-smithy-http-server-python/examples/pokemon-service-server-sdk/ {OUTPUT_PATH}/codegen-server-test-python/",
check=False)

# Clean up the SDK directory
get_cmd_output(f"rm -f {OUTPUT_PATH}/aws-sdk/versions.toml")
Expand All @@ -58,9 +64,9 @@ def generate_and_commit_generated_code(revision_sha, targets=None):

get_cmd_output(f"git add -f {OUTPUT_PATH}")
get_cmd_output(f"git -c 'user.name=GitHub Action (generated code preview)' "
f"-c 'user.name={COMMIT_AUTHOR_NAME}' "
f"-c 'user.email={COMMIT_AUTHOR_EMAIL}' "
f"commit --no-verify -m 'Generated code for {revision_sha}' --allow-empty")
f"-c 'user.name={COMMIT_AUTHOR_NAME}' "
f"-c 'user.email={COMMIT_AUTHOR_EMAIL}' "
f"commit --no-verify -m 'Generated code for {revision_sha}' --allow-empty")


def make_diff(title, path_to_diff, base_commit_sha, head_commit_sha, suffix, whitespace):
Expand Down Expand Up @@ -167,6 +173,7 @@ def get_cmd_output(command, cwd=None, check=True, **kwargs):

return result.returncode, stdout, stderr


# Runs a shell command and returns its exit status
def get_cmd_status(command):
return subprocess.run(command, capture_output=True, shell=True).returncode

0 comments on commit 651824f

Please sign in to comment.