diff --git a/codebuild_specs/base.yml b/codebuild_specs/base.yml new file mode 100644 index 00000000000..25dfe25c6ff --- /dev/null +++ b/codebuild_specs/base.yml @@ -0,0 +1,74 @@ +--- +version: 0.2 +batch: + fast-fail: false + build-graph: + - identifier: prepare_build + buildspec: codebuild_specs/prepare_build.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + - identifier: cleanup_e2e_resources + buildspec: codebuild_specs/cleanup_e2e_resources.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: mock_e2e_tests + buildspec: codebuild_specs/mock_e2e_tests.yml + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: test + buildspec: codebuild_specs/test.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: lint + buildspec: codebuild_specs/lint.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: validate_cdk_version + buildspec: codebuild_specs/validate_cdk_version.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_api_extract + buildspec: codebuild_specs/verify_api_extract.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_yarn_lock + buildspec: codebuild_specs/verify_yarn_lock.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build diff --git a/codebuild_specs/cleanup_e2e_resources.yml b/codebuild_specs/cleanup_e2e_resources.yml new file mode 100644 index 00000000000..6dd10460772 --- /dev/null +++ b/codebuild_specs/cleanup_e2e_resources.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _cleanupE2EResources diff --git a/codebuild_specs/e2e_workflow.yml b/codebuild_specs/e2e_workflow.yml new file mode 100644 index 00000000000..25dfe25c6ff --- /dev/null +++ b/codebuild_specs/e2e_workflow.yml @@ -0,0 +1,74 @@ +--- +version: 0.2 +batch: + fast-fail: false + build-graph: + - identifier: prepare_build + buildspec: codebuild_specs/prepare_build.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + - identifier: cleanup_e2e_resources + buildspec: codebuild_specs/cleanup_e2e_resources.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: mock_e2e_tests + buildspec: codebuild_specs/mock_e2e_tests.yml + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: test + buildspec: codebuild_specs/test.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: lint + buildspec: codebuild_specs/lint.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: validate_cdk_version + buildspec: codebuild_specs/validate_cdk_version.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_api_extract + buildspec: codebuild_specs/verify_api_extract.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_yarn_lock + buildspec: codebuild_specs/verify_yarn_lock.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build diff --git a/codebuild_specs/lint.yml b/codebuild_specs/lint.yml new file mode 100644 index 00000000000..7363c6c10d0 --- /dev/null +++ b/codebuild_specs/lint.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _lint diff --git a/codebuild_specs/mock_e2e_tests.yml b/codebuild_specs/mock_e2e_tests.yml new file mode 100644 index 00000000000..15573725d6a --- /dev/null +++ b/codebuild_specs/mock_e2e_tests.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _mockE2ETests diff --git a/codebuild_specs/pr_workflow.yml b/codebuild_specs/pr_workflow.yml new file mode 100644 index 00000000000..13400384d92 --- /dev/null +++ b/codebuild_specs/pr_workflow.yml @@ -0,0 +1,65 @@ +--- +version: 0.2 +batch: + fast-fail: false + build-graph: + - identifier: prepare_build + buildspec: codebuild_specs/prepare_build.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + - identifier: mock_e2e_tests + buildspec: codebuild_specs/mock_e2e_tests.yml + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: test + buildspec: codebuild_specs/test.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: lint + buildspec: codebuild_specs/lint.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: validate_cdk_version + buildspec: codebuild_specs/validate_cdk_version.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_api_extract + buildspec: codebuild_specs/verify_api_extract.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build + - identifier: verify_yarn_lock + buildspec: codebuild_specs/verify_yarn_lock.yml + debug-session: true + env: + compute-type: BUILD_GENERAL1_LARGE + variables: + IS_AMPLIFY_CI: true + depend-on: + - prepare_build diff --git a/codebuild_specs/prepare_build.yml b/codebuild_specs/prepare_build.yml new file mode 100644 index 00000000000..273b055f828 --- /dev/null +++ b/codebuild_specs/prepare_build.yml @@ -0,0 +1,11 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _buildLinux + +artifacts: + files: + - 'shared-scripts.sh' diff --git a/codebuild_specs/test.yml b/codebuild_specs/test.yml new file mode 100644 index 00000000000..ed813463ab0 --- /dev/null +++ b/codebuild_specs/test.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _testLinux diff --git a/codebuild_specs/validate_cdk_version.yml b/codebuild_specs/validate_cdk_version.yml new file mode 100644 index 00000000000..f1bf130dbc6 --- /dev/null +++ b/codebuild_specs/validate_cdk_version.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _validateCDKVersion diff --git a/codebuild_specs/verify_api_extract.yml b/codebuild_specs/verify_api_extract.yml new file mode 100644 index 00000000000..ac360de6cfd --- /dev/null +++ b/codebuild_specs/verify_api_extract.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _verifyAPIExtract diff --git a/codebuild_specs/verify_yarn_lock.yml b/codebuild_specs/verify_yarn_lock.yml new file mode 100644 index 00000000000..9fba2102f79 --- /dev/null +++ b/codebuild_specs/verify_yarn_lock.yml @@ -0,0 +1,7 @@ +version: 0.2 +env: + shell: bash +phases: + build: + commands: + - source ./shared-scripts.sh && _verifyYarnLock diff --git a/codecov.yml b/codecov.yml index 928d582cf30..b7af5f41661 100644 --- a/codecov.yml +++ b/codecov.yml @@ -14,3 +14,4 @@ coverage: default: target: 80% if_not_found: success + diff --git a/packages/amplify-cli-core-vNext/lib/index.d.ts b/packages/amplify-cli-core-vNext/lib/index.d.ts new file mode 100644 index 00000000000..cc0254f358d --- /dev/null +++ b/packages/amplify-cli-core-vNext/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from 'amplify-cli-core'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/amplify-cli-core-vNext/lib/index.d.ts.map b/packages/amplify-cli-core-vNext/lib/index.d.ts.map new file mode 100644 index 00000000000..c55e43f7f21 --- /dev/null +++ b/packages/amplify-cli-core-vNext/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"} \ No newline at end of file diff --git a/packages/amplify-cli-core-vNext/lib/index.js b/packages/amplify-cli-core-vNext/lib/index.js new file mode 100644 index 00000000000..ba37c35f17c --- /dev/null +++ b/packages/amplify-cli-core-vNext/lib/index.js @@ -0,0 +1,18 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("amplify-cli-core"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/amplify-cli-core-vNext/lib/index.js.map b/packages/amplify-cli-core-vNext/lib/index.js.map new file mode 100644 index 00000000000..b212ac377d1 --- /dev/null +++ b/packages/amplify-cli-core-vNext/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"} \ No newline at end of file diff --git a/packages/amplify-prompts-vNext/lib/index.d.ts b/packages/amplify-prompts-vNext/lib/index.d.ts new file mode 100644 index 00000000000..4d3a46d82f7 --- /dev/null +++ b/packages/amplify-prompts-vNext/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from 'amplify-prompts'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/amplify-prompts-vNext/lib/index.d.ts.map b/packages/amplify-prompts-vNext/lib/index.d.ts.map new file mode 100644 index 00000000000..98659b5710a --- /dev/null +++ b/packages/amplify-prompts-vNext/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"} \ No newline at end of file diff --git a/packages/amplify-prompts-vNext/lib/index.js b/packages/amplify-prompts-vNext/lib/index.js new file mode 100644 index 00000000000..2c07092c762 --- /dev/null +++ b/packages/amplify-prompts-vNext/lib/index.js @@ -0,0 +1,18 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("amplify-prompts"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/amplify-prompts-vNext/lib/index.js.map b/packages/amplify-prompts-vNext/lib/index.js.map new file mode 100644 index 00000000000..88112f77cee --- /dev/null +++ b/packages/amplify-prompts-vNext/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"} \ No newline at end of file diff --git a/shared-scripts.sh b/shared-scripts.sh new file mode 100644 index 00000000000..9c207fbe3bb --- /dev/null +++ b/shared-scripts.sh @@ -0,0 +1,182 @@ +#!/bin/bash + +# set exit on error to true +set -e +function test { + localPath="$1" + echo hi $1 +} +# We have custom caching for our CodeBuild pipelines +# which allows us to share caches with jobs in the same batch +function storeCache { + localPath="$1" + alias="$2" + s3Path="s3://$CACHE_BUCKET_NAME/$CODEBUILD_SOURCE_VERSION/$alias" + echo writing cache to $s3Path + # zip contents and upload to s3 + if ! (cd $localPath && tar cz . | aws s3 cp - $s3Path); then + echo Something went wrong storing the cache. + fi + echo done writing cache + cd $CODEBUILD_SRC_DIR +} +# loadCache +function loadCache { + alias="$1" + localPath="$2" + s3Path="s3://$CACHE_BUCKET_NAME/$CODEBUILD_SOURCE_VERSION/$alias" + echo loading cache from $s3Path + # create directory if it doesn't exist yet + mkdir -p $localPath + # check if cache exists in s3 + if ! aws s3 ls $s3Path > /dev/null; then + echo "Cache not found." + exit 0 + fi + # load cache and unzip it + if ! (cd $localPath && aws s3 cp $s3Path - | tar xz); then + echo "Something went wrong fetching the cache. Continuing anyway." + fi + echo done loading cache + cd $CODEBUILD_SRC_DIR +} +function _setShell { + echo Setting Shell + yarn config set script-shell $(which bash) +} +function _buildLinux { + _setShell + echo Linux Build + yarn run production-build + # copy [repo, ~/.cache, and .ssh to s3] + storeCache $CODEBUILD_SRC_DIR repo + storeCache $HOME/.cache .cache +} +function _buildWindows { + _setShell + echo Windows Build + yarn run production-build + # copy [repo, .cache, and .ssh to s3] +} +function _testLinux { + echo Run Test + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + # run tests + yarn test-ci + echo collecting coverage + yarn coverage +} +function _validateCDKVersion { + echo Validate CDK Version + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + yarn ts-node .circleci/validate_cdk_version.ts +} +function _lint { + echo Linting + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + + yarn lint-check + yarn lint-check-package-json + yarn prettier-check +} +function _verifyAPIExtract { + echo Verify API Extract + + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + + yarn verify-api-extract +} +function _verifyYarnLock { + echo Verify yarn lock + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + + yarn verify-yarn-lock +} +function _verifyVersionsMatch { + # download [repo, .cache, verdaccio-cache from s3] + echo Verify Versions Match + source .circleci/local_publish_helpers.sh + startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml" + setNpmRegistryUrlToLocal + changeNpmGlobalPath + checkPackageVersionsInLocalNpmRegistry +} +function _mockE2ETests { + # download [repo, .cache from s3] + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + + source .circleci/local_publish_helpers.sh + cd packages/amplify-util-mock/ + yarn e2e +} +function _publishToLocalRegistry { + # download [repo, .cache from s3] + echo "Publish To Local Registry" + source .circleci/local_publish_helpers.sh + startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml" + setNpmRegistryUrlToLocal + export LOCAL_PUBLISH_TO_LATEST=true + ./.circleci/publish.sh + unsetNpmRegistryUrl + + echo Generate Change Log + git reset --soft HEAD~1 + yarn ts-node scripts/unified-changelog.ts + cat UNIFIED_CHANGELOG.md + + echo Save new amplify Github tag + node scripts/echo-current-cli-version.js > .amplify-pkg-version + # copy [verdaccio-cache, changelog, pkgtag to s3] +} +function _uploadPkgBinaries { + # download [repo, pkg-binaries, from s3] + echo Consolidate binaries cache and upload + source .circleci/local_publish_helpers.sh + uploadPkgCli + # copy [repo/out to s3] +} +function _buildBinaries { + # download [repo, yarn, verdaccio from s3] + echo Start verdaccio and package CLI + source .circleci/local_publish_helpers.sh + startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml" + setNpmRegistryUrlToLocal + changeNpmGlobalPath + generatePkgCli linux + # generatePkgCli macos + # generatePkgCli win + # generatePkgCli arm + + unsetNpmRegistryUrl + # copy [repo/out to s3] +} + +function _runE2ETestsLinux { + source .circleci/local_publish_helpers.sh + source $BASH_ENV + startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml" + setNpmRegistryUrlToLocal + changeNpmGlobalPath + amplify version + cd packages/amplify-e2e-tests + retry runE2eTest +} + +function cleanupE2EResources { + loadCache repo $CODEBUILD_SRC_DIR + loadCache .cache $HOME/.cache + + cd packages/amplify-e2e-tests + yarn clean-e2e-resources +}