Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
zxl629 committed Jan 17, 2025
1 parent dfbb769 commit 6a25b25
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 136 deletions.
80 changes: 40 additions & 40 deletions .github/workflows/callable-local-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 22 additions & 22 deletions .github/workflows/callable-local-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/callable-npm-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions .github/workflows/callable-release-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
75 changes: 38 additions & 37 deletions .github/workflows/push-main-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const startSampleAndRun = async () => {
process.exit(0);
})
.catch((exitInfos) => {
console.log("unexpected error");
const exitCode = exitInfos.exitCode;
process.exit(exitCode);
});
Expand Down

0 comments on commit 6a25b25

Please sign in to comment.