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

Make codegen diff fault tolerant #2426

Merged
merged 1 commit into from
Mar 2, 2023
Merged
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
15 changes: 7 additions & 8 deletions tools/ci-scripts/codegen-diff-revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
#
# ```
# $ cd test/smithy-rs
# $ ../../smithy-rs/tools/codegen-diff-revisions.py . <some commit hash to diff against>
# $ ../../smithy-rs/tools/ci-scripts/codegen-diff-revisions.py . <some commit hash to diff against>
# ```
#
# It will diff the generated code from HEAD against any commit hash you feed it. If you want to test
# a specific range, change the HEAD of the test repository.
#
# This script requires `diff2html-cli` to be installed from NPM:
# This script requires `difftags` to be installed from `tools/ci-build/difftags`:
# ```
# $ npm install -g diff2html-cli@5.1.11
# $ cargo install --path tools/ci-build/difftags
# ```
# Make sure the local version matches the version referenced from the GitHub Actions workflow.

import os
import sys
import subprocess
import tempfile
import shlex


Expand Down Expand Up @@ -94,15 +93,15 @@ def generate_and_commit_generated_code(revision_sha):

# Generate code
run("./gradlew --rerun-tasks aws:sdk:assemble codegen-client-test:assemble codegen-server-test:assemble")
run("cd rust-runtime/aws-smithy-http-server-python/examples && make build", shell=True)
run("cd rust-runtime/aws-smithy-http-server-python/examples && make build", shell=True, check=False)

# 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-client-test/build/smithyprojections/codegen-client-test {OUTPUT_PATH}/")
run(f"mv codegen-server-test/build/smithyprojections/codegen-server-test {OUTPUT_PATH}/")
run(f"mv rust-runtime/aws-smithy-http-server-python/examples/pokemon-service-server-sdk/ {OUTPUT_PATH}/codegen-server-test-python/")
run(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
run(f"rm -f {OUTPUT_PATH}/aws-sdk/versions.toml")
Expand Down Expand Up @@ -201,10 +200,10 @@ def eprint(*args, **kwargs):


# Runs a shell command
def run(command, shell=False):
def run(command, shell=False, check=True):
if not shell:
command = shlex.split(command)
subprocess.run(command, stdout=sys.stderr, stderr=sys.stderr, shell=shell, check=True)
subprocess.run(command, stdout=sys.stderr, stderr=sys.stderr, shell=shell, check=check)


# Returns the output from a shell command. Bails if the command failed
Expand Down