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..68f867f --- /dev/null +++ b/src/orbs/getting-started-smoke-test/orb.yml @@ -0,0 +1,336 @@ +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' + +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: + - image: cimg/node:lts + resource_class: large + + mac-executor: + macos: + xcode: 13.4.0 + 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 + +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-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 + - 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: 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' + 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 + 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: + 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 + + 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-flutter-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-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 + - 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/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