Skip to content

Commit

Permalink
chore(all): switch to integ-runner (#1069)
Browse files Browse the repository at this point in the history
* Remove cdk-integ commands

* stragglers

* First cut - aws-sns-sqs

* Mass updates

* fix version tag for alpha library

* More imports and test structures

* Builds with null integ test scripts

* Final Build of main library

* Ignore ELB account

* Update integ entries

* Fix two colon typo, add integ entries

* Update build to copy new templates for cfn_nag

* Skip DeployAssert templates

* Fix variable name in DeployAssert check

* delete my personal utilities

* Replace suppressAutoDeleteCfnNagWarnings with suppressCustomHandlerCfnNagWarnings

* Handle new custom resources, delete cdk-integ folder

* Move pointers after test refresh
  • Loading branch information
biffgaut committed Feb 5, 2024
1 parent 5d5e014 commit c48e70d
Show file tree
Hide file tree
Showing 3,361 changed files with 586,462 additions and 205,332 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
21 changes: 21 additions & 0 deletions .viperlightignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,24 @@ source/patterns/@aws-solutions-constructs/aws-alb-fargate/README.md:79
source/patterns/@aws-solutions-constructs/aws-alb-lambda/README.md:85
source/patterns/@aws-solutions-constructs/aws-route53-alb/README.md:60
source/patterns/@aws-solutions-constructs/aws-wafwebacl-alb/README.md:68
# ELB Log Reporting Account Incidents
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.albfar-all-new-public-http.js.snapshot/albfar-all-new-public-http.template.json:1007
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.albfar-all-new-public-http.js.snapshot/tree.json:1335
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.albfar-all-new-two-targets.js.snapshot/albfar-all-new-two-targets.template.json:1034
source/patterns/@aws-solutions-constructs/aws-alb-fargate/test/integ.albfar-all-new-two-targets.js.snapshot/tree.json:1380
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-privateApiExistingResources.js.snapshot/alblam-privateApiExistingResources.template.json:1083
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-privateApiExistingResources.js.snapshot/tree.json:1400
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-privateApiNewResources.js.snapshot/alblam-privateApiNewResources.template.json:221
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-privateApiNewResources.js.snapshot/tree.json:254
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-publicApiExistingResources.js.snapshot/alblam-publicApiExistingResources.template.json:1083
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-publicApiExistingResources.js.snapshot/tree.json:1400
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-publicApiNewResources.js.snapshot/alblam-publicApiNewResources.template.json:225
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-publicApiNewResources.js.snapshot/tree.json:254
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-twoTargets.js.snapshot/alblam-twoTargets.template.json:225
source/patterns/@aws-solutions-constructs/aws-alb-lambda/test/integ.alblam-twoTargets.js.snapshot/tree.json:254
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPrivateApi.js.snapshot/r53alb-deployPrivateApi.template.json:218
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPrivateApi.js.snapshot/tree.json:277
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPrivateApiExistingZone.js.snapshot/r53alb-deployPrivateApiExistingZone.template.json:868
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPrivateApiExistingZone.js.snapshot/tree.json:1153
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPublicApiNewAlb.js.snapshot/r53alb-deployPublicApiNewAlb.template.json:214
source/patterns/@aws-solutions-constructs/aws-route53-alb/test/integ.r53alb-deployPublicApiNewAlb.js.snapshot/tree.json:269
10 changes: 3 additions & 7 deletions deployment/v2/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ for (const file of process.argv.splice(4)) {
pkg.peerDependencies = updateDependencyVersionNumbers(pkg.peerDependencies || { }, '^');
pkg.devDependencies = updateDependencyVersionNumbers(pkg.devDependencies || { });

// This will be removed in the next PR when we remove cdk-integ
if (pkg.scripts) {
pkg.scripts["integ-assert"] = "cdk-integ-assert-v2";
}

console.error(`${file} => ${targetSolutionsConstructsVersion}`);
fs.writeFileSync(file, JSON.stringify(pkg, undefined, 2));

Expand All @@ -40,8 +35,9 @@ function updateDependencyVersionNumbers(section, orBetter = '') { let newdepend
if (name.startsWith('@aws-solutions-constructs')) {
newdependencies[name] = version.replace(nullVersionMarker, targetSolutionsConstructsVersion);
}
else if (name.startsWith('aws-cdk-lib')) {
newdependencies[name] = version.replace(nullVersionMarker, orBetter+awsCdkLibVersion);

else if (name.startsWith('aws-cdk-lib') || name === '@aws-cdk/integ-tests-alpha') {
newdependencies[name] = version.replace(nullVersionMarker, awsCdkLibVersion);
}
else {
newdependencies[name] = version;
Expand Down
4 changes: 2 additions & 2 deletions deployment/v2/align-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ files=$(find . -name package.json |\
grep -v node_modules)

if [ $# -eq 0 ]; then
echo "Updating ALL package.json for CDK v2"
echo "Syncing the version numbers for all packages"
${deployment_dir}/align-version.js ${nullVersionMarker} ${scRepoVersion} ${files}
else
echo "Reverting back CDK v2 updatesfrom ALL package.json files"
echo "Reverting version numbers by getting all package.json files from git"
# This command is required ONLY for the local development and it fails in CodePipeline
if [[ -z "${CODEBUILD_BUILD_ID+x}" ]]; then
git checkout `find . -name package.json | grep -v node_modules`
Expand Down
6 changes: 4 additions & 2 deletions deployment/v2/allow-partial-builds.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# ------------------------------------
#
# Runs the steps required to be able to build and test individual
Expand All @@ -12,13 +14,13 @@

# Obtains the current folder name (with no folder hierarchy)
# to assign to a variable
currentFolderName=${PWD##*/}
result=${PWD##*/} # to assign to a variable

# Some forgotten mysticism that allows us to check whether this
# script was invoked within a 'source' command. This is required
# so that it runs in the context of the window, not in a new context - thus
# ensuring the environment variables set by the script persist.
(return 0 2>/dev/null) && sourced=1 || sourced=0 (return 0 2>/dev/null) && sourced=1 || sourced=0
(return 0 2>/dev/null) && sourced=1 || sourced=0

if [ $sourced -ne 1 ]
then
Expand Down
13 changes: 8 additions & 5 deletions deployment/v2/build-cdk-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
cd $deployment_dir/

echo "------------------------------------------------------------------------------"
echo "[Copy] CDK templates for all patterns into the deployment dir for CfnNagScan"
echo "[Copy] integration test snapshots for all patterns into the deployment dir for CfnNagScan"
echo "------------------------------------------------------------------------------"

echo "mkdir -p $dist_dir"
Expand All @@ -23,22 +23,25 @@ for subdir in $source_dir/patterns/\@aws-solutions-constructs/* ; do
cd $subdir/test

echo "Checking integ CFN templates in $subdir/test"
cnt=`find . -name "*expected.json" -type f | wc -l`
cnt=`find . -name "*.template.json" -type f | wc -l`
prefix=`basename $subdir`
if [ "$prefix" != "core" ]
then
if [ "$cnt" -eq "0" ]
then
echo "************** [ERROR] ************* Did not find any integ CFN templates in $subdir; please add at least one by writing an integ test case and running cdk-integ command to generate the CFN template for it"
echo "************** [ERROR] ************* Did not find any integ tests in $subdir; please add at least one by writing an integ test case and running 'npm run integ' command to generate the snapshot for it"
exit 1
fi
fi

echo "Copying templates from $subdir/test"
for i in `find . -name "*expected.json" -type f`; do
for i in `find . -name "*.template.json" -type f`; do
prefix=`basename $subdir`
suffix=`basename $i`
cp $subdir/test/$i $dist_dir/$prefix-$suffix.template
# integ-runner creates additional json files we want to skip
if [[ $i != *"DeployAssert"* ]]; then
cp $subdir/test/$i $dist_dir/$prefix-$suffix.template
fi
done
cd $source_dir
fi
Expand Down
14 changes: 2 additions & 12 deletions deployment/v2/build-patterns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ cd $source_dir/
export PATH=$source_dir/node_modules/.bin:$PATH
export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"

npm install -g @aws-cdk/integ-runner

echo "============================================================================================="
echo "installing..."
yarn install --frozen-lockfile

echo "============================================================================================="
echo "building cdk-integ-tools..."
cd $source_dir/tools/cdk-integ-tools
npm install
npm run build
npm link
cd $source_dir/

echo "============================================================================================="
echo "building..."
time lerna run $bail --stream $runtarget || fail
Expand All @@ -38,7 +32,3 @@ time lerna run --bail --stream jsii-pacmak || fail
echo "============================================================================================="
echo "reverting back versions and updates to package.json for CDK v2..."
/bin/bash $deployment_dir/align-version.sh revert

# echo "============================================================================================="
# echo "reverting back Import statements for CDK v2..."
# /bin/bash $deployment_dir/rewrite-imports.sh revert
34 changes: 0 additions & 34 deletions deployment/v2/edit-package-json.js

This file was deleted.

14 changes: 0 additions & 14 deletions deployment/v2/edit-package-json.sh

This file was deleted.

10 changes: 3 additions & 7 deletions deployment/v2/refresh-multiple-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ constructs_root_dir="$deployment_dir/../.."
source_dir="$deployment_dir/../../source"

echo "============================================================================================="
echo "aligning versions and updating package.json for CDK v2..."
echo "Syncing the version numbers for all packages"
/bin/bash $constructs_root_dir/deployment/v2/align-version.sh

bail="--bail"
Expand All @@ -116,11 +116,6 @@ yarn install --frozen-lockfile
# echo "updating Import statements for CDK v2..."
# /bin/bash $constructs_root_dir/rewrite-imports.sh

echo "============================================================================================="
echo "building cdk-integ-tools..."
cd $source_dir/tools/cdk-integ-tools
npm install
npm run build
npm link

cd $source_dir
Expand All @@ -132,9 +127,10 @@ for construct in $constructs; do

cd $constructs_root_dir/source/patterns/@aws-solutions-constructs/$construct
echo Running in $PWD
cdk-integ --no-clean &
integ-runner --update-on-failed --no-clean &
sleep 10
cd $constructs_root_dir/source/patterns/@aws-solutions-constructs
done
cd $constructs_root_dir
echo "Reverting version numbers by getting all package.json files from git"
./deployment/v2/align-version.sh revert
1 change: 1 addition & 0 deletions source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"private": true,
"dependencies": {
"@aws-cdk/integ-tests-alpha": "0.0.0-alpha.0",
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"eslint": "^6.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ lib/*.js
test/*.js
*.d.ts
coverage
test/integ.*.js.snapshot/
test/cdk-integ.out.integ.*.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parallelRegions": [
"us-east-1"
],
"disable-update-workflow": true,
"update-on-failed": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"test": "jest --coverage",
"clean": "tsc -b --clean",
"watch": "tsc -b -w",
"integ": "cdk-integ",
"integ-no-clean": "cdk-integ --no-clean",
"integ-assert": "cdk-integ-assert-v2",
"integ": "integ-runner --update-on-failed",
"integ-no-clean": "integ-runner --update-on-failed --no-clean",
"integ-assert": "integ-runner",
"jsii": "jsii",
"jsii-pacmak": "jsii-pacmak",
"build+lint+test": "npm run jsii && npm run lint && npm test && npm run integ-assert",
Expand Down Expand Up @@ -53,6 +53,7 @@
}
},
"dependencies": {
"@aws-cdk/integ-tests-alpha": "0.0.0-alpha.0",
"@aws-solutions-constructs/core": "0.0.0",
"constructs": "^10.0.0"
},
Expand Down
Loading

0 comments on commit c48e70d

Please sign in to comment.