Skip to content

Commit df69953

Browse files
committed
Generalize e2e test workflow
1 parent 1e4207c commit df69953

File tree

19 files changed

+178
-40
lines changed

19 files changed

+178
-40
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests:
2+
- test_name: webpack_data_gen2
3+
desc: 'Webpack 5'
4+
framework: webpack
5+
sample_name: basic-bundle
6+
spec: bundle
7+
browser: [chrome]
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: E2E Test
2+
run-name: e2e.${{ inputs.test_name }}
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
test_name:
8+
required: true
9+
type: string
10+
framework:
11+
required: true
12+
type: string
13+
sample_name:
14+
required: true
15+
type: string
16+
spec:
17+
required: true
18+
type: string
19+
browser:
20+
required: true
21+
type: string
22+
backend:
23+
required: true
24+
type: string
25+
timeout_minutes:
26+
required: true
27+
type: number
28+
retry_count:
29+
required: true
30+
type: number
31+
npm_script:
32+
required: false
33+
type: string
34+
npm_script_args:
35+
required: false
36+
type: number
37+
env:
38+
required: false
39+
type: string
40+
41+
jobs:
42+
e2e-test:
43+
name: E2E ${{ inputs.test_name }}
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
browser:
48+
- ${{ fromJson(inputs.browser) }}
49+
sample_name:
50+
- ${{ fromJson(inputs.sample_name) }}
51+
fail-fast: false
52+
timeout-minutes: ${{ inputs.timeout_minutes }}
53+
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
57+
with:
58+
path: amplify-data
59+
- name: Setup node and build the repository
60+
uses: ./amplify-data/.github/actions/node-and-build
61+
- name: Load Verdaccio with AmplifyData
62+
uses: ./amplify-data/.github/actions/load-verdaccio-with-amplify-data
63+
- name: Make script executable
64+
run: chmod +x ./amplify-data/scripts/retry-npm-script.sh
65+
- name: Run cypress tests for webpack e2e test dev
66+
shell: bash
67+
working-directory: ./amplify-data
68+
env:
69+
E2E_FRAMEWORK: ${{ inputs.framework }}
70+
E2E_SAMPLE_NAME: ${{ matrix.sample_name }}
71+
E2E_SPEC: ${{ inputs.spec }}
72+
E2E_BROWSER: ${{ matrix.browser }}
73+
E2E_BACKEND: ${{ inputs.backend }}
74+
E2E_RETRY_COUNT: ${{ inputs.retry_count }}
75+
E2E_TEST_NAME: ${{ inputs.test_name }}
76+
E2E_NPM_SCRIPT: ${{ inputs.npm_script }}
77+
E2E_ENV: ${{ inputs.env }}
78+
run: |
79+
if [ -z "$E2E_NPM_SCRIPT" ]; then
80+
../amplify-js/scripts/retry-npm-script.sh -s \
81+
"ci:test \
82+
$E2E_FRAMEWORK \
83+
$E2E_SAMPLE_NAME \
84+
$E2E_SPEC \
85+
$E2E_BROWSER \
86+
dev \
87+
$E2E_BACKEND \
88+
--env $(echo $E2E_ENV | jq -r 'tostring')" \
89+
$E2E_NPM_SCRIPT \
90+
-n $E2E_RETRY_COUNT
91+
else
92+
echo "Skipping specialized yarn script execution in the dev environment."
93+
fi
94+
- name: Upload artifact
95+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
96+
if: failure()
97+
with:
98+
name: ${{ inputs.test_name }}
99+
if-no-files-found: ignore
100+
path: |
101+
amplify-js-samples-staging/cypress/videos
102+
amplify-js-samples-staging/cypress/screenshots
103+
retention-days: 14
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Local E2E Tests
2+
3+
on: workflow_call
4+
5+
jobs:
6+
e2e-prep:
7+
name: Get E2E test config
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
12+
with:
13+
path: amplify-data
14+
- name: Read integ config files
15+
id: load_config
16+
run: |
17+
echo "INTEG_CONFIG=$(cat .github/integ-config/local-integ-all.yml | yq '.tests' -o=json | jq -c .)" >> $GITHUB_OUTPUT
18+
working-directory: ./amplify-data
19+
outputs:
20+
integ-config: ${{ steps.load_config.outputs.INTEG_CONFIG }}
21+
22+
e2e-test-runner:
23+
name: E2E test runnner
24+
needs: e2e-prep
25+
secrets: inherit
26+
strategy:
27+
matrix:
28+
integ-config: ${{ fromJson(needs.e2e-prep.outputs.integ-config) }}
29+
fail-fast: false
30+
uses: ./.github/workflows/callable-local-e2e-test.yml
31+
with:
32+
test_name: ${{ matrix.integ-config.test_name }}
33+
framework: ${{ matrix.integ-config.framework }}
34+
spec: ${{ matrix.integ-config.spec || '' }}
35+
sample_name: ${{ toJSON(matrix.integ-config.sample_name) || '[""]' }}
36+
browser: ${{ toJSON(matrix.integ-config.browser) || '[""]' }}
37+
backend: ${{ matrix.integ-config.backend }}
38+
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
39+
retry_count: ${{ matrix.integ-config.retry_count || 3 }}
40+
npm_script: ${{ matrix.integ-config.npm_script || '' }}
41+
npm_script_args: ${{ matrix.integ-config.npm_script_args || 15 }}
42+
env: ${{ matrix.integ-config.env && toJSON(matrix.integ-config.env) || '{}' }}

.github/workflows/callable-release-verification.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
# secrets: inherit
2727
# uses: ./.github/workflows/callable-e2e-tests.yml
2828
#
29-
webpack-e2e:
29+
e2e:
3030
needs:
3131
- prebuild-ubuntu
3232
secrets: inherit
33-
uses: ./.github/workflows/callable-local-e2e-webpack-test.yml
33+
uses: ./.github/workflows/callable-local-e2e-tests-temp.yml

cypress.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "cypress";
1+
import { defineConfig } from 'cypress';
22

33
export default defineConfig({
44
e2e: {
File renamed without changes.

packages/e2e-tests/webpack/amplify/auth/resource.ts renamed to packages/e2e-tests/webpack/basic-bundle/amplify/auth/resource.ts

File renamed without changes.
File renamed without changes.

packages/e2e-tests/webpack/amplify/data/resource.ts renamed to packages/e2e-tests/webpack/basic-bundle/amplify/data/resource.ts

File renamed without changes.

0 commit comments

Comments
 (0)