Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use postgresql for testing #569

Merged
merged 8 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/auth-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
working-directory: ./server
run: cp .env.local.online-auth .env

- name: Run postgresql server in background
working-directory: ./server
run: sh run_dev_postgresql.sh && sleep 6

- name: Run django server in background with generated certs
working-directory: ./server
run: sh setup-dev-server.sh & sleep 6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Set server environment vars
working-directory: ./server
run: cp .env.local.local-auth .env
run: cp .env.local.local-auth.sqlite .env

- name: Generate SSL certificate
working-directory: ./server
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/local-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ jobs:
working-directory: ./server
run: cp .env.local.local-auth .env

- name: Run postgresql server in background
working-directory: ./server
run: sh run_dev_postgresql.sh && sleep 6

- name: Run django server in background with generated certs
working-directory: ./server
run: sh setup-dev-server.sh & sleep 6
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Set server environment vars
working-directory: ./server
run: cp .env.local.local-auth .env
- name: Run postgresql server in background
working-directory: ./server
run: sh run_dev_postgresql.sh && sleep 6
- name: Run migrations
working-directory: ./server
run: python manage.py migrate
Expand Down
2 changes: 1 addition & 1 deletion server/.env.local.local-auth
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DEBUG=True
SECRET_KEY=I_AM_A_DUMMY_KEY_CHANGE_ME
DATABASE_URL=sqlite:///db.sqlite3
DATABASE_URL=postgres://devuser:[email protected]/devdb
SUPERUSER_USERNAME=admin
SUPERUSER_PASSWORD=admin
ALLOWED_HOSTS=*
Expand Down
23 changes: 23 additions & 0 deletions server/.env.local.local-auth.sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
##############################################################
############## ALERT: DO NOT USE FOR PRODUCTION ##############
##############################################################

DEBUG=True
SECRET_KEY=I_AM_A_DUMMY_KEY_CHANGE_ME
DATABASE_URL=sqlite:///db.sqlite3
SUPERUSER_USERNAME=admin
SUPERUSER_PASSWORD=admin
ALLOWED_HOSTS=*

#Valid deployment environments are local, gcp-ci, gcp-prod(case-sensitive)
DEPLOY_ENV=local

#Production settings when deployed in GCP
CORS_ALLOWED_ORIGINS=
GS_BUCKET_NAME=

#Auth configuration
AUTH_AUDIENCE=https://localhost-localdev/
AUTH_ISSUER=https://localhost:8000/
AUTH_JWK_URL=
AUTH_VERIFYING_KEY="-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtKO1SzU6N/sZTJmYNk0C\n/5XbK8eWfcKX2HxFl7fr0V++wrXXGsMs9A8hQEbVWtgYbWaOSkXN0ojmcUt1NFcb\nSPYLmOK/oUXVASEbuZAdIi+ByQ1EnIIAmYSKjRBDUQM8wc73Z9AvrjnhrvEHyrIN\nKyXeLnaCKj/r0s5sQA85SngnCWQbZsRQyHysfsQLwguG0SKFF9EfdNJiaoD8lLBo\nqvUQIYi8MXuVAB7O5EomJoZJe7KEeemsLhCnjTlKHcumjnAiRy5Y0rL6aFXgQkg0\nY4NWxMbsIWAplzh2qCs2jEd88mAUJnHkMzeOKhb1Q+tcmg6ZG6GmwT9fujsOjYrn\na/RTx83B1rRVRHHBFsEP4/ctVf2VdARz+RO+mIh5yZsPiqmRSKpHfbKgnkBpQlAj\nwVrzP9HYT11EXGFesLKRt6Oin0I5FkJ1Ji4w680XjeyZ4KInMY87OvQtltIyrZI9\nR9uY9EnpISGYch6kxbVw0GzdQdP/0mUnYlIeWwyvsXsWB/b3pZ9BiQuCMtlxoWlk\naRjWk9dWIZKFL2uhgeNeY5Wh3Qx9EFx8hnz9ohdaNBPB5BNO2qI61NedFrjYN9LF\nSfcGL7iATU1JQS4rDisnyjDikkTHL9B1u6sMrTsoaqi9Dl5b0gC8RnPVnJItasMN\n9HcW8Pfo2Ava4ler7oU47jUCAwEAAQ==\n-----END PUBLIC KEY-----"
2 changes: 1 addition & 1 deletion server/.env.local.online-auth
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DEBUG=True
SECRET_KEY=I_AM_A_DUMMY_KEY_CHANGE_ME
DATABASE_URL=sqlite:///db.sqlite3
DATABASE_URL=postgres://devuser:[email protected]/devdb
SUPERUSER_USERNAME=admin
SUPERUSER_PASSWORD=admin
ALLOWED_HOSTS=*
Expand Down
12 changes: 12 additions & 0 deletions server/reset_db_postgresql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
while getopts n: flag; do
case "${flag}" in
n) CONTAINER_NAME=${OPTARG} ;;
esac
done

CONTAINER_NAME="${CONTAINER_NAME:-postgreserver}"

docker container stop $CONTAINER_NAME
sh run_dev_postgresql.sh -n $CONTAINER_NAME
sleep 6
python manage.py migrate
19 changes: 19 additions & 0 deletions server/run_dev_postgresql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# we should frequently check to ensure that the postgres version
# matches the one we use in production
# NOTE: postgresql docker images show vulnerabilities, but we are using it for dev.
# Also the vulnerabilities don't affect how the container is primarily used.

while getopts n: flag; do
case "${flag}" in
n) CONTAINER_NAME=${OPTARG} ;;
esac
done

CONTAINER_NAME="${CONTAINER_NAME:-postgreserver}"

docker run -d --name $CONTAINER_NAME \
-p 127.0.0.1:5432:5432 \
-e POSTGRES_USER=devuser \
-e POSTGRES_PASSWORD=devpassword \
-e POSTGRES_DB=devdb \
postgres:14.10-alpine3.17
2 changes: 1 addition & 1 deletion server/setup-dev-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if [ "$RESET_DB" -eq 1 ]
then
# Clean DB for a fresh start
echo "Cleaning DB as RESET_DB flag is enabled"
rm db.sqlite3
sh reset_db.sh
fi

if [ "$DEPLOY" -eq 0 ]
Expand Down
Loading