Skip to content

Commit

Permalink
add retry; correct rn-android job
Browse files Browse the repository at this point in the history
  • Loading branch information
iartemiev committed Jun 8, 2022
1 parent 1b25a08 commit 0131964
Showing 1 changed file with 134 additions and 71 deletions.
205 changes: 134 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1071,25 +1071,23 @@ jobs:
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 >>
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
Expand Down Expand Up @@ -1538,17 +1536,16 @@ workflows:
<<: *releasable_branches
matrix:
parameters:
<<:
*datastore_auth_scenarios
# - integ_duplicate_packages:
# requires:
# - integ_setup
# - build
# filters:
# <<: *releasable_branches
# matrix:
# parameters:
# <<: *test_browsers
<<: *datastore_auth_scenarios
# - integ_duplicate_packages:
# requires:
# - integ_setup
# - build
# filters:
# <<: *releasable_branches
# matrix:
# parameters:
# <<: *test_browsers
- integ_react_geo:
requires:
- integ_setup
Expand Down Expand Up @@ -1622,7 +1619,7 @@ workflows:
## Web
# React
- getting-started-smoke-test/web:
name: React - latest
name: React - latest - << pipeline.schedule.name >>
npx-command: create-react-app
framework: react
main-file-path: src/App.js
Expand Down Expand Up @@ -1733,6 +1730,49 @@ orbs:
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
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
"$@" && break
n=$[$n+1]
sleep << parameters.sleep >>
done
if [ $n -ge $MAX_RETRY ]; then
echo "failed: ${@}" >&2
exit 1
fi
}
retry << parameters.command >>
no_output_timeout: << parameters.no_output_timeout >>

jobs:
web:
parameters:
Expand Down Expand Up @@ -1760,32 +1800,32 @@ orbs:
<<: *common_env_vars
working_directory: ~/project/amplify-getting-started-<< parameters.framework >>
steps:
- run:
name: Scaffold App
- run-with-retry:
label: Scaffold App
command: cd ../ && npx -y << parameters.npx-command >> amplify-getting-started-<< parameters.framework >> << parameters.npx-post >>
no_output_timeout: 2m
- run:
name: Install AmplifyJS
- run-with-retry:
label: Install AmplifyJS
command: npm i -S aws-amplify && npm i -g wait-on serve
- run:
name: Call Amplify library in code
- 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:
name: Run in Dev Mode
- 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:
name: Run in Prod Mode
- 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:
name: Run in Prod Mode
- 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:
Expand All @@ -1800,28 +1840,35 @@ orbs:
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:
name: Scaffold App
- run-with-retry:
label: 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
- 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: Pod Install
- run-with-retry:
label: Pod Install
command: npx pod-install
- run:
name: Call Amplify library in code
- 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:
name: Start App
background: true
command: xcrun simctl boot "<< parameters.ios-device >>" || true
label: Start iOS simulator (background)
- run-with-retry:
label: Start App
command: npm run ios

rn-android:
Expand All @@ -1843,23 +1890,39 @@ orbs:
sdkmanager "$SYSTEM_IMAGES"
echo "no" | avdmanager --verbose create avd -n test -k "$SYSTEM_IMAGES"
- run:
name: Scaffold App
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
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
- 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
- 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:
background: true
command: xcrun simctl boot "iPhone 13" || true
name: Start iOS simulator (background)
name: Wait for emulator to start
command: |
circle-android wait-for-boot
- run:
name: Start App
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:
Expand All @@ -1875,22 +1938,22 @@ orbs:
<<: *common_env_vars
working_directory: ~/amplify_getting_started_<< parameters.framework >>
steps:
- run:
name: Install Expo
- run-with-retry:
label: Install Expo
command: npm i -g expo-cli@<< parameters.tag >> wait-on
- run:
name: Scaffold App
- 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:
name: Install Amplify dependencies
- 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:
name: Call Amplify library in code
- 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:
name: Start App
- run-with-retry:
label: Start App
command: yarn web & wait-on http://localhost:19006 -t $MAX_WAIT_ON_TIMEOUT
# End Canary Orb

0 comments on commit 0131964

Please sign in to comment.