name: E2E Test run-name: e2e.${{ inputs.test_name }} on: workflow_call: inputs: test_name: required: true type: string framework: required: true type: string category: 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 amplifyjs_dir: required: true type: boolean timeout_minutes: required: true type: number retry_count: required: true type: number yarn_script: required: false type: string yarn_script_args: required: false type: string env: required: false type: string env: AMPLIFY_DIR: /home/runner/work/amplify-js/amplify-js/amplify-js CYPRESS_GOOGLE_CLIENTID: ${{ secrets.CYPRESS_GOOGLE_CLIENTID }} CYPRESS_GOOGLE_CLIENT_SECRET: ${{ secrets.CYPRESS_GOOGLE_CLIENT_SECRET }} CYPRESS_GOOGLE_REFRESH_TOKEN: ${{ secrets.CYPRESS_GOOGLE_REFRESH_TOKEN }} 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: path: amplify-js - name: Setup node and build the repository uses: ./amplify-js/.github/actions/node-and-build - name: Setup samples staging repository uses: ./amplify-js/.github/actions/setup-samples-staging with: GH_TOKEN_STAGING_READ: ${{ secrets.GH_TOKEN_STAGING_READ }} - name: Load Verdaccio with AmplifyJs uses: ./amplify-js/.github/actions/load-verdaccio-with-amplify-js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run cypress tests for ${{ inputs.test_name }} dev shell: bash working-directory: amplify-js-samples-staging env: E2E_FRAMEWORK: ${{ inputs.framework }} E2E_CATEGORY: ${{ inputs.category }} E2E_SAMPLE_NAME: ${{ matrix.sample_name }} E2E_SPEC: ${{ inputs.spec }} E2E_BROWSER: ${{ matrix.browser }} E2E_BACKEND: ${{ inputs.backend }} E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}} E2E_RETRY_COUNT: ${{ inputs.retry_count }} E2E_TEST_NAME: ${{ inputs.test_name }} E2E_YARN_SCRIPT: ${{ inputs.yarn_script }} E2E_ENV: ${{ inputs.env }} run: | if [ -z "$E2E_YARN_SCRIPT" ]; then ../amplify-js/scripts/retry-yarn-script.sh -s \ "ci:test \ $E2E_FRAMEWORK \ $E2E_CATEGORY \ $E2E_SAMPLE_NAME \ $E2E_SPEC \ $E2E_BROWSER \ dev \ $E2E_BACKEND \ $E2E_AMPLIFY_JS_DIR \ --env $(echo $E2E_ENV | jq -r 'tostring')" \ $E2E_YARN_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-js-samples-staging env: E2E_FRAMEWORK: ${{ inputs.framework }} E2E_CATEGORY: ${{ inputs.category }} E2E_SAMPLE_NAME: ${{ matrix.sample_name }} E2E_SPEC: ${{ inputs.spec }} E2E_BROWSER: ${{ matrix.browser }} E2E_BACKEND: ${{ inputs.backend }} E2E_AMPLIFY_JS_DIR: ${{ inputs.amplifyjs_dir == true && env.AMPLIFY_DIR || ''}} E2E_RETRY_COUNT: ${{ inputs.retry_count }} E2E_TEST_NAME: ${{ inputs.test_name }} E2E_YARN_SCRIPT: ${{ inputs.yarn_script }} E2E_YARN_SCRIPT_ARGS: ${{ inputs.yarn_script_args }} E2E_ENV: ${{ inputs.env }} run: | if [ -z "$E2E_YARN_SCRIPT" ]; then ../amplify-js/scripts/retry-yarn-script.sh -s \ "ci:test \ $E2E_FRAMEWORK \ $E2E_CATEGORY \ $E2E_SAMPLE_NAME \ $E2E_SPEC \ $E2E_BROWSER \ prod \ $E2E_BACKEND \ $E2E_AMPLIFY_JS_DIR \ --env $(echo $E2E_ENV | jq -r 'tostring')" \ $E2E_YARN_SCRIPT \ -n $E2E_RETRY_COUNT else yarn "$E2E_YARN_SCRIPT" "$E2E_YARN_SCRIPT_ARGS" "$E2E_SPEC" fi - name: Upload artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 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 overwrite: true