From 3b0be8cd8fa93587153d7e602d6378b0a2dba8fe Mon Sep 17 00:00:00 2001 From: Tiffany Yeung Date: Tue, 7 Jan 2025 09:52:22 -0800 Subject: [PATCH] rename workflow, add publish, test exponential backoff of 4s --- .../install-with-retries.sh | 15 +++++++------ ...h-delay.yml => poc-publish-with-delay.yml} | 22 +++++++------------ .../install-dependencies-with-retries.sh | 6 ++--- 3 files changed, 19 insertions(+), 24 deletions(-) rename .github/workflows/{poc-publish-next-with-delay.yml => poc-publish-with-delay.yml} (86%) diff --git a/.github/actions/install-with-retries/install-with-retries.sh b/.github/actions/install-with-retries/install-with-retries.sh index 2dce33b957..407292520d 100755 --- a/.github/actions/install-with-retries/install-with-retries.sh +++ b/.github/actions/install-with-retries/install-with-retries.sh @@ -17,9 +17,9 @@ if [ "$SKIP_CYPRESS_BINARY" = "true" ]; then export CYPRESS_INSTALL_BINARY=0 fi -for i in {1..3}; do +for i in {1..4}; do echo "====================" - echo "Attempt $i out of 3:" + echo "Attempt $i out of 4:" echo "====================" if [ "$NO_LOCKFILE" = "true" ]; then @@ -33,12 +33,13 @@ for i in {1..3}; do return_value=$? [ $return_value -eq 0 ] && break + # Don't add delay at end of last attempt if last attempt fails if [ "$i" -le 3 ]; then - # when publishing to NPM, there may be a delay before the published tag appears, causing failed installs - # initial script used flat 5s between reruns, which is too fast - # add increasing delay between retries: 15s/30s - echo "[ERROR]: yarn install failed with exit code $return_value, waiting to retry in $((15 * i)) seconds..." - sleep $((15 * i)) + # Potential delay when publishing to NPM before tag appears, causing failed installs + # Add exponential backoff delay between retries + # 4s/16s/64s close to [5s/15s/60s] + echo "[ERROR]: yarn install failed with exit code $return_value, waiting to retry in $((4 * i)) seconds..." + sleep $((4 ** i)) fi done diff --git a/.github/workflows/poc-publish-next-with-delay.yml b/.github/workflows/poc-publish-with-delay.yml similarity index 86% rename from .github/workflows/poc-publish-next-with-delay.yml rename to .github/workflows/poc-publish-with-delay.yml index e5b0a90d2f..680b96f79b 100644 --- a/.github/workflows/poc-publish-next-with-delay.yml +++ b/.github/workflows/poc-publish-with-delay.yml @@ -1,5 +1,4 @@ -# Description: This workflow runs unit + e2e tests, then publishes UI packages -# to `@next` NPM tag. +# Description: Test publish/next workflow with separate tag + install with delays # # Triggered by: push to `poc-ci-fix` @@ -56,17 +55,12 @@ jobs: DOCSEARCH_DOCS_API_KEY: ${{ secrets.DOCSEARCH_DOCS_API_KEY }} DOCSEARCH_DOCS_INDEX_NAME: ${{ secrets.DOCSEARCH_DOCS_INDEX_NAME }} - # publish: - # uses: aws-amplify/amplify-ui/.github/workflows/reusable-tagged-publish.yml@main - # with: - # dist-tag: next - # secrets: - # NPM_TOKEN: ${{ secrets.NPM_TOKEN }} publish: - runs-on: ubuntu-latest - steps: - - name: Fake Publish - run: echo "Fake publish to next" + uses: aws-amplify/amplify-ui/.github/workflows/reusable-tagged-publish.yml@main + with: + dist-tag: test-delay + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # deploy-sample-app: # runs-on: ubuntu-latest @@ -82,7 +76,7 @@ jobs: uses: ./.github/workflows/reusable-build-system-test.yml needs: publish with: - dist-tag: next + dist-tag: test-delay secrets: AUTH_E2E_ROLE_ARN: ${{ secrets.AUTH_E2E_ROLE_ARN }} DOMAIN: ${{ secrets.DOMAIN }} @@ -95,4 +89,4 @@ jobs: uses: ./.github/workflows/reusable-build-system-test-react-native.yml needs: publish with: - dist-tag: next + dist-tag: test-delay diff --git a/build-system-tests/scripts/install-dependencies-with-retries.sh b/build-system-tests/scripts/install-dependencies-with-retries.sh index d84ca6273f..1f8ea797c2 100644 --- a/build-system-tests/scripts/install-dependencies-with-retries.sh +++ b/build-system-tests/scripts/install-dependencies-with-retries.sh @@ -4,7 +4,7 @@ # Takes 2 parameters: the package manager and the dependencies to be installed # Usage: install_with_retries npm "$DEPENDENCIES" or install_with_retries yarn "$DEPENDENCIES" install_dependencies_with_retries() { - local retries=3 + local retries=4 local attempt=1 echo "Disable exit-on-error temporarily" echo "set +e" @@ -20,8 +20,8 @@ install_dependencies_with_retries() { set -e break fi - # Add increasing delay between failed attempts of 15s/30s - local wait=$((15 * attempt)) + # Add increasing delay between failed attempts of 4s/16s/64s + local wait=$((4 ** attempt)) attempt=$((attempt + 1)) if [ $attempt -le $retries ]; then echo "$1 install failed. Retrying in $wait seconds..."