From 07d0604ca5eb88de0d9cf279ec7bb3be2e634ad6 Mon Sep 17 00:00:00 2001 From: Elijah Ahianyo Date: Thu, 9 Mar 2023 22:59:04 +0000 Subject: [PATCH] Add integration tests (#650) --- .github/workflows/integration.yml | 50 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 48e049e3c..7d9564b43 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -4,7 +4,6 @@ on: pull_request_review: types: [submitted] - permissions: contents: read @@ -35,8 +34,8 @@ jobs: - name: Clone Pynecone Website Repo uses: actions/checkout@v3 with: - repository: pynecone-io/pcweb - path: pcweb + repository: pynecone-io/pynecone-examples + path: pynecone-examples # Install poetry - name: cache poetry install @@ -58,17 +57,34 @@ jobs: path: .venv key: python-${{ matrix.python-version }}-pydeps-${{ hashFiles('**/poetry.lock') }} - # Begin the integration test - # Commenting this out for now while we improve it. - # - 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 - # - name: Init Website - # working-directory: ./pcweb - # run: poetry run pc init - # - name: Run Website - # working-directory: ./pcweb - # run: timeout 1m poetry run pc run || exit 0 \ No newline at end of file + - name: Poetry Install + run: poetry install --no-interaction --no-root + if: steps.cache-deps.outputs.cache-hit != 'true' + - name: Install Requirements + working-directory: ./pynecone-examples/counter + run: poetry run pip install -r requirements.txt + - name: Init Website + working-directory: ./pynecone-examples/counter + run: poetry run pc init + - name: Run Website and check for errors + working-directory: ./pynecone-examples/counter + run: | + curl -fsSL https://bun.sh/install | bash -s -- bun-v0.5.5 + timeout 2m poetry run pc run & + 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" +