Skip to content

Commit

Permalink
test shell
Browse files Browse the repository at this point in the history
  • Loading branch information
zxl629 committed Jan 23, 2025
1 parent e98525c commit 783ab4a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
34 changes: 16 additions & 18 deletions .github/workflows/callable-local-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
# - 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
31 changes: 31 additions & 0 deletions scripts/bundler_test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 783ab4a

Please sign in to comment.