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 7, 2025
1 parent dc8a205 commit fc8db03
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 6 deletions.
10 changes: 7 additions & 3 deletions .github/actions/install-with-retries/install-with-retries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ 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
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))
fi
done

# exit 0 if last `yarn install` was successful, non-zero otherwise
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/poc-publish-next-with-delay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Description: This workflow runs unit + e2e tests, then publishes UI packages
# to `@next` NPM tag.
#
# 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: next
# secrets:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish:
runs-on: ubuntu-latest
steps:
- name: Fake Publish
run: echo "Fake publish to next"

# 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: next
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: next
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ install_dependencies_with_retries() {
set -e
break
fi
# Add increasing delay between failed attempts of 15s/30s
local wait=$((15 * 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 fc8db03

Please sign in to comment.