Skip to content

Commit

Permalink
Add local e2e test for webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
zxl629 committed Dec 27, 2024
1 parent 2394f64 commit 566916f
Show file tree
Hide file tree
Showing 29 changed files with 34,329 additions and 1,978 deletions.
6 changes: 6 additions & 0 deletions .changeset/unlucky-tables-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'integration-tests': minor
'@aws-amplify/data-schema': minor
---

Add local e2e test for webpack
5 changes: 5 additions & 0 deletions .github/integ-config/webpack-integ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- test_name: webpack_basic
desc: 'TypeScript + Webpack 5'
framework: webpack
browser: [chrome]
spec: webpack
46 changes: 46 additions & 0 deletions .github/workflows/callable-local-e2e-webpack-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Local Webpack E2E Test

on: workflow_call

jobs:
unit_test:
name: Local Webpack 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: Load Verdaccio with AmplifyData
uses: ./amplify-data/.github/actions/load-verdaccio-with-amplify-data
- name: Run cypress tests for webpack e2e test dev
shell: bash
working-directory: ./amplify-data
env:
E2E_ENV: ${{ '{}' }}
run: |
if [ -z “” ]; then
../amplify-data/scripts/retry-yarn-script.sh -s \
"ci:test-webpack \
webpack \
webpack \
chrome \
dev \
cli \
--env $(echo $E2E_ENV | jq -r 'tostring')" \
else
echo "Skipping specialized yarn script execution in the dev environment."
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: |
amplify-js-samples-staging/cypress/videos
amplify-js-samples-staging/cypress/screenshots
retention-days: 14
16 changes: 8 additions & 8 deletions .github/workflows/callable-npm-publish-preid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ 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: preid
preid: ${{ inputs.preid }}
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: preid
# preid: ${{ inputs.preid }}
# npm_token: ${{ secrets.NPM_TOKEN }}
# github_user: ${{ vars.GH_USER}}
# github_email: ${{ vars.GH_EMAIL}}
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
29 changes: 17 additions & 12 deletions .github/workflows/callable-release-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ jobs:
prebuild-samples-staging:
secrets: inherit
uses: ./.github/workflows/callable-prebuild-samples-staging.yml
unit-tests:
# unit-tests:
# needs:
# - prebuild-ubuntu
# uses: ./.github/workflows/callable-unit-tests.yml
# local-e2e:
# needs:
# - 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
webpack-e2e:
needs:
- prebuild-ubuntu
uses: ./.github/workflows/callable-unit-tests.yml
local-e2e:
needs:
- 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
uses: ./.github/workflows/callable-local-e2e-webpack-test.yml
53 changes: 27 additions & 26 deletions .github/workflows/push-main-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
# Must disable publishing to NPM prior to adding this branch to avoid
# accidentally publishing changes.
- main
- lzhouq/feat/e2e-webpack

jobs:
prebuild-ubuntu:
Expand All @@ -26,32 +27,32 @@ jobs:
# 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
# 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
Expand Down
9 changes: 9 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
5 changes: 5 additions & 0 deletions cypress/e2e/webpack/webpack.spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('webpack spec', () => {
it('passes', () => {
cy.visit('http://localhost:3000');
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
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"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
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>
// }
// }
// }
17 changes: 17 additions & 0 deletions cypress/support/e2e.ts
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'
Loading

0 comments on commit 566916f

Please sign in to comment.