This commit is contained in:
2022-12-30 16:23:27 +00:00
parent 02776e8478
commit 20da343c54
1304 changed files with 870224 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "$0")" || exit 1; pwd -P)"
REPO_ROOT=$(echo "${SCRIPT_DIR}" | sed 's:scripts::g')
BUILD_INFO_FILE="${REPO_ROOT}/app/build_info.py"
if [[ -z "$1" ]]; then
echo "This script needs to be invoked with the version as an argument"
exit 1
fi
VERSION="$1"
echo "SHA1 = \"${VERSION}\"" > $BUILD_INFO_FILE
BUILD_TIME=$(date +%s)
echo "BUILD_TIME = \"${BUILD_TIME}\"" >> $BUILD_INFO_FILE

21
app/scripts/new-migration.sh Executable file
View File

@ -0,0 +1,21 @@
# Generate a new migration script using Docker
# To run it:
# sh scripts/new-migration.sh
container_name=sl-db-new-migration
# create a postgres database for SimpleLogin
docker rm -f ${container_name}
docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
# sleep a little bit for the db to be ready
sleep 3
# upgrade the DB to the latest stage and
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
# generate the migration script.
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@
# remove the db
docker rm -f ${container_name}

7
app/scripts/reset_local_db.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
export DB_URI=postgresql://myuser:mypassword@localhost:15432/simplelogin
echo 'drop schema public cascade; create schema public;' | psql $DB_URI
poetry run alembic upgrade head
poetry run flask dummy-data

6
app/scripts/reset_test_db.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
export DB_URI=postgresql://myuser:mypassword@localhost:15432/test
echo 'drop schema public cascade; create schema public;' | psql $DB_URI
poetry run alembic upgrade head

19
app/scripts/run-test.sh Executable file
View File

@ -0,0 +1,19 @@
# Run tests
# Delete the test DB if it isn't properly removed
docker rm -f sl-test-db
# Create a test DB
docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -p 15432:5432 postgres:13
# the time for the test DB container to start
sleep 3
# migrate the DB to the latest version
CONFIG=tests/test.env poetry run alembic upgrade head
# run test
poetry run pytest -c pytest.ci.ini
# Delete the test DB
docker rm -f sl-test-db