Skip to content

Commit

Permalink
Contract test script stuff
Browse files Browse the repository at this point in the history
Fail nicely if deps arent installed rather than ploughing through,
make it a bit quieter too.

Fix .gitignore line for openapi json and allow .venv-local type
stuff
  • Loading branch information
bitplane committed Feb 12, 2023
1 parent 08f0e28 commit 2c16fb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitignore
@@ -1,4 +1,4 @@
.venv
.venv*
venv
.env
*.pyc
Expand All @@ -8,4 +8,4 @@ __pycache__
.DS_Store

# Generated files
backend/oasst-openapi.json
backend/openapi.json
22 changes: 11 additions & 11 deletions scripts/backend-development/start-mock-server.sh
@@ -1,14 +1,21 @@
#!/usr/bin/env bash

function die() {
popd > /dev/null
echo "Mock server failed to start"
exit 1
}

parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

# switch to backend directory
pushd "$parent_path/../../backend"
pushd "$parent_path/../../backend" > /dev/null

MOCK_SERVER_PORT=8080
OPENAPI_JSON_FILE_NAME=openapi.json

echo "Generating OpenAPI schema..."
python -m main --print-openapi-schema > $OPENAPI_JSON_FILE_NAME
python -m main --print-openapi-schema > $OPENAPI_JSON_FILE_NAME || die
echo "Done!"

echo "Formatting & Copying OpenAPI schema to docs directory..."
Expand All @@ -30,15 +37,8 @@ else
fi

echo "Waiting for server to be live..."
curl --retry-all-errors --retry 5 localhost:$MOCK_SERVER_PORT
curl --retry-all-errors --retry 10 --silent localhost:$MOCK_SERVER_PORT > /dev/null || die
echo ""

# if return code is successful, print successful response
if [ $? -eq 0 ]; then
echo "Mock server is running at localhost:$MOCK_SERVER_PORT"
else
echo "Mock server failed to start"
fi


echo "Mock server is running at localhost:$MOCK_SERVER_PORT"
popd

0 comments on commit 2c16fb0

Please sign in to comment.