Skip to content

Commit

Permalink
poc add test workflow and new install script changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanynwyeung committed Jan 9, 2025
1 parent daa2e9b commit 5de99cc
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 9 deletions.
15 changes: 10 additions & 5 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 @@ -32,10 +32,15 @@ for i in {1..3}; do
# Check return value and exit early if successful
return_value=$?
[ $return_value -eq 0 ] && break
echo "[ERROR]: yarn install failed with exit code $return_value, waiting to retry..."

# Sleep 5 seconds before retrying
sleep 5
# Don't add delay at end of last attempt if last attempt fails
if [ "$i" -le 3 ]; then
# 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

# exit 0 if last `yarn install` was successful, non-zero otherwise
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/poc-publish-with-delay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Description: Test publish/next workflow with separate tag + install with delays
#
# Triggered by: push to `poc-ci-fix`

name: POC / Test Publish With Delay

concurrency:
group: e2e-${{ github.sha }}
cancel-in-progress: true

on:
push:
branches: [poc-ci-fix]

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
setup-cache:
uses: aws-amplify/amplify-ui/.github/workflows/reusable-setup-cache.yml@main
with:
commit: ${{ github.sha }}
repository: ${{ github.repository }}

unit:
uses: aws-amplify/amplify-ui/.github/workflows/reusable-unit.yml@main
needs: setup-cache
with:
commit: ${{ github.sha }}
repository: ${{ github.repository }}

e2e:
uses: aws-amplify/amplify-ui/.github/workflows/reusable-e2e.yml@main
needs: unit
with:
commit: ${{ github.sha }}
repository: ${{ github.repository }}
skip-changed-packages-check: 'true' # always run e2e tests for native platform on main
secrets:
AUTH_E2E_ROLE_ARN: ${{ secrets.AUTH_E2E_ROLE_ARN }}
DATASTORE_E2E_ROLE_ARN: ${{ secrets.DATASTORE_E2E_ROLE_ARN }}
GEO_E2E_ROLE_ARN: ${{ secrets.GEO_E2E_ROLE_ARN }}
STORAGE_E2E_ROLE_ARN: ${{ secrets.STORAGE_E2E_ROLE_ARN }}
LIVENESS_E2E_ROLE_ARN: ${{ secrets.LIVENESS_E2E_ROLE_ARN }}
IN_APP_MESSAGING_E2E_ROLE_ARN: ${{ secrets.IN_APP_MESSAGING_E2E_ROLE_ARN }}
AI_E2E_ROLE_ARN: ${{ secrets.AI_E2E_ROLE_ARN }}
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
SITE_URL: ${{ secrets.SITE_URL }}
DOCSEARCH_DOCS_APP_ID: ${{ secrets.DOCSEARCH_DOCS_APP_ID }}
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: testdelay
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# deploy-sample-app:
# runs-on: ubuntu-latest
# environment: deployment
# needs: publish
# steps:
# - name: Trigger build for beta liveness sample app pointing at next tag
# run: curl -X POST -d {} $ENDPOINT -H "Content-Type:application/json"
# env:
# ENDPOINT: ${{ secrets.LIVENESS_BETA_SAMPLE_APP_BUILD_TRIGGER }}

build-test:
uses: ./.github/workflows/reusable-build-system-test.yml
needs: publish
with:
dist-tag: testdelay
secrets:
AUTH_E2E_ROLE_ARN: ${{ secrets.AUTH_E2E_ROLE_ARN }}
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}

build-test-react-native:
uses: ./.github/workflows/reusable-build-system-test-react-native.yml
needs: publish
with:
dist-tag: testdelay
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,10 +20,12 @@ install_dependencies_with_retries() {
set -e
break
fi
# 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 5 seconds..."
sleep 5
echo "$1 install failed. Retrying in $wait seconds..."
sleep $wait
else
echo "$1 install failed after $retries attempts."
echo "Re-enable exit-on-error"
Expand Down
2 changes: 1 addition & 1 deletion build-system-tests/scripts/mega-app-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ else
# react-native-safe-area-context v5.0.0+ does not support RN 0.74 and lower
DEPENDENCIES="$TAGGED_UI_FRAMEWORK @aws-amplify/react-native aws-amplify react-native-safe-area-context@^4.2.5 @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill"
echo "npm install $DEPENDENCIES"
npm install $DEPENDENCIES
install_dependencies_with_retries npm "$DEPENDENCIES"
if [[ "$BUILD_TOOL" == "expo" ]]; then
if [[ "$FRAMEWORK_VERSION" == "0.75" ]]; then
# Expo SDK version 51.0.0 supports RN 0.74 and 0.75 but installs 0.74 by default https://expo.dev/changelog/2024/08-14-react-native-0.75#2-install-updated-packages
Expand Down

0 comments on commit 5de99cc

Please sign in to comment.