From 6a25b25e7da34ce449440673a9501c3c539b7f6e Mon Sep 17 00:00:00 2001 From: Jack Lu Date: Fri, 17 Jan 2025 11:15:17 -0800 Subject: [PATCH] Test --- .github/workflows/callable-local-e2e-test.yml | 80 +++++++++---------- .../workflows/callable-local-e2e-tests.yml | 44 +++++----- .../callable-npm-publish-release.yml | 48 +++++------ .../callable-release-verification.yml | 26 +++--- .github/workflows/push-main-release.yml | 75 ++++++++--------- scripts/test.mjs | 1 + 6 files changed, 138 insertions(+), 136 deletions(-) diff --git a/.github/workflows/callable-local-e2e-test.yml b/.github/workflows/callable-local-e2e-test.yml index a0b7342a3..dc927f847 100644 --- a/.github/workflows/callable-local-e2e-test.yml +++ b/.github/workflows/callable-local-e2e-test.yml @@ -91,43 +91,43 @@ jobs: else echo "Skipping specialized yarn script execution in the dev environment." fi - - name: Run cypress tests for ${{ inputs.test_name }} prod - shell: bash - working-directory: ./amplify-data - env: - E2E_FRAMEWORK: ${{ inputs.framework }} - E2E_SAMPLE_NAME: ${{ matrix.sample_name }} - E2E_SPEC: ${{ inputs.spec }} - E2E_BROWSER: ${{ matrix.browser }} - E2E_BACKEND: ${{ inputs.backend }} - E2E_RETRY_COUNT: ${{ inputs.retry_count }} - E2E_TEST_NAME: ${{ inputs.test_name }} - E2E_NPM_SCRIPT: ${{ inputs.npm_script }} - E2E_NPM_SCRIPT_ARGS: ${{ inputs.npm_script_args }} - E2E_ENV: ${{ inputs.env }} - run: | - if [ -z "$E2E_NPM_SCRIPT" ]; then - ../amplify-data/scripts/retry-npm-script.sh -s \ - "ci:test \ - $E2E_FRAMEWORK \ - $E2E_SAMPLE_NAME \ - $E2E_SPEC \ - $E2E_BROWSER \ - prod \ - $E2E_BACKEND \ - --env $(echo $E2E_ENV | jq -r 'tostring')" \ - $E2E_NPM_SCRIPT \ - -n $E2E_RETRY_COUNT - else - npm run "$E2E_NPM_SCRIPT" "$E2E_NPM_SCRIPT_ARGS" - fi - - name: Upload artifact - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce - if: failure() - with: - name: ${{ inputs.test_name }} - if-no-files-found: ignore - path: | - cypress/videos - cypress/screenshots - retention-days: 14 + # - name: Run cypress tests for ${{ inputs.test_name }} prod + # shell: bash + # working-directory: ./amplify-data + # env: + # E2E_FRAMEWORK: ${{ inputs.framework }} + # E2E_SAMPLE_NAME: ${{ matrix.sample_name }} + # E2E_SPEC: ${{ inputs.spec }} + # E2E_BROWSER: ${{ matrix.browser }} + # E2E_BACKEND: ${{ inputs.backend }} + # E2E_RETRY_COUNT: ${{ inputs.retry_count }} + # E2E_TEST_NAME: ${{ inputs.test_name }} + # E2E_NPM_SCRIPT: ${{ inputs.npm_script }} + # E2E_NPM_SCRIPT_ARGS: ${{ inputs.npm_script_args }} + # E2E_ENV: ${{ inputs.env }} + # run: | + # if [ -z "$E2E_NPM_SCRIPT" ]; then + # ../amplify-data/scripts/retry-npm-script.sh -s \ + # "ci:test \ + # $E2E_FRAMEWORK \ + # $E2E_SAMPLE_NAME \ + # $E2E_SPEC \ + # $E2E_BROWSER \ + # prod \ + # $E2E_BACKEND \ + # --env $(echo $E2E_ENV | jq -r 'tostring')" \ + # $E2E_NPM_SCRIPT \ + # -n $E2E_RETRY_COUNT + # else + # npm run "$E2E_NPM_SCRIPT" "$E2E_NPM_SCRIPT_ARGS" + # fi + # - name: Upload artifact + # uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce + # if: failure() + # with: + # name: ${{ inputs.test_name }} + # if-no-files-found: ignore + # path: | + # cypress/videos + # cypress/screenshots + # retention-days: 14 diff --git a/.github/workflows/callable-local-e2e-tests.yml b/.github/workflows/callable-local-e2e-tests.yml index 822c6a573..7db044605 100644 --- a/.github/workflows/callable-local-e2e-tests.yml +++ b/.github/workflows/callable-local-e2e-tests.yml @@ -3,29 +3,29 @@ name: Local E2E Tests on: workflow_call jobs: - unit_test: - name: Local E2E Tests - runs-on: ubuntu-latest + # unit_test: + # name: Local E2E Tests + # runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f - with: - path: amplify-data - - name: Setup node and build the repository - uses: ./amplify-data/.github/actions/node-and-build - - name: Write Amplify outputs - working-directory: ./amplify-data - env: - AMPLIFY_OUTPUTS_BASE64: ${{ secrets.E2E_NODE_AMPLIFY_OUTPUTS_BASE64 }} - run: | - echo $AMPLIFY_OUTPUTS_BASE64 | base64 --decode > ./packages/e2e-tests/node/amplify_outputs.json - - name: Install Node Sample Dependencies - working-directory: ./amplify-data - run: npm run e2e-node:install - - name: Run tests - working-directory: ./amplify-data - run: npm run e2e-node:test + # steps: + # - name: Checkout repository + # uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + # with: + # path: amplify-data + # - name: Setup node and build the repository + # uses: ./amplify-data/.github/actions/node-and-build + # - name: Write Amplify outputs + # working-directory: ./amplify-data + # env: + # AMPLIFY_OUTPUTS_BASE64: ${{ secrets.E2E_NODE_AMPLIFY_OUTPUTS_BASE64 }} + # run: | + # echo $AMPLIFY_OUTPUTS_BASE64 | base64 --decode > ./packages/e2e-tests/node/amplify_outputs.json + # - name: Install Node Sample Dependencies + # working-directory: ./amplify-data + # run: npm run e2e-node:install + # - name: Run tests + # working-directory: ./amplify-data + # run: npm run e2e-node:test e2e-prep: name: Get E2E test config diff --git a/.github/workflows/callable-npm-publish-release.yml b/.github/workflows/callable-npm-publish-release.yml index 24a848f09..0ecb5b649 100644 --- a/.github/workflows/callable-npm-publish-release.yml +++ b/.github/workflows/callable-npm-publish-release.yml @@ -16,30 +16,30 @@ jobs: - name: Setup node and build the repository uses: ./amplify-data/.github/actions/node-and-build - - name: Run npm publish - uses: ./amplify-data/.github/actions/npm-publish - with: - target: release - npm_token: ${{ secrets.NPM_TOKEN }} - github_user: ${{ vars.GH_USER}} - github_email: ${{ vars.GH_EMAIL}} + # - name: Run npm publish + # uses: ./amplify-data/.github/actions/npm-publish + # with: + # target: release + # npm_token: ${{ secrets.NPM_TOKEN }} + # github_user: ${{ vars.GH_USER}} + # github_email: ${{ vars.GH_EMAIL}} - - name: Set github commit user - env: - GITHUB_EMAIL: ${{ vars.GH_EMAIL }} - GITHUB_USER: ${{ vars.GH_USER }} - run: | - git config --global user.email $GITHUB_EMAIL - git config --global user.name $GITHUB_USER + # - name: Set github commit user + # env: + # GITHUB_EMAIL: ${{ vars.GH_EMAIL }} + # GITHUB_USER: ${{ vars.GH_USER }} + # run: | + # git config --global user.email $GITHUB_EMAIL + # git config --global user.name $GITHUB_USER - - name: Update lockfile with newly published version - working-directory: ./amplify-data - run: npm i + # - name: Update lockfile with newly published version + # working-directory: ./amplify-data + # run: npm i - - name: Commit version and changelog - working-directory: ./amplify-data - run: | - git add . - git commit -m "release: publish [ci skip]" - git push origin main - git push --follow-tags + # - name: Commit version and changelog + # working-directory: ./amplify-data + # run: | + # git add . + # git commit -m "release: publish [ci skip]" + # git push origin main + # git push --follow-tags diff --git a/.github/workflows/callable-release-verification.yml b/.github/workflows/callable-release-verification.yml index bb4cf868f..b70be9f66 100644 --- a/.github/workflows/callable-release-verification.yml +++ b/.github/workflows/callable-release-verification.yml @@ -7,13 +7,13 @@ jobs: uses: ./.github/workflows/callable-prebuild-amplify-data.yml with: runs_on: ubuntu-latest - prebuild-samples-staging: - secrets: inherit - uses: ./.github/workflows/callable-prebuild-samples-staging.yml - unit-tests: - needs: - - prebuild-ubuntu - uses: ./.github/workflows/callable-unit-tests.yml + # prebuild-samples-staging: + # secrets: inherit + # uses: ./.github/workflows/callable-prebuild-samples-staging.yml + # unit-tests: + # needs: + # - prebuild-ubuntu + # uses: ./.github/workflows/callable-unit-tests.yml # NOTE: "local-e2e" is a temporal naming to distinguish them from those pulled # from amplify-js-samples-staging. Should be renamed once we move all e2e tests # to the amplify-data repo. @@ -22,9 +22,9 @@ jobs: - prebuild-ubuntu secrets: inherit uses: ./.github/workflows/callable-local-e2e-tests.yml - e2e: - needs: - - prebuild-ubuntu - - prebuild-samples-staging - secrets: inherit - uses: ./.github/workflows/callable-e2e-tests.yml + # e2e: + # needs: + # - prebuild-ubuntu + # - prebuild-samples-staging + # secrets: inherit + # uses: ./.github/workflows/callable-e2e-tests.yml diff --git a/.github/workflows/push-main-release.yml b/.github/workflows/push-main-release.yml index cd2deda77..84f1c230d 100644 --- a/.github/workflows/push-main-release.yml +++ b/.github/workflows/push-main-release.yml @@ -14,50 +14,51 @@ on: # Must disable publishing to NPM prior to adding this branch to avoid # accidentally publishing changes. - main + - lzhouq/feat/e2e-webpack jobs: - prebuild-ubuntu: - uses: ./.github/workflows/callable-prebuild-amplify-data.yml - with: - runs_on: ubuntu-latest - # This step is included at the top level as a workround (i.e. not in a - # nested workflow). See: https://github.com/orgs/community/discussions/76409. - # The `configure-aws-credentials` GH Action is unable to retrieve the JWT - # token when run from a nested workflow. - # TODO: Find a workaround or alternative so that this can be included in a - # nested workflow (e.g. `callable-sandbox-e2e-tests.yml`). - sandbox_test: - name: Sandbox E2E Tests - needs: prebuild-ubuntu - runs-on: ubuntu-latest - permissions: - # these permissions are required for the `configure-aws-credentials` action to get a JWT: - id-token: write - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f - with: - path: amplify-data - - name: Setup node and build the repository - uses: ./amplify-data/.github/actions/node-and-build - - name: Configure AWS test execution credentials - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2 - with: - role-to-assume: ${{ secrets.SANDBOX_E2E_RUNNER_ROLE_ARN }} - aws-region: us-west-2 - - name: Install Sandbox E2E Dependencies - working-directory: ./amplify-data - run: npm run e2e-sandbox:install - - name: Run E2E sandbox tests - working-directory: ./amplify-data - run: npm run e2e-sandbox:test + # prebuild-ubuntu: + # uses: ./.github/workflows/callable-prebuild-amplify-data.yml + # with: + # runs_on: ubuntu-latest + # # This step is included at the top level as a workround (i.e. not in a + # # nested workflow). See: https://github.com/orgs/community/discussions/76409. + # # The `configure-aws-credentials` GH Action is unable to retrieve the JWT + # # token when run from a nested workflow. + # # TODO: Find a workaround or alternative so that this can be included in a + # # nested workflow (e.g. `callable-sandbox-e2e-tests.yml`). + # sandbox_test: + # name: Sandbox E2E Tests + # needs: prebuild-ubuntu + # runs-on: ubuntu-latest + # permissions: + # # these permissions are required for the `configure-aws-credentials` action to get a JWT: + # id-token: write + # contents: read + # steps: + # - name: Checkout repository + # uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + # with: + # path: amplify-data + # - name: Setup node and build the repository + # uses: ./amplify-data/.github/actions/node-and-build + # - name: Configure AWS test execution credentials + # uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2 + # with: + # role-to-assume: ${{ secrets.SANDBOX_E2E_RUNNER_ROLE_ARN }} + # aws-region: us-west-2 + # - name: Install Sandbox E2E Dependencies + # working-directory: ./amplify-data + # run: npm run e2e-sandbox:install + # - name: Run E2E sandbox tests + # working-directory: ./amplify-data + # run: npm run e2e-sandbox:test release-verification-testing: secrets: inherit uses: ./.github/workflows/callable-release-verification.yml release: needs: - release-verification-testing - - sandbox_test + # - sandbox_test secrets: inherit uses: ./.github/workflows/callable-npm-publish-release.yml diff --git a/scripts/test.mjs b/scripts/test.mjs index 0e1c1a22f..f582dd7bd 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -202,6 +202,7 @@ const startSampleAndRun = async () => { process.exit(0); }) .catch((exitInfos) => { + console.log("unexpected error"); const exitCode = exitInfos.exitCode; process.exit(exitCode); });