mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
Merge pull request #945 from simple-login/run-migration-in-ci
Run migration in ci
This commit is contained in:
commit
65bc6c7fdf
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -77,6 +77,10 @@ jobs:
|
|||||||
poetry run black --check .
|
poetry run black --check .
|
||||||
poetry run flake8
|
poetry run flake8
|
||||||
|
|
||||||
|
- name: Run db migration
|
||||||
|
run: |
|
||||||
|
CONFIG=tests/test.env poetry run alembic upgrade head
|
||||||
|
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
poetry run pytest
|
poetry run pytest
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
# Run tests
|
# Run tests
|
||||||
|
|
||||||
|
# Delete the test DB if it isn't properly removed
|
||||||
docker rm -f sl-test-db
|
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
|
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 the DB container starts
|
# the time for the test DB container to start
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
|
# migrate the DB to the latest version
|
||||||
|
CONFIG=tests/test.env poetry run alembic upgrade head
|
||||||
|
|
||||||
|
# run test
|
||||||
poetry run pytest
|
poetry run pytest
|
||||||
|
|
||||||
|
# Delete the test DB
|
||||||
docker rm -f sl-test-db
|
docker rm -f sl-test-db
|
||||||
|
@ -9,7 +9,6 @@ os.environ["CONFIG"] = os.path.abspath(
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from app.db import Session, engine, connection
|
from app.db import Session, engine, connection
|
||||||
from app.models import Base
|
|
||||||
|
|
||||||
from psycopg2 import errors
|
from psycopg2 import errors
|
||||||
from psycopg2.errorcodes import DEPENDENT_OBJECTS_STILL_EXIST
|
from psycopg2.errorcodes import DEPENDENT_OBJECTS_STILL_EXIST
|
||||||
@ -34,8 +33,6 @@ with engine.connect() as conn:
|
|||||||
print(">>> pg_trgm can't be dropped, ignore")
|
print(">>> pg_trgm can't be dropped, ignore")
|
||||||
conn.execute("Rollback")
|
conn.execute("Rollback")
|
||||||
|
|
||||||
Base.metadata.create_all(engine)
|
|
||||||
|
|
||||||
add_sl_domains()
|
add_sl_domains()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user