From d659812e32d36b5e280a79170b7a49651bfc55ff Mon Sep 17 00:00:00 2001 From: Aaron S Date: Thu, 3 Aug 2023 17:06:38 -0500 Subject: [PATCH 1/2] chore: Reintroduce circle without deploy/post-release steps --- .circleci/android-rn.sh | 53 + .circleci/config.yml | 2644 ++++++++++++++++++++++++++++++++ .circleci/duplicates-npm.sh | 17 + .circleci/retry-yarn-script.sh | 51 + 4 files changed, 2765 insertions(+) create mode 100755 .circleci/android-rn.sh create mode 100644 .circleci/config.yml create mode 100644 .circleci/duplicates-npm.sh create mode 100755 .circleci/retry-yarn-script.sh diff --git a/.circleci/android-rn.sh b/.circleci/android-rn.sh new file mode 100755 index 00000000000..4f17e354200 --- /dev/null +++ b/.circleci/android-rn.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Based on: +# https://github.com/react-native-community/react-native-circleci-orb + +case $1 in + export-env) + echo 'export PATH="$PATH:/usr/local/opt/node@10/bin:~/.yarn/bin:~/project/node_modules/.bin:~/project/example/node_modules/.bin"' >> $BASH_ENV + echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV + echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV + echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> $BASH_ENV + echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV + echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> $BASH_ENV + source $BASH_ENV + ;; + install-node) + set +e + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash + echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV + echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV + source ~/.bashrc + command -v nvm + nvm install 10 + nvm alias default 10 + ;; + sdkmanager) + yes | sdkmanager "platform-tools" "tools" >/dev/null + yes | sdkmanager "platforms;android-28" "system-images;android-28;default;x86_64" >/dev/null + yes | sdkmanager "emulator" >/dev/null + yes | sdkmanager "build-tools;28.0.3" >/dev/null + yes | sdkmanager --licenses >/dev/null + yes | sdkmanager --list + ;; + wait-for-avd) + boot="" + echo "Waiting for AVD to finish booting" + export PATH=$(dirname $(dirname $(command -v android)))/platform-tools:$PATH + until [[ "$boot" =~ "1" ]]; do + sleep 5 + boot=$(adb -e shell getprop sys.boot_completed 2>&1) + done + # extra time to let the OS settle + sleep 15 + adb shell settings put global window_animation_scale 0 + adb shell settings put global transition_animation_scale 0 + adb shell settings put global animator_duration_scale 0 + echo "Android Virtual Device is now ready." + ;; + start-emulator) + $ANDROID_HOME/emulator/emulator @TestingAVD -version + $ANDROID_HOME/emulator/emulator @TestingAVD -cores 1 -gpu auto -accel on -memory 1024 -no-audio -no-snapshot -no-boot-anim -no-window + ;; +esac \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..8370fe2e2cc --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,2644 @@ +# Javascript Node CircleCI 2.1 configuration file +# +version: 2.1 + +executors: + build-executor: + docker: + - image: cypress/browsers:node16.16.0-chrome107-ff107-edge + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_ACCESS_TOKEN + + resource_class: large + working_directory: ~/amplify-js + + unit-test-executor: + docker: + - image: cypress/browsers:node16.16.0-chrome107-ff107-edge + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_ACCESS_TOKEN + + resource_class: xlarge + working_directory: ~/amplify-js + + js-test-executor: + docker: + - image: cypress/included:12.4.1 + - image: verdaccio/verdaccio:5.20 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_ACCESS_TOKEN + resource_class: large + + # TODO: Update tests that use this image to use the updated `js-test-executor` + # After upgrading the Docker image to 12.4.1, we had to make several updates to our samples (see + # https://github.com/aws-amplify/amplify-js-samples-staging/pull/522). + # This is because our current implementation of setting network status in our E2E tests began to + # fail (i.e. this is no longer supported). We updated our samples to instead use the Reachability + # component's helper function for setting network status + # (see https://github.com/aws-amplify/amplify-js/blob/main/packages/core/src/Util/Reachability.ts#L42-L54). + # However, several JS tests were still failing after attempting to remediate. An item has been + # added to the JS backlog for follow-up. + js-test-executor-prev: + docker: + - image: cypress/included:8.7.0 + - image: verdaccio/verdaccio:5.20 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_ACCESS_TOKEN + resource_class: large + + macos-executor: + macos: + xcode: 13.2.1 + resource_class: large + + webkit-test-executor: + docker: + - image: mcr.microsoft.com/playwright:v1.34.2-focal + - image: verdaccio/verdaccio:5.20 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_ACCESS_TOKEN + +test_env_vars: &test_env_vars + environment: + NPM_REGISTRY: http://0.0.0.0:4873/ + NPM_USER: circleci + NPM_PASS: circleci + NPM_EMAIL: circleci@amplify.js + +commands: + publish_to_verdaccio: + steps: + - run: + name: 'Set registry to Verdaccio and verify' + # If the registry isn't set correctly, fail the job + command: | + yarn config set registry $NPM_REGISTRY + npm set registry $NPM_REGISTRY + CURRENT_REGISTRY=$(yarn config get registry) + if [ "$CURRENT_REGISTRY" = "$NPM_REGISTRY" ]; then + exit 0 + fi + exit 1 + - run: + # npm-cli-login allows us to log in to verdaccio in a noninteractive way + # logs in with NPM_USER, NPM_PASS, and NPM_EMAIL env vars + name: 'Install and run npm-cli-login' + command: | + npm i -g npm-cli-adduser + npm-cli-adduser + sleep 1 + - run: + name: 'Publish to Verdaccio' + command: | + cd ~/amplify-js + git config --global user.email $NPM_EMAIL + git config --global user.name $NPM_USER + git status + git --no-pager diff + ~/amplify-js/.circleci/retry-yarn-script.sh -s publish:verdaccio -n 5 -r true + + prepare_test_env: + steps: + - attach_workspace: + at: /root + - restore_cache: + key: amplify-js-{{ .Branch }}-{{ checksum "~/amplify-js-samples-staging/yarn.lock" }} + - publish_to_verdaccio + + prepare_no_ui_test_env: + steps: + - attach_workspace: + at: /root + - restore_cache: + key: amplify-js-{{ .Branch }}-{{ checksum "~/amplify-js-samples-staging/yarn.lock" }} + + integ_test_js: + parameters: + test_name: + type: string + framework: + type: string + category: + type: string + sample_name: + type: string + spec: + # optional - the script will use sample_name by default + type: string + default: '' + browser: + type: string + default: '' + amplifyjs_dir: + # optional - dir to amplify js workspace + type: string + default: '' + steps: + - run: + name: 'Install << parameters.test_name >> sample' + command: | + echo "Current NPM registry: " $(yarn config get registry) + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'install' -n 3 + - run: + name: 'Run cypress tests for << parameters.test_name >> sample on dev' + command: | + cd ~/amplify-js-samples-staging + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> dev << parameters.amplifyjs_dir >>' -n 3 + - run: + name: 'Run cypress tests for << parameters.test_name >> sample on prod' + command: | + cd ~/amplify-js-samples-staging + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test << parameters.framework >> << parameters.category >> << parameters.sample_name >> << parameters.spec >> << parameters.browser >> prod << parameters.amplifyjs_dir >>' -n 3 + - store_artifacts: + path: ~/amplify-js-samples-staging/cypress/videos + - store_artifacts: + path: ~/amplify-js-samples-staging/cypress/screenshots + + integ_test_node_js: + parameters: + test_name: + type: string + category: + type: string + sample_name: + type: string + steps: + - run: + name: 'Install << parameters.test_name >> sample' + command: | + echo "Current NPM registry: " $(yarn config get registry) + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'install' -n 3 + - run: + name: 'Run Node tests for << parameters.test_name >> sample' + command: | + cd ~/amplify-js-samples-staging + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'ci:test node << parameters.category >> << parameters.sample_name >> dev' -n 3 + + integ_test_cypress_no_ui: + parameters: + test_name: + type: string + category: + type: string + spec: + type: string + steps: + - run: + name: 'Change directory into build and run link' + command: | + cd ~/amplify-js/ + yarn link-all + - run: + name: 'Link packages into samples staging root' + command: | + yarn link amazon-cognito-identity-js @aws-amplify/core @aws-amplify/cache @aws-amplify/auth + - run: + name: 'Run cypress test << parameters.spec >>' + command: | + cd ~/amplify-js-samples-staging + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'cypress run --headless --spec ./cypress/integration/auth/<< parameters.spec >>.spec.js --config baseUrl=https://aws.amazon.com/' -n 3 + - store_artifacts: + path: ~/amplify-js-samples-staging/cypress/videos + - store_artifacts: + path: ~/amplify-js-samples-staging/cypress/screenshots + + install_verdaccio: + steps: + - run: + name: Install Verdaccio + command: npm i -g verdaccio + - run: + name: Run Verdaccio + background: true + command: | + cd ~ + verdaccio + + integ_test_rn_ios: + steps: + - attach_workspace: + at: ~/ + - install_verdaccio + - publish_to_verdaccio + - run: + name: Yarn Install + command: | + echo "Current NPM registry: " $(yarn config get registry) + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'install --frozen-lockfile --non-interactive' -n 3 + - run: + name: Install CocoaPods + command: | + cd ios + pod install + - run: + background: true + command: xcrun simctl boot "iPhone 11" || true + name: Start iOS simulator (background) + - run: + background: true + command: yarn start + name: Start Metro Packager (background) + - run: + name: Configure Detox + environment: + HOMEBREW_NO_AUTO_UPDATE: '1' + command: | + brew tap wix/brew + brew install applesimutils + yarn global add detox-cli + - run: + name: Detox Build + command: detox build -c ios.sim.debug + - run: + environment: + JEST_JUNIT_OUTPUT_DIR: 'reports/junit' + JEST_JUNIT_OUTPUT_NAME: 'detox-test-results.xml' + name: Detox Test + command: | + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'detox test -c ios.sim.debug -u' -n 3 + - store_test_results: + path: reports/junit + - store_artifacts: + path: reports/junit + + integ_test_rn_android: + steps: + - attach_workspace: + at: ~/ + - install_verdaccio + - publish_to_verdaccio + - run: + # https://reactnative.dev/docs/environment-setup + command: | + cd ~/amplify-js + ./.circleci/android-rn.sh export-env + name: Configure Environment Variables + - restore_cache: + key: | + brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }} + - run: + # https://reactnative.dev/docs/environment-setup + environment: + HOMEBREW_NO_AUTO_UPDATE: '1' + command: | + brew tap wix/brew >/dev/null + brew tap homebrew/cask >/dev/null + brew install android-sdk >/dev/null + yarn global add detox-cli + touch .watchmanconfig + node -v + name: Configure Detox Environment + - save_cache: + key: | + brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }} + paths: + - /usr/local/Homebrew + - ~/Library/Caches/Homebrew + - run: + name: Yarn Install + command: | + echo "Current NPM registry: " $(yarn config get registry) + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'install --frozen-lockfile --non-interactive' -n 3 + - run: + # Install Android Emulator without Android Studio + command: | + cd ~/amplify-js + ./.circleci/android-rn.sh sdkmanager + name: Install Android Emulator + shell: /bin/bash -e + - run: + # Force ssh key generation for emulators + command: | + adb start-server + adb devices + adb kill-server + ls -la ~/.android + name: ADB Start Stop + - run: + # Create Android Emulator without Android Studio + command: >- + avdmanager create avd --force --name TestingAVD + --package "system-images;android-28;default;x86_64" + --tag default --device pixel + name: Create Android Emulator + - run: + background: true + command: | + cd ~/amplify-js + ./.circleci/android-rn.sh start-emulator + name: Start Android Emulator (background) + - run: + command: | + cd ~/amplify-js + ./.circleci/android-rn.sh wait-for-avd + name: Wait for AVD to be ready + no_output_timeout: 5m + - run: + background: true + command: yarn start + name: Start Metro Packager (background) + - run: + name: Detox Build + command: detox build -c android.emu.debug + - run: + environment: + JEST_JUNIT_OUTPUT_DIR: 'reports/junit' + JEST_JUNIT_OUTPUT_NAME: 'detox-test-results.xml' + name: Detox Test + command: | + ~/amplify-js/.circleci/retry-yarn-script.sh -s 'detox test -c android.emu.debug -u' -n 3 + - store_test_results: + path: reports/junit + - store_artifacts: + path: reports/junit + +jobs: + build: + executor: build-executor + steps: + - checkout + - run: + name: yarn install --non-interactive + # temporarily rename .yarnrc before installing so that we can generate a yarn.lock artifact + command: | + mv .yarnrc ._yarnrc + yarn + - run: yarn bootstrap + - run: yarn build + # storing yarn.lock as an artifact, so that we can quickly get a dependency diff + # with the last working build in the event that some upstream deps break the build in the future + - store_artifacts: + path: yarn.lock + - run: + name: delete lockfile after persisting + command: | + mv ._yarnrc .yarnrc + rm yarn.lock + - save_cache: + key: amplify-ssh-deps-{{ .Branch }} + paths: + - ~/.ssh + - persist_to_workspace: + root: /root + paths: + - amplify-js + + unit_test: + executor: unit-test-executor + steps: + - attach_workspace: + at: /root + - run: + name: 'Run Amplify JS unit tests' + command: | + yarn test + yarn coverage + + bundle_test: + executor: unit-test-executor + steps: + - attach_workspace: + at: /root + - run: + name: 'Run Amplify JS bundle size checks' + command: yarn test:size + + integ_setup: + executor: build-executor + working_directory: ~/ + steps: + - run: + name: 'Clone Amplify JS Samples repo, install cypress, install react samples authenticator and link amplify packages' + command: | + mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config + echo $SSH_HOST_PUBLIC_KEY >> ~/.ssh/known_hosts + git clone $AMPLIFY_JS_SAMPLES_STAGING_URL + cd amplify-js-samples-staging + branchExists=true + git ls-remote --heads origin <> | grep <> >/dev/null || branchExists=false + if [ "$branchExists" = true ]; then git checkout <>; fi + yarn + - save_cache: + key: amplify-js-{{ .Branch }}-{{ checksum "amplify-js-samples-staging/yarn.lock" }} + paths: + - ~/.cache ## cache both yarn and Cypress + - persist_to_workspace: + root: /root + paths: + - amplify-js-samples-staging + + integ_react_auth_1: #break react auth test to 2 sections to save time + parameters: + browser: + type: string + # TODO: see `js-test-executor` TODO above + executor: js-test-executor-prev + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Authenticator' + framework: react + category: auth + sample_name: amplify-authenticator + spec: new-ui-authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Guest to Authenticated User"' + framework: react + category: auth + sample_name: guest-to-auth-user + spec: guest-to-auth-user + browser: << parameters.browser >> + - integ_test_js: + test_name: 'React Typescript Authenticator' + framework: react + category: auth + sample_name: typescript-amplify-authenticator + spec: new-ui-authenticator + browser: << parameters.browser >> + integ_react_auth_2: + parameters: + browser: + type: string + # TODO: see `js-test-executor` TODO above + executor: js-test-executor-prev + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Credentials Different Region' + framework: react + category: auth + sample_name: credentials-auth + spec: credentials-auth + browser: << parameters.browser >> + - integ_test_js: + test_name: 'React Custom Authenticator' + framework: react + category: auth + sample_name: amplify-authenticator + spec: new-ui-custom-authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'React Custom Authenticator' + framework: react + category: auth + sample_name: with-authenticator + spec: new-ui-authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Sign In after Sign Up' + framework: react + category: auth + sample_name: auto-signin-after-signup + spec: auto-signin-after-signup + browser: << parameters.browser >> + integ_angular_auth: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Angular Authenticator' + framework: angular + category: auth + sample_name: amplify-authenticator + spec: ui-amplify-authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Angular Custom Authenticator' + framework: angular + category: auth + sample_name: amplify-authenticator + spec: custom-authenticator + browser: << parameters.browser >> + integ_javascript_auth: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'JavaScript Auth CDN' + framework: javascript + category: auth + sample_name: auth-cdn + spec: auth-cdn + browser: << parameters.browser >> + amplifyjs_dir: ~/amplify-js + integ_vue_auth: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Legacy Vue Authenticator' + framework: vue + category: auth + sample_name: amplify-authenticator-legacy + spec: authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Vue 3 Authenticator' + framework: vue + category: auth + sample_name: authenticator-vue3 + spec: new-ui-authenticator + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Vue Custom Authenticator' + framework: vue + category: auth + sample_name: amplify-authenticator + spec: custom-authenticator + browser: << parameters.browser >> + integ_next_auth: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Authenticator and SSR page' + framework: next + category: auth + sample_name: auth-ssr + spec: auth-ssr + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Authenticator and RSC page' + framework: next + category: auth + sample_name: auth-rsc + spec: auth-rsc + browser: << parameters.browser >> + - integ_test_js: + test_name: 'NextJS Auth Custom Implementation with SSR' + framework: next + category: auth + sample_name: custom-auth-ssr + spec: authenticator + browser: << parameters.browser >> + + integ_react_predictions: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/predictions/multi-user-translation + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Predictions' + framework: react + category: predictions + sample_name: multi-user-translation + spec: multiuser-translation + browser: << parameters.browser >> + + integ_react_interactions: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/interactions/chatbot-component + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Interactions' + framework: react + category: interactions + sample_name: chatbot-component + spec: chatbot-component + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Chatbot V1' + framework: react + category: interactions + sample_name: lex-test-component + spec: chatbot-v1 + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Chatbot V2' + framework: react + category: interactions + sample_name: lex-test-component + spec: chatbot-v2 + browser: << parameters.browser >> + + integ_vue_interactions: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/vue/interactions/chatbot-component + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Vue 2 Interactions' + framework: vue + category: interactions + sample_name: chatbot-component + spec: chatbot-component + browser: << parameters.browser >> + - integ_test_js: + test_name: 'Vue 3 Interactions' + framework: vue + category: interactions + sample_name: chatbot-component-vue3 + spec: chatbot-component + browser: << parameters.browser >> + integ_angular_interactions: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/angular/interactions/chatbot-component + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Angular Interactions' + framework: angular + category: interactions + sample_name: chatbot-component + spec: chatbot-component + browser: << parameters.browser >> + + integ_react_datastore: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/many-to-many + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore' + framework: react + category: datastore + sample_name: many-to-many + spec: many-to-many + browser: << parameters.browser >> + + integ_react_datastore_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/many-to-many-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore CLI v2' + framework: react + category: datastore + sample_name: v2/many-to-many-v2 + spec: many-to-many + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_one_rule: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/multi-auth + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - One Rule' + framework: react + category: datastore + sample_name: multi-auth + spec: multi-auth-one-rule + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_one_rule_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/multi-auth-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - One Rule CLI v2' + framework: react + category: datastore + sample_name: v2/multi-auth-v2 + spec: multi-auth-one-rule + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_two_rules: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/multi-auth + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - Two Rules' + framework: react + category: datastore + sample_name: multi-auth + spec: multi-auth-two-rules + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_two_rules_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/multi-auth-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - Two Rules CLI v2' + framework: react + category: datastore + sample_name: v2/multi-auth-v2 + spec: multi-auth-two-rules + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_three_plus_rules: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/multi-auth + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - Three Plus Rules' + framework: react + category: datastore + sample_name: multi-auth + spec: multi-auth-three-plus-rules + browser: << parameters.browser >> + + integ_react_datastore_multi_auth_three_plus_rules_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/multi-auth-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React DataStore Multi-Auth - Three Plus Rules CLI v2' + framework: react + category: datastore + sample_name: v2/multi-auth-v2 + spec: multi-auth-three-plus-rules + browser: << parameters.browser >> + + integ_react_datastore_subs_disabled: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/subs-disabled + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Subs Disabled' + framework: react + category: datastore + sample_name: subs-disabled + spec: subs-disabled + browser: << parameters.browser >> + + integ_react_datastore_subs_disabled_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/subs-disabled-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Subs Disabled CLI v2' + framework: react + category: datastore + sample_name: v2/subs-disabled-v2 + spec: subs-disabled + browser: << parameters.browser >> + + integ_react_datastore_consecutive_saves: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/consecutive-saves + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Subs Disabled' + framework: react + category: datastore + sample_name: consecutive-saves + spec: consecutive-saves + browser: << parameters.browser >> + + integ_react_datastore_consecutive_saves_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/consecutive-saves-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Subs Disabled CLI v2' + framework: react + category: datastore + sample_name: v2/consecutive-saves-v2 + spec: consecutive-saves + browser: << parameters.browser >> + + integ_react_datastore_observe_query: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/observe-query + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Observe Query' + framework: react + category: datastore + sample_name: observe-query + spec: observe-query + browser: << parameters.browser >> + + integ_react_datastore_observe_query_v2: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/observe-query-v2 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Observe Query CLI v2' + framework: react + category: datastore + sample_name: v2/observe-query-v2 + spec: observe-query + browser: << parameters.browser >> + + integ_react_datastore_schema_drift: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/schema-drift + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Schema Drift' + framework: react + category: datastore + sample_name: schema-drift + spec: schema-drift + browser: << parameters.browser >> + + integ_react_storage: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/storage/storageApp + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Storage' + framework: react + category: storage + sample_name: storageApp + spec: storage + browser: << parameters.browser >> + integ_react_storage_multipart_progress: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/storage/multi-part-upload-with-progress + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Storage Multi-Part Upload with Progress' + framework: react + category: storage + sample_name: multi-part-upload-with-progress + spec: multi-part-upload-with-progress + browser: << parameters.browser >> + integ_react_storage_copy: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/storage/multi-part-copy-with-progress + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React Storage Copy' + framework: react + category: storage + sample_name: multi-part-copy-with-progress + spec: multi-part-copy-with-progress + browser: << parameters.browser >> + integ_react_graphql_api: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/api/graphql + steps: + - prepare_test_env + - integ_test_js: + test_name: 'React GraphQL API' + framework: react + category: api + sample_name: graphql + spec: graphql + browser: << parameters.browser >> + integ_react_amazon_cognito_identity_js_cookie_storage: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/auth/amazon-cognito-identity-js-cookie-storage + steps: + - prepare_test_env + - integ_test_js: + test_name: 'amazon-cognito-identity-js-cookie-storage' + framework: react + category: auth + sample_name: amazon-cognito-identity-js-cookie-storage + spec: amazon-cognito-identity-js-cookie-storage + browser: << parameters.browser >> + integ_react_amazon_cognito_identity_js: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/auth/amazon-cognito-identity-js + steps: + - prepare_test_env + - integ_test_js: + test_name: 'amazon-cognito-identity-js' + framework: react + category: auth + sample_name: amazon-cognito-identity-js + spec: amazon-cognito-identity-js + browser: << parameters.browser >> + integ_node_amazon_cognito_identity_js: + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/node/auth/amazon-cognito-identity-js + steps: + - prepare_test_env + - integ_test_node_js: + test_name: 'amazon-cognito-identity-js' + category: auth + sample_name: amazon-cognito-identity-js + integ_react_device_tracking: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/auth/device-tracking + steps: + - prepare_test_env + - integ_test_js: + test_name: 'cognito-device-tracking' + framework: react + category: auth + sample_name: device-tracking + spec: device-tracking + browser: << parameters.browser >> + + integ_react_delete_user: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/auth/delete_user + steps: + - prepare_test_env + - integ_test_js: + test_name: 'delete-user' + framework: react + category: auth + sample_name: delete-user + spec: delete-user + browser: << parameters.browser >> + integ_rn_ios_storage: + executor: macos-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react-native/storage/StorageApp + steps: + - integ_test_rn_ios + + integ_rn_ios_storage_multipart_progress: + executor: macos-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react-native/storage/MultiPartUploadWithProgress + steps: + - integ_test_rn_ios + + integ_rn_ios_push_notifications: + executor: macos-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react-native/push-notifications/PushNotificationApp + steps: + - integ_test_rn_ios + + # integ_rn_android_storage: + # executor: macos-executor + # <<: *test_env_vars + # working_directory: ~/amplify-js-samples-staging/samples/react-native/storage/StorageApp + # steps: + # - integ_test_rn_android + + # integ_rn_android_storage_multipart_progress: + # executor: macos-executor + # <<: *test_env_vars + # working_directory: ~/amplify-js-samples-staging/samples/react-native/storage/MultiPartUploadWithProgress + # steps: + # - integ_test_rn_android + + integ_rn_ios_datastore_sqlite_adapter: + executor: macos-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react-native/datastore/SQLiteAdapter + steps: + - integ_test_rn_ios + + integ_rn_ios_device_tracking: + executor: macos-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react-native/auth/deviceTracking + steps: + - integ_test_rn_ios + + integ_datastore_auth: + parameters: + scenario: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore Auth - Chrome' + framework: react + category: datastore + sample_name: << parameters.scenario >> + spec: << parameters.scenario >> + browser: chrome + - integ_test_js: + test_name: 'DataStore Auth - Firefox' + framework: react + category: datastore + sample_name: << parameters.scenario >> + spec: << parameters.scenario >> + browser: firefox + + integ_datastore_auth_v2: + parameters: + scenario: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore Auth CLI v2 - Chrome' + framework: react + category: datastore + sample_name: v2/<< parameters.scenario >>-v2 + spec: << parameters.scenario >> + browser: chrome + - integ_test_js: + test_name: 'DataStore Auth CLI v2 - Firefox' + framework: react + category: datastore + sample_name: v2/<< parameters.scenario >>-v2 + spec: << parameters.scenario >> + browser: firefox + # integ_duplicate_packages: + # parameters: + # browser: + # type: string + # executor: js-test-executor + # <<: *test_env_vars + # working_directory: ~/amplify-js-samples-staging/samples/react/version-conflict/duplicate-packages + # steps: + # - prepare_test_env + # - integ_test_js: + # test_name: 'Duplicate Package Errors' + # framework: react + # category: version-conflict + # sample_name: duplicate-packages + # spec: duplicate-packages + # browser: << parameters.browser >> + integ_auth_test_cypress_no_ui: + working_directory: ~/amplify-js-samples-staging/ + executor: js-test-executor + steps: + - prepare_no_ui_test_env + - integ_test_cypress_no_ui: + test_name: 'Token revocation' + category: 'auth' + spec: 'token-revocation' + integ_javascript_geo: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Display Map' + framework: javascript + category: geo + sample_name: display-map-static + spec: display-map-static + browser: << parameters.browser >> + amplifyjs_dir: ~/amplify-js + - integ_test_js: + test_name: 'Search Outside Map' + framework: javascript + category: geo + sample_name: search-outside-map-static + spec: search-outside-map-static + browser: << parameters.browser >> + amplifyjs_dir: ~/amplify-js + integ_react_geo: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Display Map' + framework: react + category: geo + sample_name: display-map + spec: display-map + # Temp fix: + browser: chrome + - integ_test_js: + test_name: 'Search Outside Map' + framework: react + category: geo + sample_name: search-outside-map + spec: search-outside-map + # Temp fix: + browser: chrome + + integ_next_datastore_owner_auth: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/next/datastore/owner-based-default + steps: + - prepare_test_env + - integ_test_js: + test_name: 'next owner auth' + framework: next + category: datastore + sample_name: owner-based-default + spec: next-owner-based-default + browser: << parameters.browser >> + + integ_react_datastore_custom_pk_unconnected_models: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/custom-pk-unconnected-models + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Custom Primary Key (Connected Models)' + framework: react + category: datastore + sample_name: v2/custom-pk-unconnected-models + spec: custom-pk-unconnected-models + browser: << parameters.browser >> + + integ_react_datastore_custom_pk_unconnected_models_webkit: + executor: webkit-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/custom-pk-unconnected-models + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Custom Primary Key (Connected Models)' + framework: react + category: datastore + sample_name: v2/custom-pk-unconnected-models + spec: custom-pk-unconnected-models + browser: webkit + + integ_react_datastore_custom_pk_has_one: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/custom-pk-has-one + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Custom Primary Key (Has One)' + framework: react + category: datastore + sample_name: v2/custom-pk-has-one + spec: custom-pk-has-one + browser: << parameters.browser >> + + integ_react_datastore_custom_pk_has_many_many_to_many: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/custom-pk-has-many-many-to-many + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Custom Primary Key (Has Many / Many to Many)' + framework: react + category: datastore + sample_name: v2/custom-pk-has-many-many-to-many + spec: custom-pk-has-many-many-to-many + browser: << parameters.browser >> + + integ_react_datastore_background_process_manager: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/background-process-manager + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Background Process Manager' + framework: react + category: datastore + sample_name: v2/background-process-manager + spec: background-process-manager + browser: << parameters.browser >> + + integ_react_datastore_background_process_manager_webkit: + executor: webkit-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/background-process-manager + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Background Process Manager' + framework: react + category: datastore + sample_name: v2/background-process-manager + spec: background-process-manager + browser: webkit + + integ_react_datastore_related_models: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/related-models + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Related Models' + framework: react + category: datastore + sample_name: related-models + spec: related-models + browser: << parameters.browser >> + + integ_react_iot_reconnect: + # TODO: see `js-test-executor` TODO above + executor: js-test-executor-prev + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/pubsub/reconnection-iot + steps: + - prepare_test_env + - integ_test_js: + test_name: 'PubSub - Reconnection for IoT' + framework: react + category: pubsub + sample_name: reconnection-iot + spec: reconnection + # Firefox doesn't support network state management in cypress + browser: chrome + + integ_react_api_reconnect: + # TODO: see `js-test-executor` TODO above + executor: js-test-executor-prev + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/pubsub/reconnection-api + steps: + - prepare_test_env + - integ_test_js: + test_name: 'PubSub - Reconnection for API' + framework: react + category: pubsub + sample_name: reconnection-api + spec: reconnection + # Firefox doesn't support network state management in cypress + browser: chrome + + integ_react_datastore_selective_sync: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/selective-sync-v5 + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Selective Sync' + framework: react + category: datastore + sample_name: selective-sync-v5 + spec: selective-sync-v5 + browser: << parameters.browser >> + + integ_react_datastore_nested_predicate: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/nested-predicate + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Nested Predicate' + framework: react + category: datastore + sample_name: nested-predicate + spec: nested-predicate + browser: << parameters.browser >> + + integ_next_datastore_13_basic: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/next/datastore/next-13-basic + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Nextjs 13 build with SWC - basic JS app' + framework: next + category: datastore + sample_name: next-13-basic + spec: nextjs-13-basic + browser: << parameters.browser >> + + integ_next_datastore_13_js: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/next/datastore/next-13-js + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Nextjs 13 build with SWC - JS app' + framework: next + category: datastore + sample_name: next-13-js + spec: nextjs-13 + browser: << parameters.browser >> + + integ_vite_datastore_basic_crud: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/vite/datastore/v2/basic-crud + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Vite + DataStore - Basic CRUD' + framework: vite + category: datastore + sample_name: v2/basic-crud + spec: vite-basic-crud + + integ_rollup_datastore_basic_crud: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/rollup/datastore/rollup-basic-crud + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Rollup + DataStore - Basic CRUD' + framework: rollup + category: datastore + sample_name: rollup-basic-crud + spec: rollup-basic-crud + + integ_vanilla_js_datastore_basic_crud: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'Vanilla JS + Webpack 4 + DataStore - Basic CRUD' + framework: javascript + category: datastore + sample_name: basic-crud + browser: << parameters.browser >> + spec: vanilla-js-basic-crud + amplifyjs_dir: ~/amplify-js + + integ_react_datastore_docs_examples: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/v2/amplify-docs-examples + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - Docs Examples' + framework: react + category: datastore + sample_name: v2/amplify-docs-examples + spec: amplify-docs-examples + browser: << parameters.browser >> + + integ_react_datastore_websocket_disruption: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/datastore/websocket-disruption + steps: + - prepare_test_env + - integ_test_js: + test_name: 'DataStore - WebSocket Disruption' + framework: react + category: datastore + sample_name: websocket-disruption + spec: websocket-disruption + browser: << parameters.browser >> + + integ_react_api_optimistic_ui: + parameters: + browser: + type: string + executor: js-test-executor + <<: *test_env_vars + working_directory: ~/amplify-js-samples-staging/samples/react/api/optimistic-ui + steps: + - prepare_test_env + - integ_test_js: + test_name: 'API (GraphQL) - Optimistic UI' + framework: react + category: api + sample_name: optimistic-ui + spec: optimistic-ui + browser: << parameters.browser >> + + deploy: + executor: macos-executor + working_directory: ~/amplify-js + steps: + - attach_workspace: + at: ~/ + - run: + name: 'Publish to Amplify Package' + command: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + echo "export PREID_HASH_SUFFIX=$(echo $CIRCLE_SHA1 | cut -c -7 | sed 's/^/\./')" >> "$BASH_ENV" + source "$BASH_ENV" + npm whoami + git config --global user.email $GITHUB_EMAIL + git config --global user.name $GITHUB_USER + git status + git --no-pager diff + yarn publish:$CIRCLE_BRANCH + + post_release: + executor: build-executor + steps: + - attach_workspace: + at: /root + - restore_cache: + keys: + - amplify-ssh-deps-{{ .Branch }} + - amplify-ssh-deps + - run: + name: 'Update roll-back infrastructure' + command: | + git config --global user.email $GITHUB_EMAIL + git config --global user.name $GITHUB_USER + git pull origin release + PUBLISH_COMMIT_HASH=$(git log -n 1 --pretty=format:"%H") + RELEASE_COMMIT_MESSAGE=$(git log -n 1 --skip 1 --pretty=oneline) + if [[ $RELEASE_COMMIT_MESSAGE = *release\(required\)* ]]; then git tag -f required-release $PUBLISH_COMMIT_HASH; fi + - run: + name: 'Update API documentation' + command: | + yarn run docs + git add ./docs/api/ + git commit -m "chore(release): update API docs [ci skip]" + - run: + name: 'Push post release changes' + command: | + git push origin release + git push -f origin required-release + git push --force-with-lease origin release:main + +# Specifies the branches that can be considered releasable. +# +# Listing a branch here has the following effects: +# - Allows the branch to be published to NPM assuming there is a corresponding `publish:` script in package.json +# - Runs the full test suite against the branch in CircleCI on pushes to that branch. If the exact branch name also exists +# in the `amplify-js-samples-staging` repo, it will be used when executing tests. Otherwise, defaults to `main`. +releasable_branches: &releasable_branches + branches: + only: + - release + - main + - next + +# List of test browsers that are always used in every E2E test. Tests that aren't expected to interact with browser APIs +# should use `minimal_browser_list` to keep test execution time low. +minimal_browser_list: &minimal_browser_list + browser: [chrome, firefox] + +# List of test browsers that are used in E2E tests where we want to also test browser APIs. For functionality that +# interacts with browser APIs (e.g. IndexedDB), use `extended_browser_list`. Includes Microsoft Edge. Note: WebKit +# is not included in this list because WebKit requires a different Docker image. Any test that uses this browser +# list should also test against WebKit. +extended_browser_list: &extended_browser_list + browser: [chrome, firefox, edge] + +datastore_auth_scenarios: &datastore_auth_scenarios + scenario: [ + owner-based-default, # TODO: Add `owner-based-operations` when tests pass + static-user-pool-groups-default, + static-user-pool-groups-operations, + owner-and-group-different-models-default, + owner-and-group-same-model-default, + owner-and-group-same-model-operations, + dynamic-user-pool-groups-default, + dynamic-user-pool-groups-owner-based-default, + private-auth-default, + private-auth-iam, + public-auth-default, + public-auth-iam, + owner-custom-claim-default, + owner-custom-field-default, + ] + +workflows: + build_test_deploy: + # Tells CircleCI to skip this workflow when the pipeline is triggered by the scheduled source, + # i.e. when the canaries workflow executes + # https://circleci.com/docs/2.0/scheduled-pipelines/#workflows-filtering + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] + jobs: + - build + - integ_setup: + filters: + <<: *releasable_branches + - unit_test: + requires: + - build + - bundle_test: + requires: + - build + - integ_react_auth_1: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_auth_2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_auth_test_cypress_no_ui: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_graphql_api: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_angular_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_vue_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_next_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_predictions: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_interactions: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_vue_interactions: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + browser: [chrome] + - integ_angular_interactions: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_javascript_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_one_rule: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_one_rule_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_two_rules: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_two_rules_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_three_plus_rules: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_multi_auth_three_plus_rules_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_subs_disabled: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_subs_disabled_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_consecutive_saves: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_consecutive_saves_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + # - integ_react_datastore_observe_query: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # matrix: + # parameters: + # <<: *minimal_browser_list + # - integ_react_datastore_observe_query_v2: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # matrix: + # parameters: + # <<: *minimal_browser_list + - integ_react_datastore_schema_drift: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_storage: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_storage_multipart_progress: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_storage_copy: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_amazon_cognito_identity_js_cookie_storage: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_amazon_cognito_identity_js: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_node_amazon_cognito_identity_js: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_device_tracking: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_delete_user: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_rn_ios_storage: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_rn_ios_storage_multipart_progress: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_rn_ios_push_notifications: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_rn_ios_device_tracking: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + # - integ_rn_android_storage: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # - integ_rn_android_storage_multipart_progress: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # - integ_rn_ios_datastore_sqlite_adapter: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + - integ_datastore_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *datastore_auth_scenarios + - integ_datastore_auth_v2: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *datastore_auth_scenarios + # - integ_duplicate_packages: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # matrix: + # parameters: + # <<: *minimal_browser_list + #- integ_javascript_geo: + # requires: + # - integ_setup + # - build + # filters: + # <<: *releasable_branches + # matrix: + # parameters: + # browser: [chrome] + - integ_react_geo: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_next_datastore_owner_auth: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_custom_pk_unconnected_models: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *extended_browser_list + - integ_react_datastore_custom_pk_unconnected_models_webkit: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_datastore_custom_pk_has_one: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_custom_pk_has_many_many_to_many: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_background_process_manager: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *extended_browser_list + - integ_react_datastore_background_process_manager_webkit: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_datastore_related_models: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_iot_reconnect: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_api_reconnect: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + - integ_react_datastore_selective_sync: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_nested_predicate: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_next_datastore_13_basic: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_next_datastore_13_js: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_vite_datastore_basic_crud: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_rollup_datastore_basic_crud: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_vanilla_js_datastore_basic_crud: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_docs_examples: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_datastore_websocket_disruption: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *minimal_browser_list + - integ_react_api_optimistic_ui: + requires: + - integ_setup + - build + filters: + <<: *releasable_branches + matrix: + parameters: + <<: *extended_browser_list + + # Scheduled smoke test workflow + # Jobs are pulled from the getting-started-smoke-test inline orb defined below + canaries: + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: [canaries, << pipeline.schedule.name >>] + jobs: + ## Web + # React + - getting-started-smoke-test/web: + name: React - latest + npx-command: create-react-app + framework: react + main-file-path: src/App.js + build-dir: build + - getting-started-smoke-test/web: + name: React - next + npx-command: create-react-app@next + framework: react + main-file-path: src/App.js + build-dir: build + # Next + - getting-started-smoke-test/web: + name: Next.js (Page Router) - latest + npx-command: create-next-app + npx-post: --use-npm --ts --tailwind --no-eslint --no-src-dir --no-app --import-alias "@/*" + framework: nextjs + main-file-path: pages/_app.tsx + dev-start: dev + build-dir: build + ssr: true + - getting-started-smoke-test/web: + name: Next.js (App Router) - latest + npx-command: create-next-app + npx-post: --use-npm --ts --tailwind --no-eslint --no-src-dir --app --import-alias "@/*" + framework: nextjs + main-file-path: app/page.tsx + dev-start: dev + build-dir: build + ssr: true + - getting-started-smoke-test/web: + name: Next.js (App Router) - next + npx-command: create-next-app@canary + npx-post: --use-npm --ts --tailwind --no-eslint --no-src-dir --app --import-alias "@/*" + framework: nextjs + main-file-path: app/page.tsx + dev-start: dev + build-dir: build + ssr: true + # Angular + - getting-started-smoke-test/web: + name: Angular - latest + npx-command: -p @angular/cli ng new --defaults true --force + framework: angular + main-file-path: src/main.ts + dev-port: 4200 + build-dir: dist + - getting-started-smoke-test/web: + name: Angular - next + npx-command: -p @angular/cli@next ng new --defaults true --force + framework: angular + main-file-path: src/main.ts + dev-port: 4200 + build-dir: dist + # Vue + - getting-started-smoke-test/web: + name: Vue - latest + npx-command: -p @vue/cli vue create --default --force --registry "https://registry.npmmirror.com" # npmmirror works better with vue create specifically in CCI + framework: vue + main-file-path: src/main.js + dev-start: serve + dev-port: 8080 + build-dir: dist + - getting-started-smoke-test/web: + name: Vue - next + npx-command: -p @vue/cli@next vue create --default --force --registry "https://registry.npmmirror.com" + framework: vue + main-file-path: src/main.js + dev-start: serve + dev-port: 8080 + build-dir: dist + ## Mobile + # RN CLI + - getting-started-smoke-test/rn-ios: + name: RN iOS - latest + framework: rn_ios + main-file-path: ./App.js + # TODO: delete next line after https://github.com/react-native-picker/picker/issues/425 is resolved + tag: 0.68.2 + - getting-started-smoke-test/rn-android: + name: RN Android - latest + framework: rn_android + main-file-path: ./App.js + # TODO: delete next line after https://github.com/react-native-picker/picker/issues/425 is resolved + tag: 0.68.2 + + # TODO: re-enable the following 2 jobs after https://github.com/react-native-picker/picker/issues/425 is resolved + # - getting-started-smoke-test/rn-ios: + # name: RN iOS - next + # framework: rn_ios + # main-file-path: ./App.js + # tag: next + # - getting-started-smoke-test/rn-android: + # name: RN Android - next + # framework: rn_android + # main-file-path: ./App.js + # tag: next + # Expo + - getting-started-smoke-test/expo: + name: Expo - latest + framework: expo_ios + main-file-path: ./App.js + - getting-started-smoke-test/expo: + name: Expo - next + framework: expo_ios + main-file-path: ./App.js + tag: next + +# Start Canary Orb +orbs: + getting-started-smoke-test: + executors: + web-executor: + docker: + - image: cimg/node:lts + resource_class: large + + android-executor: + machine: + image: android:202102-01 + resource_class: large + + common_env_vars: &common_env_vars + environment: + IMPORT_STATEMENT: import {Logger} from 'aws-amplify'; + LIBRARY_STATEMENT: Logger.LOG_LEVEL='DEBUG'; + MAX_WAIT_ON_TIMEOUT: 180000 # 3 minutes; how long we wait for the build to succeed before failing the job + + commands: + run-with-retry: + description: Run command with retry + parameters: + label: + description: Display name + type: string + pre-command: + description: This command will be executed once, but will not be retried + type: string + default: '' + command: + description: Command to run + type: string + retry-count: + description: Number of retry + type: integer + default: 3 + sleep: + description: Wait duration until next retry + type: integer + default: 5 + no_output_timeout: + description: Elapsed time the command can run without output + type: string + default: 10m + steps: + - run: + name: << parameters.label >> + command: | + retry() { + MAX_RETRY=<< parameters.retry-count >> + n=0 + until [ $n -ge $MAX_RETRY ] + do + bash -c "$@" && exit 0 + n=$[$n+1] + echo "retry $n of $MAX_RETRY" + sleep << parameters.sleep >> + done + if [ $n -ge $MAX_RETRY ]; then + echo "failed: ${@}" >&2 + exit 1 + fi + } + eval << parameters.pre-command >> + retry "<< parameters.command >>" + no_output_timeout: << parameters.no_output_timeout >> + + jobs: + web: + parameters: + framework: + type: string + npx-command: + type: string + npx-post: + type: string + default: '' + main-file-path: + type: string + dev-start: + type: string + default: start + dev-port: + type: integer + default: 3000 + build-dir: + type: string + ssr: + type: boolean + default: false + executor: web-executor + <<: *common_env_vars + working_directory: ~/project/amplify-getting-started-<< parameters.framework >> + steps: + - run-with-retry: + label: Scaffold App + pre-command: cd ../ + command: npx -y << parameters.npx-command >> amplify-getting-started-<< parameters.framework >> << parameters.npx-post >> + no_output_timeout: 2m + - run-with-retry: + label: Install AmplifyJS + command: | + npm i -S aws-amplify + npm i -g wait-on serve + ~/amplify-js/.circleci/duplicates-npm.sh + - run: + name: Call Amplify library in code + command: | + echo "$IMPORT_STATEMENT" | cat - << parameters.main-file-path >> | tee << parameters.main-file-path >> + echo "$LIBRARY_STATEMENT" >> << parameters.main-file-path >> + - run-with-retry: + label: Run in Dev Mode + command: npm run << parameters.dev-start >> & wait-on http://localhost:<< parameters.dev-port >> -t $MAX_WAIT_ON_TIMEOUT + - unless: + condition: << parameters.ssr >> + steps: + - run-with-retry: + label: Run in Prod Mode + command: npm run build && (serve -n -s << parameters.build-dir >> -l 4000 & wait-on http://localhost:4000 -t $MAX_WAIT_ON_TIMEOUT) + - when: + condition: << parameters.ssr >> + steps: + - run-with-retry: + label: Run in Prod Mode + command: npm run build && (npm start & wait-on http://localhost:3000 -t $MAX_WAIT_ON_TIMEOUT) + + rn-ios: + parameters: + framework: + type: string + main-file-path: + type: string + tag: + type: string + default: latest + xcode-version: + type: string + default: 13.4.0 + ios-device: + type: string + default: iPhone 13 + macos: + xcode: << parameters.xcode-version >> + resource_class: large + working_directory: ~/amplify_getting_started_<< parameters.framework >> + steps: + - run-with-retry: + label: Scaffold App + pre-command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> + command: npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> --version << parameters.tag >> + no_output_timeout: 10m + - run-with-retry: + label: Install Amplify dependencies + command: npm install aws-amplify aws-amplify-react-native amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage @react-native-picker/picker + - run-with-retry: + label: Pod Install + command: npx pod-install + - run: + name: Call Amplify library in code + command: | + echo "$IMPORT_STATEMENT" | cat - << parameters.main-file-path >> | tee << parameters.main-file-path >> + echo "$LIBRARY_STATEMENT" >> << parameters.main-file-path >> + - run: + background: true + name: Start iOS simulator (background) + command: xcrun simctl boot "<< parameters.ios-device >>" || true + - run-with-retry: + label: Start App + command: npm run ios + + rn-android: + parameters: + framework: + type: string + main-file-path: + type: string + tag: + type: string + default: latest + executor: android-executor + working_directory: ~/amplify_getting_started_<< parameters.framework >> + steps: + - run: + name: Create avd + command: | + SYSTEM_IMAGES="system-images;android-29;default;x86" + sdkmanager "$SYSTEM_IMAGES" + echo "no" | avdmanager --verbose create avd -n test -k "$SYSTEM_IMAGES" + - run: + name: Launch emulator + command: | + emulator -avd test -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim + background: true + - run: + name: Generate cache key + command: | + find . -name 'build.gradle' | sort | xargs cat | + shasum | awk '{print $1}' > /tmp/gradle_cache_seed + - run-with-retry: + label: Scaffold App + pre-command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> + command: npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> --version << parameters.tag >> + no_output_timeout: 10m + - run-with-retry: + label: Install Amplify dependencies + command: npm install aws-amplify aws-amplify-react-native amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage @react-native-picker/picker + - run: + name: Call Amplify library in code + command: | + echo "$IMPORT_STATEMENT" | cat - << parameters.main-file-path >> | tee << parameters.main-file-path >> + echo "$LIBRARY_STATEMENT" >> << parameters.main-file-path >> + - run: + name: Wait for emulator to start + command: | + circle-android wait-for-boot + - run: + name: Disable emulator animations + command: | + adb shell settings put global window_animation_scale 0.0 + adb shell settings put global transition_animation_scale 0.0 + adb shell settings put global animator_duration_scale 0.0 + - run-with-retry: + label: Start App + command: npm run android + + expo: + parameters: + framework: + type: string + main-file-path: + type: string + tag: + type: string + default: latest + executor: web-executor + <<: *common_env_vars + working_directory: ~/amplify_getting_started_<< parameters.framework >> + steps: + - run-with-retry: + label: Install Expo + command: npm i -g expo-cli@<< parameters.tag >> wait-on + - run-with-retry: + label: Scaffold App + command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> && expo-cli init amplify_getting_started_<< parameters.framework >> --yes + no_output_timeout: 5m + - run-with-retry: + label: Install Amplify dependencies + command: yarn add aws-amplify aws-amplify-react-native @react-native-community/netinfo @react-native-async-storage/async-storage @react-native-picker/picker + - run-with-retry: + label: Call Amplify library in code + command: | + echo "$IMPORT_STATEMENT" | cat - << parameters.main-file-path >> | tee << parameters.main-file-path >> + echo "$LIBRARY_STATEMENT" >> << parameters.main-file-path >> + - run-with-retry: + label: Start App + command: yarn web & wait-on http://localhost:19006 -t $MAX_WAIT_ON_TIMEOUT +# End Canary Orb diff --git a/.circleci/duplicates-npm.sh b/.circleci/duplicates-npm.sh new file mode 100644 index 00000000000..fb54ab6f690 --- /dev/null +++ b/.circleci/duplicates-npm.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# This script detects duplicated Amplify dependencies in the dependency graph (with NPM) +duplicatedDependencies=$( + npm ls -all 2>/dev/null | \ + grep -o -e '@\?aws-amplify[^ ]*' | \ + sort | uniq | \ + sed -E 's/^(@?[^@]+).*$/\1/g' | \ + uniq -d | sort +) + +if [ ! "$duplicatedDependencies" ]; then + echo "No duplicated Amplify dependencies detected." +else + echo "Duplicated Amplify dependencies detected: $duplicatedDependencies" + false +fi diff --git a/.circleci/retry-yarn-script.sh b/.circleci/retry-yarn-script.sh new file mode 100755 index 00000000000..da730245431 --- /dev/null +++ b/.circleci/retry-yarn-script.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# flags: +# -s = script name +# -n = how many times to retry +# -r (optional) = run git reset in between retries + +# usage example: +# ./retry-command.sh -s lint -n 5 +# ./retry-command.sh -s publish:verdaccio -n 3 -r true + +while getopts s:n:r: option +do + case "${option}" + in + s) SCRIPT=${OPTARG};; + n) N=${OPTARG};; + r) GIT_RESET=${OPTARG};; + esac +done + +# initialize counter +n=0 +# loop until n > first param +until [ "$n" -gt $N ] +do + # $1 is the argument passed in, e.g. publish:verdaccio + # if the publish command succeeds, `break` exits the loop + yarn $SCRIPT && break + + if [[ $GIT_RESET ]] + then + # reset git HEAD (remove the package.json changes made by lerna) + echo "Resetting git HEAD" + git reset --hard + fi + + if [ "$n" -eq $N ]; + then + echo "Returning error" + exit 1 + fi + + # increment counter + n=$((n+1)) + + # wait 5 seconds + sleep 5 + echo "Retry $n of $N" +done + From 64fa6daef6e3d777ca88177ae77c650aee8a890d Mon Sep 17 00:00:00 2001 From: Aaron S Date: Thu, 3 Aug 2023 17:10:12 -0500 Subject: [PATCH 2/2] chore: Fix yarn.lock issue --- .circleci/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8370fe2e2cc..fb21cab53ac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -364,9 +364,7 @@ jobs: - checkout - run: name: yarn install --non-interactive - # temporarily rename .yarnrc before installing so that we can generate a yarn.lock artifact command: | - mv .yarnrc ._yarnrc yarn - run: yarn bootstrap - run: yarn build @@ -374,11 +372,6 @@ jobs: # with the last working build in the event that some upstream deps break the build in the future - store_artifacts: path: yarn.lock - - run: - name: delete lockfile after persisting - command: | - mv ._yarnrc .yarnrc - rm yarn.lock - save_cache: key: amplify-ssh-deps-{{ .Branch }} paths: