Skip to content

Commit

Permalink
chore(build): fast fail PR builds if rosetta extraction fails (aws#14946
Browse files Browse the repository at this point in the history
)

Modify the build script to run jsii-rosetta extraction if the `--extract` flag is passed. This will allow PR builds to run extraction, ensuring that modules who have strict snippet compilation enabled will fail to build if a change causes a snippet to fail compilation.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
BenChaimberg authored Jun 9, 2021
1 parent 0d00e50 commit ba46b5a
Show file tree
Hide file tree
Showing 237 changed files with 787 additions and 255 deletions.
20 changes: 16 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
set -euo pipefail

bail="--bail"
runtarget="build+test"
runtarget="build"
run_tests="true"
check_prereqs="true"
check_compat="true"
extract_snippets="false"
while [[ "${1:-}" != "" ]]; do
case $1 in
-h|--help)
echo "Usage: build.sh [--no-bail] [--force|-f] [--skip-test]"
echo "Usage: build.sh [--no-bail] [--force|-f] [--skip-test] [--skip-prereqs] [--skip-compat] [--extract]"
exit 1
;;
--no-bail)
Expand All @@ -18,14 +20,17 @@ while [[ "${1:-}" != "" ]]; do
export CDK_BUILD="--force"
;;
--skip-test|--skip-tests)
runtarget="build"
run_tests="false"
;;
--skip-prereqs)
check_prereqs="false"
;;
--skip-compat)
check_compat="false"
;;
--extract)
extract_snippets="true"
;;
*)
echo "Unrecognized parameter: $1"
exit 1
Expand All @@ -35,7 +40,7 @@ while [[ "${1:-}" != "" ]]; do
done

export PATH=$(npm bin):$PATH
export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
export NODE_OPTIONS="--max-old-space-size=4096 --experimental-worker ${NODE_OPTIONS:-}"

if ! [ -x "$(command -v yarn)" ]; then
echo "yarn is not installed. Install it from here- https://yarnpkg.com/en/docs/install."
Expand Down Expand Up @@ -73,6 +78,13 @@ rm -rf $BUILD_INDICATOR
export MERKLE_BUILD_CACHE=$(mktemp -d)
trap "rm -rf $MERKLE_BUILD_CACHE" EXIT

if [ "$run_tests" == "true" ]; then
runtarget="$runtarget+test"
fi
if [ "$extract_snippets" == "true" ]; then
runtarget="$runtarget+extract"
fi

echo "============================================================================================="
echo "building..."
time lerna run $bail --stream $runtarget || fail
Expand Down
2 changes: 1 addition & 1 deletion buildspec-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ phases:
- yarn --version || npm -g install yarn
build:
commands:
- /bin/bash ./build.sh && git diff-index --exit-code --ignore-space-at-eol --stat HEAD
- /bin/bash ./build.sh --extract && git diff-index --exit-code --ignore-space-at-eol --stat HEAD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"awslint": "cdk-awslint",
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"build+extract": "yarn build",
"build+test+extract": "yarn build+test"
},
"keywords": [
"aws",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "Alexa::ASK",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"dependencies": {
"@aws-cdk/aws-cloudformation": "0.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/assert-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test"
"build+test": "yarn build && yarn test",
"build+extract": "yarn build",
"build+test+extract": "yarn build+test"
},
"author": {
"name": "Amazon Web Services",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"pkglint": "pkglint -f",
"package": "cdk-package",
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test"
"build+test": "yarn build && yarn test",
"build+extract": "yarn build",
"build+test+extract": "yarn build+test"
},
"cdk-build": {
"jest": true,
Expand Down
10 changes: 8 additions & 2 deletions packages/@aws-cdk/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"pre": [
Expand Down Expand Up @@ -98,7 +100,11 @@
"announce": false
},
"nozem": {
"ostools": ["rm", "tar", "gzip"]
"ostools": [
"rm",
"tar",
"gzip"
]
},
"publishConfig": {
"tag": "latest"
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"build+test+package": "yarn build+test && yarn package",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AccessAnalyzer",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-acmpca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::ACMPCA",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AmazonMQ",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test+package": "yarn build+test && yarn package",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::Amplify",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::ApiGateway",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"compat": "cdk-compat",
"build+test": "yarn build && yarn test",
"build+test+package": "yarn build+test && yarn package",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"jest": true,
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2-integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"compat": "cdk-compat",
"build+test": "yarn build && yarn test",
"build+test+package": "yarn build+test && yarn package",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"jest": true,
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"build+test": "yarn build && yarn test",
"build+test+package": "yarn build+test && yarn package",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::ApiGatewayV2",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppConfig",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppFlow",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appintegrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
"build+test+package": "yarn build+test && yarn package",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppIntegrations",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationAutoScaling",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-applicationinsights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationInsights",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appmesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppMesh",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apprunner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
"build+test+package": "yarn build+test && yarn package",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppRunner",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppStream",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AppSync",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"keywords": [
"aws",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-auditmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AuditManager",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-autoscaling-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"keywords": [
"aws",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-autoscaling-hooktargets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"build+test+package": "yarn build+test && yarn package",
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"keywords": [
"aws",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AutoScaling",
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-autoscalingplans/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"build+test": "yarn build && yarn test",
"compat": "cdk-compat",
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
"rosetta:extract": "yarn --silent jsii-rosetta extract",
"build+extract": "yarn build && yarn rosetta:extract",
"build+test+extract": "yarn build+test && yarn rosetta:extract"
},
"cdk-build": {
"cloudformation": "AWS::AutoScalingPlans",
Expand Down
Loading

0 comments on commit ba46b5a

Please sign in to comment.