From 5a40d34c6b8dcdc11c0d9a695e1d5b410e16db17 Mon Sep 17 00:00:00 2001 From: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com> Date: Wed, 18 May 2022 10:33:43 -0400 Subject: [PATCH 1/4] feat: add getting-started-smoke-test orb for JS --- src/orbs/getting-started-smoke-test/README.md | 9 + src/orbs/getting-started-smoke-test/orb.yml | 189 ++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 src/orbs/getting-started-smoke-test/README.md create mode 100644 src/orbs/getting-started-smoke-test/orb.yml diff --git a/src/orbs/getting-started-smoke-test/README.md b/src/orbs/getting-started-smoke-test/README.md new file mode 100644 index 0000000..82774ce --- /dev/null +++ b/src/orbs/getting-started-smoke-test/README.md @@ -0,0 +1,9 @@ +# Amplify DevOps - Getting Started Smoke Test Orb + +CircleCI orb containing jobs for testing the interoperability of the Amplify client-side libraries with each of our [supported](https://docs.amplify.aws/start/) 3rd party platforms and frameworks. + +These pipeline jobs ensure that changes to these 3rd party tools don't break compatibility with Amplify. + +## Contributor Tips + +Validate Orb config: `circleci orb validate orb.yml` diff --git a/src/orbs/getting-started-smoke-test/orb.yml b/src/orbs/getting-started-smoke-test/orb.yml new file mode 100644 index 0000000..9bd6a6f --- /dev/null +++ b/src/orbs/getting-started-smoke-test/orb.yml @@ -0,0 +1,189 @@ +version: 2.1 + +description: "This orb contains a collection of jobs for smoke testing the AWS Amplify library's Getting Started flows on all supported platforms and frameworks" + +display: + source_url: 'https://github.com/aws-amplify/amplify-ci-support/src/orbs/getting-started-smoke-test' + +executors: + web-executor: + docker: + - image: cimg/node:lts + resource_class: large + + mac-executor: + macos: + # TODO: use param for this + xcode: 13.3.1 + resource_class: large + + android-executor: + machine: + image: android:202102-01 + resource_class: large + +js_env_vars: &js_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 + +jobs: + web: + description: 'Test Getting Started Flow for 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 + <<: *js_env_vars + working_directory: ~/project/amplify-getting-started-<< parameters.framework >> + steps: + - run: + name: Scaffold App + command: cd ../ && npx -y << parameters.npx-command >> amplify-getting-started-<< parameters.framework >> << parameters.npx-post >> + no_output_timeout: 3m + - run: + name: Install AmplifyJS + command: npm i -S aws-amplify && npm i -g wait-on serve + - 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: 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: + name: 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: + name: Run in Prod Mode + command: npm run build && (npm start & wait-on http://localhost:3000 -t $MAX_WAIT_ON_TIMEOUT) + + rn-ios: + description: 'Test Getting Started Flow for React Native iOS' + parameters: + framework: + type: string + main-file-path: + type: string + tag: + type: string + default: latest + executor: mac-executor + working_directory: ~/amplify_getting_started_<< parameters.framework >> + steps: + - run: + name: Scaffold App + command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> && npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> + no_output_timeout: 10m + - run: + name: 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: 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: + name: Start App + command: npm run ios + + rn-android: + description: 'Test Getting Started Flow on React Native 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: Scaffold App + command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> && npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> + no_output_timeout: 10m + - run: + name: 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: + background: true + command: xcrun simctl boot "iPhone 13" || true + name: Start iOS simulator (background) + - run: + name: Start App + command: npm run android + + expo: + description: 'Test Getting Started Flow on Expo (Web)' + parameters: + framework: + type: string + main-file-path: + type: string + tag: + type: string + default: latest + executor: web-executor + <<: *js_env_vars + working_directory: ~/amplify_getting_started_<< parameters.framework >> + steps: + - run: + name: Install Expo + command: npm i -g expo-cli@<< parameters.tag >> wait-on + - run: + name: 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: + name: 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: + 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: Start App + command: yarn web & wait-on http://localhost:19006 -t $MAX_WAIT_ON_TIMEOUT From acf392afe30d94369985838f20579c638ec23017 Mon Sep 17 00:00:00 2001 From: yeungwah Date: Wed, 25 May 2022 22:35:09 -0400 Subject: [PATCH 2/4] add getting-started-smoke-test orb for Flutter, iOS, and android --- src/orbs/getting-started-smoke-test/orb.yml | 141 ++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/src/orbs/getting-started-smoke-test/orb.yml b/src/orbs/getting-started-smoke-test/orb.yml index 9bd6a6f..a0c0ea2 100644 --- a/src/orbs/getting-started-smoke-test/orb.yml +++ b/src/orbs/getting-started-smoke-test/orb.yml @@ -5,6 +5,13 @@ description: "This orb contains a collection of jobs for smoke testing the AWS A display: source_url: 'https://github.com/aws-amplify/amplify-ci-support/src/orbs/getting-started-smoke-test' +orbs: + macos: circleci/macos@2 + android: circleci/android@2.0.0 + flutter-orb: circleci/flutter@1.0.1 + node: circleci/node@5.0.2 + ruby: circleci/ruby@1.6.0 + executors: web-executor: docker: @@ -28,6 +35,40 @@ js_env_vars: &js_env_vars 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: + install-flutter: + description: Install Flutter and set up paths. + parameters: + flutter_branch: + description: Flutter branch or version tag. + type: string + default: stable + steps: + - run: + name: Set up Flutter + command: | + echo 'export FLUTTER_HOME=${HOME}/sdks/flutter' >> $BASH_ENV + echo 'export FLUTTER_BRANCH=<< parameters.flutter_branch >>' >> $BASH_ENV + echo 'export FLUTTER_ROOT=${FLUTTER_HOME}' >> $BASH_ENV + echo 'export PATH=${PATH}:${FLUTTER_HOME}/bin:${FLUTTER_HOME}/bin/cache/dart-sdk/bin:${HOME}/.pub-cache/bin:${FLUTTER_HOME}/.pub-cache/bin' >> $BASH_ENV + source $BASH_ENV + git clone --branch ${FLUTTER_BRANCH} https://github.com/flutter/flutter.git ${FLUTTER_HOME} + (yes || true) | flutter doctor --android-licenses && flutter doctor + flutter precache + setup-amplify-project: + description: Setup Amplify project + steps: + - run: + name: Setting up dependences + command: cd amplified_todo && flutter pub add amplify_flutter && flutter pub add amplify_datastore && flutter pub add -d integration_test + - run: + name: Update outdated dependences + command: cd amplified_todo && flutter pub upgrade --major-versions + - run: + name: Adding Amplify code + command: cp canaries/amplifyconfiguration.dart amplified_todo/lib && cp canaries/main.dart amplified_todo/lib && cp -r canaries/integration_test amplified_todo/integration_test + + jobs: web: description: 'Test Getting Started Flow for Web' @@ -187,3 +228,103 @@ jobs: - run: name: Start App command: yarn web & wait-on http://localhost:19006 -t $MAX_WAIT_ON_TIMEOUT + + flutter-android: + executor: + name: android/android-machine + resource-class: xlarge + tag: 2022.03.1 + steps: + - checkout + - install-flutter + - run: + name: Setting up project + command: flutter create amplified_todo + - run: + name: Update Android version + command: cd amplified_todo && sed -i -e "s/minSdkVersion .*/minSdkVersion 21/" ./android/app/build.gradle && cat ./android/app/build.gradle + - setup-amplify-project + - flutter-orb/install_android_gradle: + app-dir: ./amplified_todo + - android/create-avd: + avd-name: flutter + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: flutter + post-emulator-launch-assemble-command: ls -lrt + restore-gradle-cache-find-args: ./amplified_todo/android -name 'build.gradle' + - run: + name: Run Flutter Tests + command: cd amplified_todo && flutter test integration_test --no-sound-null-safety -v + + flutter-ios: + executor: mac-executor + working_directory: ~/flutter-canaries + steps: + - checkout + - macos/preboot-simulator: + device: iPhone 13 + version: "15.4" + - install-flutter + - run: + name: Setting up project + command: flutter create amplified_todo + - setup-amplify-project + - run: + name: Update ios version + command: cd amplified_todo && sed -i -e "s/# platform :ios, '9.0'/platform :ios, '13.0'/" ./ios/Podfile + - run: + name: Run Flutter Tests + command: cd amplified_todo && flutter test integration_test --no-sound-null-safety -v + + ios: + parameters: + xcode-version: + type: string + default: 13.3.0 + simulator-device: + type: string + default: iPhone 13 + simulator-os-version: + type: string + default: "15.4" + working_directory: ~/ios-canaries/example + macos: + xcode: <> + environment: + FL_OUTPUT_DIR: output + # Add steps to the job + # See: https://circleci.com/docs/2.0/configuration-reference/#steps + steps: + - checkout: + path: ~/ios-canaries + - run: ls -lst; pwd; + - node/install + - run: npm install -g @aws-amplify/cli + - run: amplify init --quickstart --frontend ios + - macos/preboot-simulator: + device: <> + version: <> + - ruby/install-deps + - run: pod install + - run: + name: Run tests + command: bundle exec fastlane scan + + android: + working_directory: ~/android-canaries/canaries/example + executor: + name: android/android-machine + resource-class: xlarge + tag: 2022.03.1 + steps: + - checkout: + path: ~/android-canaries + - android/create-avd: + avd-name: myavd + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: myavd + - android/run-tests \ No newline at end of file From 2437e2ef13ecac98e66511d219f354201fa96d73 Mon Sep 17 00:00:00 2001 From: yeungwah Date: Tue, 31 May 2022 11:12:33 -0400 Subject: [PATCH 3/4] fixed some of the paths for ios, and flutter flow --- src/orbs/getting-started-smoke-test/orb.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/orbs/getting-started-smoke-test/orb.yml b/src/orbs/getting-started-smoke-test/orb.yml index a0c0ea2..7635a2e 100644 --- a/src/orbs/getting-started-smoke-test/orb.yml +++ b/src/orbs/getting-started-smoke-test/orb.yml @@ -55,18 +55,21 @@ commands: git clone --branch ${FLUTTER_BRANCH} https://github.com/flutter/flutter.git ${FLUTTER_HOME} (yes || true) | flutter doctor --android-licenses && flutter doctor flutter precache - setup-amplify-project: + setup-amplify-flutter-project: description: Setup Amplify project steps: - run: name: Setting up dependences - command: cd amplified_todo && flutter pub add amplify_flutter && flutter pub add amplify_datastore && flutter pub add -d integration_test + command: cd amplified_todo && flutter pub add amplify_flutter && flutter pub add amplify_datastore + - run: + name: Adding integration_test package + command: 'cd amplified_todo && sed -i -e "s/dev_dependencies:/dev_dependencies:\n integration_test:\n sdk: flutter/" ./pubspec.yaml && cat ./pubspec.yaml' - run: name: Update outdated dependences command: cd amplified_todo && flutter pub upgrade --major-versions - run: name: Adding Amplify code - command: cp canaries/amplifyconfiguration.dart amplified_todo/lib && cp canaries/main.dart amplified_todo/lib && cp -r canaries/integration_test amplified_todo/integration_test + command: mv canaries/dummy_amplifyconfiguration.dart canaries/amplifyconfiguration.dart && cp canaries/amplifyconfiguration.dart amplified_todo/lib && cp canaries/main.dart amplified_todo/lib && cp -r canaries/integration_test amplified_todo/integration_test jobs: @@ -243,7 +246,7 @@ jobs: - run: name: Update Android version command: cd amplified_todo && sed -i -e "s/minSdkVersion .*/minSdkVersion 21/" ./android/app/build.gradle && cat ./android/app/build.gradle - - setup-amplify-project + - setup-amplify-flutter-project - flutter-orb/install_android_gradle: app-dir: ./amplified_todo - android/create-avd: @@ -270,7 +273,7 @@ jobs: - run: name: Setting up project command: flutter create amplified_todo - - setup-amplify-project + - setup-amplify-flutter-project - run: name: Update ios version command: cd amplified_todo && sed -i -e "s/# platform :ios, '9.0'/platform :ios, '13.0'/" ./ios/Podfile @@ -289,7 +292,7 @@ jobs: simulator-os-version: type: string default: "15.4" - working_directory: ~/ios-canaries/example + working_directory: ~/ios-canaries/canaries/example macos: xcode: <> environment: From 9cb4a1cc143db090ccd7bf6bc2604b8a46df9df5 Mon Sep 17 00:00:00 2001 From: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com> Date: Tue, 31 May 2022 14:29:26 -0400 Subject: [PATCH 4/4] feat: paramaterize xcode version for rn-ios job --- src/orbs/getting-started-smoke-test/orb.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/orbs/getting-started-smoke-test/orb.yml b/src/orbs/getting-started-smoke-test/orb.yml index 7635a2e..68f867f 100644 --- a/src/orbs/getting-started-smoke-test/orb.yml +++ b/src/orbs/getting-started-smoke-test/orb.yml @@ -20,8 +20,7 @@ executors: mac-executor: macos: - # TODO: use param for this - xcode: 13.3.1 + xcode: 13.4.0 resource_class: large android-executor: @@ -71,7 +70,6 @@ commands: name: Adding Amplify code command: mv canaries/dummy_amplifyconfiguration.dart canaries/amplifyconfiguration.dart && cp canaries/amplifyconfiguration.dart amplified_todo/lib && cp canaries/main.dart amplified_todo/lib && cp -r canaries/integration_test amplified_todo/integration_test - jobs: web: description: 'Test Getting Started Flow for Web' @@ -138,7 +136,12 @@ jobs: tag: type: string default: latest - executor: mac-executor + xcode-version: + type: string + default: 13.4.0 + macos: + xcode: << parameters.xcode-version >> + resource_class: large working_directory: ~/amplify_getting_started_<< parameters.framework >> steps: - run: @@ -268,7 +271,7 @@ jobs: - checkout - macos/preboot-simulator: device: iPhone 13 - version: "15.4" + version: '15.4' - install-flutter - run: name: Setting up project @@ -291,7 +294,7 @@ jobs: default: iPhone 13 simulator-os-version: type: string - default: "15.4" + default: '15.4' working_directory: ~/ios-canaries/canaries/example macos: xcode: <> @@ -330,4 +333,4 @@ jobs: system-image: system-images;android-29;default;x86 - android/start-emulator: avd-name: myavd - - android/run-tests \ No newline at end of file + - android/run-tests