CI: set db host for tests
All checks were successful
/ test (push) Successful in 25s
/ build (push) Successful in 6s

This commit is contained in:
phil 2024-12-08 05:57:04 +01:00
parent 4a54a815a0
commit 8bfb410ee1
4 changed files with 7 additions and 6 deletions

View file

@ -33,7 +33,7 @@ jobs:
run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps .
- name: Run tests (API call)
run: pytest -s tests/basic.py
run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py
build:
runs-on: container

View file

@ -31,4 +31,4 @@ jobs:
run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps .
- name: Run tests (API call)
run: pytest -s tests/basic.py
run: TREETRAIL_DB_HOST=treetrail-database pytest -s tests/basic.py

View file

@ -1,4 +1,4 @@
# Build: podman build -t code.philo.ydns.eu/philorg/treetrail-backend-base -f Containerfile.base
# Build: podman build -t code.philo.ydns.eu/philorg/treetrail-backend -f Containerfile
FROM code.philo.ydns.eu/philorg/treetrail-backend-deps

View file

@ -14,7 +14,7 @@ from treetrail.config import conf
logger = logging.getLogger(__name__)
CREATE_DB_TIMEOUT = 30
CREATE_DB_TIMEOUT = 10
engine = create_async_engine(
conf.db.get_sqla_url(),
@ -33,7 +33,7 @@ async def create_db(drop=False):
await conn.run_sync(SQLModel.metadata.drop_all)
await conn.run_sync(SQLModel.metadata.create_all)
logger.debug(f'Connect to database with config: {conf.db}')
logger.debug(f"Connect to database with config: {conf.db}")
while attempts > 0:
try:
await try_once()
@ -68,6 +68,7 @@ async def populate_init_db():
"""Populate the database for a fresh install"""
from sqlalchemy import text
from treetrail.security import create_user, add_role, add_user_role
logger.info("Populating initial database")
user = await create_user(username="admin", password="admin")
@ -76,7 +77,7 @@ async def populate_init_db():
async with db_session() as session:
for initial in initials:
await session.execute(text(initial))
logger.debug(f'Added map style {initial}')
logger.debug(f"Added map style {initial}")
await session.commit()