diff --git a/.github/workflows/callable-local-e2e-test.yml b/.github/workflows/callable-local-e2e-test.yml index c8a13307..ab1239e2 100644 --- a/.github/workflows/callable-local-e2e-test.yml +++ b/.github/workflows/callable-local-e2e-test.yml @@ -30,8 +30,8 @@ jobs: path: amplify-data - name: Setup node and build the repository uses: ./amplify-data/.github/actions/node-and-build - # - name: Make script executable - # run: chmod +x ./amplify-data/scripts/retry-npm-script.sh + - name: Make script executable + run: chmod +x ./amplify-data/scripts/retry-npm-script.sh - name: Run e2e tests for ${{ inputs.test_name }} dev shell: bash working-directory: ./amplify-data @@ -41,20 +41,18 @@ jobs: E2E_TEST_NAME: ${{ inputs.test_name }} run: | ../amplify-data/scripts/retry-npm-script.sh -s \ - "ci:test \ - $E2E_FRAMEWORK \ - dev" \ + "e2e-shell:test" \ -n $E2E_RETRY_COUNT - - name: Run e2e tests for ${{ inputs.test_name }} prod - shell: bash - working-directory: ./amplify-data - env: - E2E_FRAMEWORK: ${{ inputs.framework }} - E2E_RETRY_COUNT: ${{ inputs.retry_count }} - E2E_TEST_NAME: ${{ inputs.test_name }} - run: | - ../amplify-data/scripts/retry-npm-script.sh -s \ - "ci:test \ - $E2E_FRAMEWORK \ - prod" \ - -n $E2E_RETRY_COUNT \ No newline at end of file + # - name: Run e2e tests for ${{ inputs.test_name }} prod + # shell: bash + # working-directory: ./amplify-data + # env: + # E2E_FRAMEWORK: ${{ inputs.framework }} + # E2E_RETRY_COUNT: ${{ inputs.retry_count }} + # E2E_TEST_NAME: ${{ inputs.test_name }} + # run: | + # ../amplify-data/scripts/retry-npm-script.sh -s \ + # "ci:test \ + # $E2E_FRAMEWORK \ + # prod" \ + # -n $E2E_RETRY_COUNT \ No newline at end of file diff --git a/package.json b/package.json index b2e14feb..79efe215 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "test": "turbo run test && npm run test:scripts && npm run e2e-exports", "test:scripts": "npx jest scripts/", "ci:test": "node scripts/test.mjs", + "e2e-shell:test": "./bundler_test.sh", "turbo": "turbo", "vend": "npm run start:npm-proxy && npm run publish:local" }, diff --git a/scripts/bundler_test.sh b/scripts/bundler_test.sh new file mode 100644 index 00000000..c9b4a9ea --- /dev/null +++ b/scripts/bundler_test.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Run the npm commands +npm --prefix packages/e2e-tests/webpack install && npm --prefix packages/e2e-tests/webpack run start & + +# Store the PID of the npm process +NPM_PID=$! + +# Function to check if the server is up +check_server() { + for i in {1..30}; do + sleep 2 + if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 | grep -q "200"; then + return 0 + fi + done + return 1 +} + +# Wait for the server to start (with timeout) +if check_server; then + echo "Server is up and running!" + # Kill the npm process + kill $NPM_PID + exit 0 +else + echo "Server failed to start or return 200 status code within the timeout period." + # Kill the npm process + kill $NPM_PID + exit 1 +fi \ No newline at end of file