Build and Runtime Test #67162
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: this workflow runs build and simple runtime tests on supported | |
# frameworks and their build systems. | |
# | |
# Triggered by: it runs every 15 minutes. | |
name: Build and Runtime Test | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
on: | |
schedule: | |
- cron: '*/15 * * * *' # Run every 15 minutes | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: ci | |
strategy: | |
fail-fast: false | |
matrix: | |
# Paths for each example app we want to test build on | |
include: | |
- framework: angular | |
build-tool: angularcli | |
- framework: react | |
build-tool: cra | |
- framework: react | |
build-tool: cra-ts | |
- framework: react | |
build-tool: next | |
- framework: react | |
build-tool: vite | |
- framework: react | |
build-tool: vite3 | |
- framework: vue | |
build-tool: vite | |
- framework: vue | |
build-tool: vite3 | |
- framework: vue | |
build-tool: vuecli | |
steps: | |
- name: Checkout Amplify UI | |
uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
persist-credentials: false | |
- name: Setup Node.js 20 | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/commit/60edb5dd545a775178f52524783378180af0d1f8 | |
with: | |
node-version: 20 | |
cache: 'yarn' | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 | |
- name: Install canary package | |
uses: ./.github/actions/install-with-retries | |
with: | |
no-lockfile: true | |
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }} | |
- name: Add Amplify CLI | |
run: yarn global add @aws-amplify/cli | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 https://github.com/aws-actions/configure-aws-credentials/commit/e3dd6a429d7300a6a4c196c26e071d42e0343502 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: ${{ secrets.AUTH_E2E_ROLE_ARN }} | |
# Amplify CLI does not support headless pull with temporary credentials | |
# when useProfile is false. | |
# See: https://github.com/aws-amplify/amplify-cli/issues/11009. | |
- name: Create temp AWS profile | |
run: | | |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \ | |
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \ | |
aws configure set aws_session_token $AWS_SESSION_TOKEN && \ | |
aws configure set default.region $AWS_REGION | |
- name: Pull down AWS environments | |
run: yarn pull | |
working-directory: ./canary | |
- name: Delete AWS Profile | |
run: rm -rf ~/.aws | |
- name: Build example app | |
run: yarn build | |
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }} | |
# This steps attempts to restore cypress runner. It will not create any new | |
# cache entries however, because cypress runner isn't available yet. | |
- name: Restore cypress runner from Cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
id: restore-cypress-cache | |
with: | |
path: ~/.cache/Cypress | |
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('canary/e2e/yarn.lock') }} | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | |
- name: Install e2e packages | |
uses: ./.github/actions/install-with-retries | |
with: | |
working-directory: ./canary/e2e | |
# If we got a cache hit on cypress runner, then we will skip cypress binary | |
# installation. Otherwise, it will install cypress binary. | |
skip-cypress-binary: ${{ steps.restore-cypress-cache.outputs.cache-hit }} | |
# If cypress cache was missed, then we need to create new cache entry and upload it. | |
# At this point, cypress runner should've been installed from the previous installation | |
# step, so we go ahead and update the cache entry. | |
- name: Cache cypress runner | |
if: steps.restore-cypress-cache.outputs.cache-hit != 'true' | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
with: | |
path: ~/.cache/Cypress | |
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('canary/e2e/yarn.lock') }} | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | |
- name: Start ${{ matrix.framework }}/${{ matrix.build-tool }} example | |
run: yarn start & npx wait-on -c waitOnConfig.json -t 20000 http-get://localhost:3000 | |
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }} | |
- name: Run E2E tests against ${{ matrix.framework }}/${{ matrix.build-tool }} example | |
run: yarn test | |
id: e2e | |
working-directory: ./canary | |
env: | |
# Env values for testing flows | |
DOMAIN: ${{ secrets.DOMAIN }} | |
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }} | |
USERNAME: ${{ secrets.USERNAME }} | |
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }} | |
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }} | |
- name: Upload videos and screenshots | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce | |
if: ${{ failure() && steps.e2e.outcome != 'success' }} | |
with: | |
name: canary-cypress-error-${{ matrix.framework }}-${{ matrix.build-tool }} | |
path: | | |
canary/e2e/cypress/videos/** | |
canary/e2e/cypress/screenshots/** | |
retention-days: 5 | |
log-failure-metric: | |
# Send a failure data point to metric BuildAndRuntimeTestFailure in github-workflows@ us-east-2, if it's a failure | |
runs-on: ubuntu-latest | |
environment: ci | |
needs: build | |
if: ${{ failure() }} | |
steps: | |
- name: Log failure data point to metric BuildAndRuntimeTestFailure | |
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main | |
with: | |
metric-name: BuildAndRuntimeTestFailure | |
value: 1 | |
role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }} | |
aws-region: us-east-2 | |
log-success-metric: | |
# Send a success data point to metric BuildAndRuntimeTestFailure in github-workflows@ us-east-2, if it's a success | |
runs-on: ubuntu-latest | |
environment: ci | |
needs: build | |
if: ${{ success() }} | |
steps: | |
- name: Log success data point to metric BuildAndRuntimeTestFailure | |
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main | |
with: | |
metric-name: BuildAndRuntimeTestFailure | |
value: 0 | |
role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }} | |
aws-region: us-east-2 |