Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup e2e tests workflow and local webpack e2e test #508

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
c28fcbc
Add webpack and testfile
zxl629 Jan 14, 2025
65156dc
Add changeset
zxl629 Jan 14, 2025
2cf9341
Add to workflow
zxl629 Jan 15, 2025
2a9dc96
Fix
zxl629 Jan 15, 2025
649ff0c
Yml fix
zxl629 Jan 15, 2025
71d55e8
Yml fix
zxl629 Jan 15, 2025
8f45d3e
Bug fix
zxl629 Jan 15, 2025
6ccc577
Add log
zxl629 Jan 15, 2025
9b10d86
Bug fix
zxl629 Jan 15, 2025
db5d36a
Test
zxl629 Jan 16, 2025
690ac0e
Fix test
zxl629 Jan 16, 2025
a46e755
Fix test
zxl629 Jan 16, 2025
9e021d4
Fix test
zxl629 Jan 16, 2025
d2c0b8b
Test
zxl629 Jan 16, 2025
62823ea
Test
zxl629 Jan 16, 2025
77916ad
Test
zxl629 Jan 16, 2025
5f3dd32
Test
zxl629 Jan 16, 2025
bb341bf
Test
zxl629 Jan 16, 2025
f46c7a4
Test
zxl629 Jan 16, 2025
f9f97ab
Test
zxl629 Jan 16, 2025
412b26f
Test
zxl629 Jan 17, 2025
94a9465
Test
zxl629 Jan 17, 2025
7576a61
Test
zxl629 Jan 17, 2025
fac219b
Test
zxl629 Jan 17, 2025
fadf872
Test
zxl629 Jan 17, 2025
6bac295
Test
zxl629 Jan 17, 2025
965a09f
Test
zxl629 Jan 17, 2025
ac0808e
Test prod
zxl629 Jan 21, 2025
47c4908
Test prod + dev
zxl629 Jan 21, 2025
869e21c
Fail test
zxl629 Jan 21, 2025
633a1ab
Test
zxl629 Jan 21, 2025
04be5a3
Test
zxl629 Jan 21, 2025
2ccb90b
Test sample-staging
zxl629 Jan 21, 2025
fa1ea8d
Test sample-staging
zxl629 Jan 21, 2025
28d73af
Test exit code 4
zxl629 Jan 21, 2025
382494d
Test staging repo
zxl629 Jan 21, 2025
4a9fe2f
Test staging repo
zxl629 Jan 21, 2025
6cb2f25
Test exitinfos
zxl629 Jan 21, 2025
4630e4a
test exitinfos
zxl629 Jan 22, 2025
42c46f4
test success failure
zxl629 Jan 22, 2025
dca632d
concurrently version
zxl629 Jan 22, 2025
0e0927c
concurrently version
zxl629 Jan 22, 2025
ac56902
concurrently version
zxl629 Jan 22, 2025
745e442
Change url
zxl629 Jan 22, 2025
9b0a013
Restore workflows
zxl629 Jan 22, 2025
93a327b
Clean up
zxl629 Jan 22, 2025
729a5e3
Update docs
zxl629 Jan 22, 2025
ea96082
Clean up
zxl629 Jan 22, 2025
cb4b29b
Clean up
zxl629 Jan 22, 2025
6d945d1
Sample test run
zxl629 Jan 22, 2025
dd395dc
Clean up
zxl629 Jan 22, 2025
2ecf191
Merge branch 'main' into lzhouq/feat/webpack
zxl629 Jan 22, 2025
618913e
test chmod
zxl629 Jan 22, 2025
e98525c
test chmod
zxl629 Jan 22, 2025
783ab4a
test shell
zxl629 Jan 23, 2025
fb5277b
Fix test file path
zxl629 Jan 23, 2025
32a07b8
Fix test file path
zxl629 Jan 23, 2025
1ae4346
Test fail
zxl629 Jan 23, 2025
b9b8d12
Delete chmod
zxl629 Jan 23, 2025
2f650e6
Remove retry
zxl629 Jan 23, 2025
8f58b94
Increase wait time
zxl629 Jan 24, 2025
bc91709
Test prod
zxl629 Jan 24, 2025
9250ea4
Add prod
zxl629 Jan 24, 2025
4c52355
only prod
zxl629 Jan 24, 2025
ee81931
Add wait time for kill
zxl629 Jan 24, 2025
1c6e050
Clean up
zxl629 Jan 24, 2025
ddd9915
Clean up
zxl629 Jan 24, 2025
0ce1b33
Test pipeline
zxl629 Jan 24, 2025
c707531
Test pipeline
zxl629 Jan 24, 2025
8ec366d
Test pipeline
zxl629 Jan 24, 2025
a4d7482
Test pipeline
zxl629 Jan 24, 2025
5418694
Test pipeline
zxl629 Jan 24, 2025
0a8250b
Test pipeline
zxl629 Jan 24, 2025
4d38ed5
Clean up
zxl629 Jan 24, 2025
31f5e2a
Clean up
zxl629 Jan 24, 2025
f6ceee8
Format issues
zxl629 Jan 24, 2025
50fca1f
Merge branch 'main' into lzhouq/feat/webpack
stocaaro Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/chilly-snails-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 4 additions & 0 deletions .github/integ-config/local-integ-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tests:
- test_name: webpack_e2e_test
desc: 'Webpack 5'
framework: webpack
45 changes: 45 additions & 0 deletions .github/workflows/callable-local-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: E2E Test
run-name: e2e.${{ inputs.test_name }}

