forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
tools/ci-scripts/codegen-diff-revisions.py
fault tolerant (smi…
- Loading branch information
Showing
1 changed file
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected] | ||
# $ 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 | ||
|
||
|
||
|
@@ -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") | ||
|
@@ -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 | ||
|