Alek/intfix (#898)
* Added working integration tests * Uncomment integration tests * Get rid of no root * Changed caching rules.
This commit is contained in:
parent
60323a3aec
commit
bfb96b842f
3
.github/workflows/integration_examples.yml
vendored
3
.github/workflows/integration_examples.yml
vendored
@ -58,8 +58,7 @@ jobs:
|
||||
key: python-${{ matrix.python-version }}-pydeps-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
- name: Poetry Install
|
||||
run: poetry install --no-interaction --no-root
|
||||
if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction
|
||||
- name: Install Requirements
|
||||
working-directory: ./pynecone-examples/counter
|
||||
run: poetry run pip install -r requirements.txt
|
||||
|
25
.github/workflows/integration_website.yml
vendored
25
.github/workflows/integration_website.yml
vendored
@ -58,16 +58,15 @@ jobs:
|
||||
path: .venv
|
||||
key: python-${{ matrix.python-version }}-pydeps-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
# - name: Poetry Install
|
||||
# run: poetry install --no-interaction --no-root
|
||||
# if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
# - name: Install Requirements
|
||||
# working-directory: ./pcweb
|
||||
# run: poetry run pip install -r requirements.txt && poetry run pip install googletrans
|
||||
# - name: Init Website
|
||||
# working-directory: ./pcweb
|
||||
# run: poetry run pc init
|
||||
# - name: Run Website and Check for errors
|
||||
# run: |
|
||||
# chmod +x ./scripts/integration.sh
|
||||
# ./scripts/integration.sh ./pcweb prod
|
||||
- name: Poetry Install
|
||||
run: poetry install --no-interaction
|
||||
- name: Install Requirements
|
||||
working-directory: ./pcweb
|
||||
run: poetry run pip install -r requirements.txt && poetry run pip install googletrans
|
||||
- name: Init Website
|
||||
working-directory: ./pcweb
|
||||
run: poetry run pc init
|
||||
- name: Run Website and Check for errors
|
||||
run: |
|
||||
chmod +x ./scripts/integration.sh
|
||||
./scripts/integration.sh ./pcweb prod
|
||||
|
@ -1,41 +1,35 @@
|
||||
GNU nano 4.8 run_bash.sh #!/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
cd "$1"
|
||||
curl -fsSL https://bun.sh/install | bash -s -- bun-v0.5.5
|
||||
# Change directory to the first argument passed to the script
|
||||
cd "$1" || exit 1
|
||||
echo "Changed directory to $1"
|
||||
|
||||
set -e
|
||||
if [ "$2" = "dev" ]; then
|
||||
timeout 2m poetry run pc run --env "$2" || exit 0 & sleep 50
|
||||
else
|
||||
timeout 5m poetry run pc run --env "$2" || exit 0 & sleep 250
|
||||
fi
|
||||
# Start the server in the background
|
||||
poetry run pc run --env "$2" & pid=$!
|
||||
echo "Started server with PID $pid"
|
||||
|
||||
# set the HOST to request
|
||||
HOST="127.0.0.1"
|
||||
FRONTEND_PORT="3000"
|
||||
API_PORT="8000"
|
||||
# Wait for ports 3000 and 8000 to become available
|
||||
wait_time=0
|
||||
while ! nc -z localhost 3000 || ! lsof -i :8000 >/dev/null; do
|
||||
if ! kill -0 "$pid" >/dev/null 2>&1; then
|
||||
echo "Error: Server process with PID $pid exited early"
|
||||
break
|
||||
fi
|
||||
if ((wait_time >= 120)); then
|
||||
echo "Error: Timeout waiting for ports 3000 and 8000 to become available"
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
((wait_time += 5))
|
||||
echo "Waiting for ports 3000 and 8000 to become available (waited $wait_time seconds)..."
|
||||
done
|
||||
|
||||
# make the curl request and save the response and HTTP status code
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" "$HOST:$FRONTEND_PORT")
|
||||
|
||||
# extract the HTTP status code from the response
|
||||
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
|
||||
|
||||
|
||||
# check for errors based on the HTTP status code
|
||||
if [[ $HTTP_STATUS -ge 400 ]]; then
|
||||
echo "Error: HTTP status code $HTTP_STATUS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check for errors on API server
|
||||
API_RESPONSE=$(curl --silent "$HOST:$API_PORT/ping")
|
||||
|
||||
if echo "$API_RESPONSE" | grep -q "pong"; then
|
||||
echo "success with HTTP STATUS: $HTTP_STATUS"
|
||||
# Check if the server is still running
|
||||
if kill -0 "$pid" >/dev/null 2>&1; then
|
||||
echo "Integration test passed"
|
||||
kill -TERM $(pgrep -P "$pid")
|
||||
exit 0
|
||||
else
|
||||
echo "Error starting API server"
|
||||
echo "Integration test failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
Loading…
Reference in New Issue
Block a user