on:
workflow_call:
inputs:
test_name:
required: true
type: string
framework:
required: true
type: string
timeout_minutes:
required: true
type: number

jobs:
e2e-test:
name: E2E ${{ inputs.test_name }}
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}

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: Run e2e tests for ${{ inputs.test_name }} dev
shell: bash
working-directory: ./amplify-data
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_TEST_NAME: ${{ inputs.test_name }}
run: |
npm run ci:test dev
- name: Run e2e tests for ${{ inputs.test_name }} prod
shell: bash
working-directory: ./amplify-data
env:
E2E_FRAMEWORK: ${{ inputs.framework }}
E2E_TEST_NAME: ${{ inputs.test_name }}
run: |
npm run ci:test prod
31 changes: 31 additions & 0 deletions .github/workflows/callable-local-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,34 @@ jobs:
- name: Run tests
working-directory: ./amplify-data
run: npm run e2e-node:test

e2e-prep:
name: Get local E2E test config
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: amplify-data
- name: Read integ config files
id: load_config
run: |
echo "INTEG_CONFIG=$(cat .github/integ-config/local-integ-all.yml | yq '.tests' -o=json | jq -c .)" >> $GITHUB_OUTPUT
working-directory: ./amplify-data
outputs:
integ-config: ${{ steps.load_config.outputs.INTEG_CONFIG }}


e2e-test-runner:
name: E2E test runnner
needs: e2e-prep
secrets: inherit
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config) }}
fail-fast: false
uses: ./.github/workflows/callable-local-e2e-test.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
framework: ${{ matrix.integ-config.framework }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
2 changes: 1 addition & 1 deletion e2e-TEST-COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The following table outlines the current e2e test coverage for various runtimes
|---------------------|-----------|
| Chrome | [✅](.github/workflows/callable-e2e-test.yml) |
| Node | [✅](packages/e2e-tests/node/jest.config.ts) |
| Webpack | ⚠️ |
| Webpack | [✅](packages/e2e-tests/webpack/webpack.config.js) |
| Rollup | ⚠️ |
| Metro | ⚠️ |
| React Natives | ⚠️ |
Expand Down
133 changes: 121 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"stop:npm-proxy": "tsx scripts/stop_npm_proxy.ts",
"test": "turbo run test && npm run test:scripts && npm run e2e-exports",
"test:scripts": "npx jest scripts/",
"ci:test": "./scripts/bundler_test.sh",
"turbo": "turbo",
"vend": "npm run start:npm-proxy && npm run publish:local"
},
Expand Down
29 changes: 21 additions & 8 deletions packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# `amplify-data` E2E Tests

