generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 18
ci: setup cypress, e2e tests workflow, and local webpack e2e test #418
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
Closed
Closed
Changes from 64 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
566916f
Add local e2e test for webpack
zxl629 409fd72
Fix yml error
zxl629 1c25d21
Fix yml error
zxl629 0451fc3
Fix yml error
zxl629 34da228
Fix yml error
zxl629 4da782f
Replace yarn with npm
zxl629 a8b5896
Fix yml
zxl629 b00984e
Test npm run
zxl629 e324477
Test npm run
zxl629 e6713eb
Test npm run
zxl629 37f5a2c
Test npm run
zxl629 426dcf5
Test npm run
zxl629 85e7299
Fix import bug
zxl629 65d465a
Fix broken existsSync import
zxl629 b2b0227
Delete unused import
zxl629 26ede80
Import parseArgs
zxl629 3331991
Add env in args
zxl629 f4ba407
Fix fml error
zxl629 93b07f5
Fix concurrently error
zxl629 66ee6ea
Fix concurrently empty command
zxl629 d0cfb80
Bug fix
zxl629 141dde8
Install wait-on
zxl629 fe4011e
Cache Cypress
zxl629 28413a8
Fix concurrently error handling
zxl629 e3af6c7
Concurrently version test
zxl629 390ed62
Restore concurrently version
zxl629 659aa8a
Fix concurrently error handling
zxl629 9e6ed11
Modify success condition of concurrently
zxl629 732ffd7
Test sigterm error handling
zxl629 b7e0088
Test
zxl629 aa1aa18
Test
zxl629 1e4207c
Fix error handling of concurrently
zxl629 df69953
Generalize e2e test workflow
zxl629 7716077
Bug fix
zxl629 95eb198
Bug fix
zxl629 219ae61
Bug fix
zxl629 3261d4b
Bug fix
zxl629 9cef5bc
Bug fix
zxl629 ec6b1b8
Fix wrong path
zxl629 80c46a6
Test e2e prod
zxl629 aa7f38b
Add serve to package dependency
zxl629 2e83b1b
Modify Cypress config
zxl629 306dfa7
Update webpack config
zxl629 851aa87
Bug fix
zxl629 61c4eb1
Modify test
zxl629 f505257
Modify index.html
zxl629 c571c9f
Test dev + prod
zxl629 aea7faa
Fix webpack bundle output file extension
zxl629 49cd570
Intentional pipeline failure
zxl629 0cdb7a8
Clean up
zxl629 974588f
Clean up
zxl629 551f86d
Exclude cypress from tsconfig
zxl629 2f3d686
Fix wrong script name
zxl629 d8a266e
Fix e2e runner test name
zxl629 8bcb65b
Move to cypress samples
zxl629 2a0e5e1
Update cypress samples path
zxl629 718c99a
Update docs
zxl629 bec3a18
Fix dependency conflicts
zxl629 10eaff5
Set changeset to empty
zxl629 15205b6
Delete old changesets
zxl629 7f9dfd8
Update e2e docs
zxl629 feaef09
Restore npm publish workflows
zxl629 a159a00
Clean up
zxl629 348ffa2
Clean up
zxl629 dfbb769
Fix e2e README
zxl629 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| tests: | ||
| - test_name: webpack_data_gen2 | ||
| desc: 'Webpack 5' | ||
| framework: webpack | ||
| sample_name: basic-bundle | ||
| spec: bundle | ||
| browser: [chrome] |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| name: E2E Test | ||
| run-name: e2e.${{ inputs.test_name }} | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| test_name: | ||
| required: true | ||
| type: string | ||
| framework: | ||
| required: true | ||
| type: string | ||
| sample_name: | ||
| required: true | ||
| type: string | ||
| spec: | ||
| required: true | ||
| type: string | ||
| browser: | ||
| required: true | ||
| type: string | ||
| backend: | ||
| required: true | ||
| type: string | ||
| timeout_minutes: | ||
| required: true | ||
| type: number | ||
| retry_count: | ||
| required: true | ||
| type: number | ||
| npm_script: | ||
| required: false | ||
| type: string | ||
| npm_script_args: | ||
| required: false | ||
| type: number | ||
| env: | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| e2e-test: | ||
| name: E2E ${{ inputs.test_name }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| browser: | ||
| - ${{ fromJson(inputs.browser) }} | ||
| sample_name: | ||
| - ${{ fromJson(inputs.sample_name) }} | ||
| fail-fast: false | ||
| 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: Load Verdaccio with AmplifyData | ||
| uses: ./amplify-data/.github/actions/load-verdaccio-with-amplify-data | ||
| - name: Make script executable | ||
| run: chmod +x ./amplify-data/scripts/retry-npm-script.sh | ||
| - name: Run cypress tests for ${{ inputs.test_name }} dev | ||
| 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_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 \ | ||
| dev \ | ||
| $E2E_BACKEND \ | ||
| --env $(echo $E2E_ENV | jq -r 'tostring')" \ | ||
| $E2E_NPM_SCRIPT \ | ||
| -n $E2E_RETRY_COUNT | ||
| 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 | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { defineConfig } from 'cypress'; | ||
|
|
||
| export default defineConfig({ | ||
| includeShadowDom: true, | ||
| defaultCommandTimeout: 30000, | ||
| experimentalWebKitSupport: true, | ||
| experimentalModifyObstructiveThirdPartyCode: true, | ||
| e2e: { | ||
| baseUrl: 'http://localhost:3000/', | ||
| specPattern: 'cypress/e2e/**/*.spec.cy.{ts,js}', | ||
| excludeSpecPattern: ['**/__snapshots__/*', '**/__image_snapshots__/*'], | ||
| }, | ||
| chromeWebSecurity: false, | ||
| }); |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| describe('webpack spec', () => { | ||
| it('passes', () => { | ||
| cy.visit('http://localhost:3000'); | ||
| cy.request('/main.bundle.js').then((response) => { | ||
| cy.log('main.bundle.js content:', response.body); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "Using fixtures to represent data", | ||
| "email": "hello@cypress.io", | ||
| "body": "Fixtures are a great way to mock data for responses to routes" | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /// <reference types="cypress" /> | ||
| // *********************************************** | ||
| // This example commands.ts shows you how to | ||
| // create various custom commands and overwrite | ||
| // existing commands. | ||
| // | ||
| // For more comprehensive examples of custom | ||
| // commands please read more here: | ||
| // https://on.cypress.io/custom-commands | ||
| // *********************************************** | ||
| // | ||
| // | ||
| // -- This is a parent command -- | ||
| // Cypress.Commands.add('login', (email, password) => { ... }) | ||
| // | ||
| // | ||
| // -- This is a child command -- | ||
| // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
| // | ||
| // | ||
| // -- This is a dual command -- | ||
| // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
| // | ||
| // | ||
| // -- This will overwrite an existing command -- | ||
| // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
| // | ||
| // declare global { | ||
| // namespace Cypress { | ||
| // interface Chainable { | ||
| // login(email: string, password: string): Chainable<void> | ||
| // drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
| // dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
| // visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
| // } | ||
| // } | ||
| // } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // *********************************************************** | ||
| // This example support/e2e.ts is processed and | ||
| // loaded automatically before your test files. | ||
| // | ||
| // This is a great place to put global configuration and | ||
| // behavior that modifies Cypress. | ||
| // | ||
| // You can change the location of this file or turn off | ||
| // automatically serving support files with the | ||
| // 'supportFile' configuration option. | ||
| // | ||
| // You can read more here: | ||
| // https://on.cypress.io/configuration | ||
| // *********************************************************** | ||
|
|
||
| // Import commands.js using ES2015 syntax: | ||
| import './commands' |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es2020", | ||
| "lib": ["esnext", "dom"], | ||
| "types": ["cypress"] | ||
| }, | ||
| "include": ["**/*.ts", "../cypress.config.ts"] | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we still need to use Verdaccio here since we are already pointing the
@aws-amplify/data-schemadependency in our Cypress sample apps package.json file to the local package.