diff --git a/codebuild_specs/pr_workflow.yml b/codebuild_specs/pr_workflow.yml index ce453b5493..9df198d153 100644 --- a/codebuild_specs/pr_workflow.yml +++ b/codebuild_specs/pr_workflow.yml @@ -47,3 +47,9 @@ batch: compute-type: BUILD_GENERAL1_MEDIUM depend-on: - build_linux + - identifier: verify_amplify_backend_compatability + buildspec: codebuild_specs/verify_amplify_backend_compatability.yml + env: + image: aws/codebuild/amazonlinux2-x86_64-standard:5.0 + depend-on: + - build_linux diff --git a/codebuild_specs/verify_amplify_backend_compatability.yml b/codebuild_specs/verify_amplify_backend_compatability.yml new file mode 100644 index 0000000000..00761f97b7 --- /dev/null +++ b/codebuild_specs/verify_amplify_backend_compatability.yml @@ -0,0 +1,9 @@ +version: 0.2 +env: + shell: bash + variables: + NODE_OPTIONS: --max-old-space-size=8096 +phases: + build: + commands: + - source ./shared-scripts.sh && _verifyAmplifyBackendCompatability diff --git a/shared-scripts.sh b/shared-scripts.sh index 52cc61e34e..1a84c00115 100755 --- a/shared-scripts.sh +++ b/shared-scripts.sh @@ -132,6 +132,54 @@ function _lint { loadCacheFromBuildJob chmod +x codebuild_specs/scripts/lint_pr.sh && ./codebuild_specs/scripts/lint_pr.sh } +function _verifyAmplifyBackendCompatability { + echo "Verify Amplify Backend Compatability" + + # Install NVM and set Node.js version + echo "Installing NVM and setting Node.js version" + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 18.16.0 + nvm use 18.16.0 + + loadCacheFromBuildJob + + # Increase buffer size to avoid error when git operations return large response on CI + git config http.version HTTP/1.1 + git config http.postBuffer 157286400 + + git checkout -b _vab + git symbolic-ref HEAD --short + git rev-parse HEAD + + # Fetching git tags from upstream + # For forked repo only + # Can be removed when using team account + echo "fetching tags" + git fetch --tags https://github.com/aws-amplify/amplify-category-api + # Create the folder to avoid failure when no packages are published due to no change detected + rm -rf ../verdaccio-cache && mkdir ../verdaccio-cache + + git config user.email not@used.com + git config user.name "Doesnt Matter" + + source ./shared-scripts.sh && _publishLocalWorkspace + setNpmRegistryUrlToLocal + npm config get registry + + cd .. + git clone https://github.com/aws-amplify/amplify-backend.git + cd amplify-backend + npm update + git diff package-lock.json | grep -e 'graphql-api-construct' -e 'data-construct' + npm run build && npm run test + + cd $CODEBUILD_SRC_DIR + unsetNpmRegistryUrl + npm config get registry + yarn verdaccio-stop +} function _publishToLocalRegistry { echo "Publish To Local Registry" loadCacheFromBuildJob