## Node testing

This package contains automated tests for validating functionality E2E in Node.

## How it works:
### How it works:

- All tests within `node` share a single "long-lived" Amplify backend (added to
the shared Cypress account).
- Sample will use `amplify-js@unstable` and local versions of packages in this repo.
- See [test utils](node/utils.ts) for helpers that configure Amplify, generate /
configure the API client, as well as for additional test utilities and types.

## How to add a new test / test local changes:
### How to add a new test / test local changes:

1. Create a new file under `__tests__`
2. Use the helpers to configure Amplify and generate / configure the API client.
Expand All @@ -19,12 +21,12 @@ This package contains automated tests for validating functionality E2E in Node.
ensure that a `package-lock` file is not generated for this sample.
4. [TODO] subscription testing (will be added with follow-up PR)

## [TODO] Global cleanup
### [TODO] Global cleanup

Add a check to clean up potential orphaned records after all tests have run
(see https://jestjs.io/docs/configuration#globalteardown-string).

## [Known Issue] Jest open handles warning
### [Known Issue] Jest open handles warning

Tests that use `Hub` currently emit the following warning when running the tests:

Expand All @@ -42,7 +44,7 @@ TODO: Investigate and/or fix.

All tests within the `sandbox` directory deploy a new sandbox for each test run.

## How it works:
### How it works:

CLI commands are managed by the process controller. The process controller is
responsible for executing CLI commands, and listening for output from the CLI.
Expand All @@ -58,7 +60,7 @@ Test setup / execution is structured as follows:
5. Sandbox is torn down after the tests are complete. `.amplify/` and
`amplify_outputs.json` are deleted.

## CI AWS Credentials:
### CI AWS Credentials:

We follow the recommended OS approach to get AWS account credentials: https://w.amazon.com/bin/view/Open_Source/GitHub/Actions.
Specifically, we use the [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials#assuming-a-role) GH Action to obtain credentials from
Expand All @@ -83,16 +85,27 @@ To view identify provider details in the console, see: `Console > IAM > Identity
- https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
- https://github.com/aws-actions/configure-aws-credentials

## How to add a new test:
### How to add a new test:

1. Add a new project directory under `amplify-backends`. Must also contain a
basic `package.json`.
2. Add a corresponding test file under `__tests__`.
3. Use the utils to generate / teardown the sandbox withthe process controller.

## Using Execa with Jest
### Using Execa with Jest

Execa is the primary dependency used to run CLI commands in the process
controller, and it is a pure ES module. Unlike `amplify-backend`, which uses the
Node test runner, our tests are written in Jest. This results in [this issue](https://github.com/sindresorhus/execa/issues/465).
The workaround is to use Jest's [experimental support for ECMAScript Modules](https://jestjs.io/docs/ecmascript-modules). There is a backlog item to investigate other potential solutions.

## General tool testing:

This is the general guidance for testing module bundlers. When testing other tools in the future, please adapt these guidelines accordingly and update this file.

### How to add a new e2e test sample:

1. Add a sample in this directory following the structure `e2e-tests/<framework>`.
2. Add configs for your test to the [local-integ-all.yml](../../.github/integ-config/local-integ-all.yml) file.
3. Create an npm command for your test script and call it from [callable-local-e2e-test](../../.github/workflows/callable-local-e2e-test.yml).
4. Update the e2e test coverage for `amplify-data` repo in [e2e test coverage table](../../e2e-TEST-COVERAGE.md).
8 changes: 8 additions & 0 deletions packages/e2e-tests/webpack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*

# lock file
package-lock.json
Loading
Loading