Add pcweb to integration tests (#657)
This commit is contained in:
parent
416a813be8
commit
38ecc66893
@ -4,6 +4,7 @@ on:
|
|||||||
pull_request_review:
|
pull_request_review:
|
||||||
types: [submitted]
|
types: [submitted]
|
||||||
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
||||||
node-version: ["15.x"]
|
node-version: ["16.x"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -31,13 +32,12 @@ jobs:
|
|||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
# Clone Pynecone Website Repo For integration tests
|
# Clone Pynecone Website Repo For integration tests
|
||||||
- name: Clone Pynecone Website Repo
|
- name: Clone Pynecone Examples Repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: pynecone-io/pynecone-examples
|
repository: pynecone-io/pynecone-examples
|
||||||
path: pynecone-examples
|
path: pynecone-examples
|
||||||
|
|
||||||
# Install poetry
|
|
||||||
- name: cache poetry install
|
- name: cache poetry install
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
@ -66,25 +66,7 @@ jobs:
|
|||||||
- name: Init Website
|
- name: Init Website
|
||||||
working-directory: ./pynecone-examples/counter
|
working-directory: ./pynecone-examples/counter
|
||||||
run: poetry run pc init
|
run: poetry run pc init
|
||||||
- name: Run Website and check for errors
|
- name: Check for errors
|
||||||
working-directory: ./pynecone-examples/counter
|
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL https://bun.sh/install | bash -s -- bun-v0.5.5
|
chmod +x ./scripts/integration.sh
|
||||||
timeout 2m poetry run pc run &
|
./scripts/integration.sh ./pynecone-examples/counter dev
|
||||||
sleep 10
|
|
||||||
URL="127.0.0.1:3000"
|
|
||||||
|
|
||||||
# make the curl request and save the response and HTTP status code
|
|
||||||
RESPONSE=$(curl -s -w "\n%{http_code}" $URL)
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
echo "success with HTTP STATUS: $HTTP_STATUS"
|
|
||||||
|
|
73
.github/workflows/integration_website.yml
vendored
Normal file
73
.github/workflows/integration_website.yml
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
name: integration-test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_review:
|
||||||
|
types: [submitted]
|
||||||
|
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
if: github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Specify python/node versions to test against
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10", "3.11"]
|
||||||
|
node-version: ["16.x"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
# Clone Pynecone Website Repo For integration tests
|
||||||
|
- name: Clone Pynecone Website Repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: pynecone-io/pcweb
|
||||||
|
path: pcweb
|
||||||
|
|
||||||
|
# Install poetry
|
||||||
|
- name: cache poetry install
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.local
|
||||||
|
key: python-${{ matrix.python-version }}-poetry-1.3.1
|
||||||
|
|
||||||
|
- uses: snok/install-poetry@v1
|
||||||
|
with:
|
||||||
|
version: 1.3.1
|
||||||
|
virtualenvs-create: true
|
||||||
|
virtualenvs-in-project: true
|
||||||
|
|
||||||
|
- name: cache deps
|
||||||
|
id: cache-deps
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
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 pynecone==0.1.19 && 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
|
41
scripts/integration.sh
Normal file
41
scripts/integration.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
GNU nano 4.8 run_bash.sh #!/bin/bash
|
||||||
|
|
||||||
|
cd "$1"
|
||||||
|
curl -fsSL https://bun.sh/install | bash -s -- bun-v0.5.5
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# set the HOST to request
|
||||||
|
HOST="127.0.0.1"
|
||||||
|
FRONTEND_PORT="3000"
|
||||||
|
API_PORT="8000"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Error starting API server"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user