From 3064fec554d7f3cc46fb07a3daf68176ea8f6d6d Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 30 Nov 2023 09:46:29 -0800 Subject: [PATCH] fix: v6 cli release canary (#1140) Co-authored-by: David Lopez --- .github/workflows/canaries.yml | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/.github/workflows/canaries.yml b/.github/workflows/canaries.yml index 79838fe7..af3fb6c5 100644 --- a/.github/workflows/canaries.yml +++ b/.github/workflows/canaries.yml @@ -254,3 +254,85 @@ jobs: role-to-assume: ${{ secrets.CANARY_METRIC_ROLE_ARN }} aws-region: us-west-2 - run: aws cloudwatch put-metric-data --metric-name ReleaseSuccessRate --namespace CodegenUiCanaries --value 1 + + release-canary-v6: + runs-on: ubuntu-latest + steps: + - name: Checkout Studio Codegen + uses: actions/checkout@v2 + with: + path: amplify-codegen-ui + - name: Setup Node.js LTS + uses: actions/setup-node@v2 + with: + node-version: lts/* + - name: Install Latest Amplfy CLI + run: npm i -g @aws-amplify/cli@latest + - name: Create a test react app + run: npx create-react-app e2e-test-app + - name: Install test app dependencies + working-directory: e2e-test-app + run: | + npm i aws-amplify@^6.0.0 @aws-amplify/ui-react@^6.0.0 + npm i --save-dev cypress + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }} + aws-region: us-west-2 + - name: Create temp AWS credentials file + working-directory: e2e-test-app + 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: Run CLI Pull in test app + working-directory: e2e-test-app + run: | + FORCE_RENDER=1 amplify pull --appId ${{ secrets.E2E_TEST_APP_ID }} --envName staging -y --providers "{\ + \"awscloudformation\":{\ + \"configLevel\":\"project\",\ + \"useProfile\":true,\ + \"profileName\":\"default\",\ + }\ + }" + - name: Write test files + working-directory: e2e-test-app + run: cp -r ../amplify-codegen-ui/packages/test-generator/e2e-test-templates-amplify-js-v6/. . + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + working-directory: e2e-test-app + install: false + start: npm start + wait-on: 'http://localhost:3000' + wait-on-timeout: 120 + config-file: cypress.config.js + env: + REACT_APP_USER_EMAIL: ${{ secrets.E2E_TEST_USER_EMAIL }} + REACT_APP_USER_PASSWORD: ${{ secrets.E2E_TEST_USER_PASSWORD }} + + write-release-canary-v6-failure-metric: + runs-on: ubuntu-latest + needs: release-canary-v6 + if: ${{ failure() }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.CANARY_METRIC_ROLE_ARN }} + aws-region: us-west-2 + - run: aws cloudwatch put-metric-data --metric-name ReleaseSuccessRate --namespace CodegenUiCanaries --value 0 + + write-release-canary-v6-success-metric: + runs-on: ubuntu-latest + needs: release-canary-v6 + if: ${{ success() }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.CANARY_METRIC_ROLE_ARN }} + aws-region: us-west-2 + - run: aws cloudwatch put-metric-data --metric-name ReleaseSuccessRate --namespace CodegenUiCanaries --value 1