From 0f76fba41b125d88be3f5d4c412c26922de53d20 Mon Sep 17 00:00:00 2001 From: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com> Date: Wed, 15 Jun 2022 16:40:20 -0400 Subject: [PATCH] ci: canaries - improve retry command --- .circleci/config.yml | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8bb6232dcde..f875ef82ba5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1737,6 +1737,10 @@ orbs: label: description: Display name type: string + pre-command: + description: This command will not be retried + type: string + default: '' command: description: Command to run type: string @@ -1761,8 +1765,9 @@ orbs: n=0 until [ $n -ge $MAX_RETRY ] do - "$@" && break + bash -c "$@" && exit 0 n=$[$n+1] + echo "retry $n of $MAX_RETRY" sleep << parameters.sleep >> done if [ $n -ge $MAX_RETRY ]; then @@ -1770,7 +1775,8 @@ orbs: exit 1 fi } - retry << parameters.command >> + eval << parameters.pre-command >> + retry "<< parameters.command >>" no_output_timeout: << parameters.no_output_timeout >> jobs: @@ -1802,13 +1808,14 @@ orbs: steps: - run-with-retry: label: Scaffold App - command: cd ../ && npx -y << parameters.npx-command >> amplify-getting-started-<< parameters.framework >> << parameters.npx-post >> + 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 - - run-with-retry: - label: Call Amplify library in code + - 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 >> @@ -1826,7 +1833,7 @@ orbs: 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) + command: npm run build && (npm start & wait-on http://localhost:3000 -t $MAX_WAIT_ON_TIMEOUT) rn-ios: parameters: @@ -1850,7 +1857,8 @@ orbs: steps: - 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 >> + pre-command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> + command: npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> no_output_timeout: 10m - run-with-retry: label: Install Amplify dependencies @@ -1858,8 +1866,8 @@ orbs: - run-with-retry: label: Pod Install command: npx pod-install - - run-with-retry: - label: Call Amplify library in code + - 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 >> @@ -1901,13 +1909,14 @@ orbs: 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 >> + pre-command: cd ../ && rm -rf amplify_getting_started_<< parameters.framework >> + command: npx react-native@<< parameters.tag >> init amplify_getting_started_<< parameters.framework >> 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: Call Amplify library in code + - 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 >>