Skip to content

Commit

Permalink
rename workflow, add publish, test exponential backoff of 4s
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanynwyeung committed Jan 7, 2025
1 parent fc8db03 commit 3b0be8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
15 changes: 8 additions & 7 deletions .github/actions/install-with-retries/install-with-retries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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`

Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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..."
Expand Down

0 comments on commit 3b0be8c

Please sign in to comment.