fix: configure CI database connection properly

- Add dotenv loading to Django settings
- Update CI workflow to use correct environment variables
- Set POSTGRES_* variables instead of DATABASE_URL
- Add environment variables to all Django management commands
- Fixes CI test failures due to database connection issues
This commit is contained in:
Stiftung Development
2025-09-06 18:47:23 +02:00
parent dcc91b9f49
commit 35ba089a84
64 changed files with 7040 additions and 1419 deletions

View File

@@ -58,28 +58,64 @@ jobs:
- name: Set up environment
run: |
cp env-template.txt .env
echo "DEBUG=True" >> .env
echo "SECRET_KEY=test-secret-key-for-ci" >> .env
echo "DATABASE_URL=postgresql://postgres:postgres@localhost:5432/test_stiftung" >> .env
echo "DJANGO_DEBUG=1" >> .env
echo "DJANGO_SECRET_KEY=test-secret-key-for-ci" >> .env
echo "POSTGRES_DB=test_stiftung" >> .env
echo "POSTGRES_USER=postgres" >> .env
echo "POSTGRES_PASSWORD=postgres" >> .env
echo "DB_HOST=localhost" >> .env
echo "DB_PORT=5432" >> .env
echo "REDIS_URL=redis://localhost:6379/0" >> .env
- name: Run migrations
working-directory: ./app
env:
DJANGO_DEBUG: "1"
DJANGO_SECRET_KEY: "test-secret-key-for-ci"
POSTGRES_DB: "test_stiftung"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
DB_HOST: "localhost"
DB_PORT: "5432"
run: |
python manage.py migrate
- name: Run tests
working-directory: ./app
env:
DJANGO_DEBUG: "1"
DJANGO_SECRET_KEY: "test-secret-key-for-ci"
POSTGRES_DB: "test_stiftung"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
DB_HOST: "localhost"
DB_PORT: "5432"
run: |
python manage.py test
- name: Check Django configuration
working-directory: ./app
env:
DJANGO_DEBUG: "1"
DJANGO_SECRET_KEY: "test-secret-key-for-ci"
POSTGRES_DB: "test_stiftung"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
DB_HOST: "localhost"
DB_PORT: "5432"
run: |
python manage.py check --deploy
- name: Collect static files
working-directory: ./app
env:
DJANGO_DEBUG: "1"
DJANGO_SECRET_KEY: "test-secret-key-for-ci"
POSTGRES_DB: "test_stiftung"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
DB_HOST: "localhost"
DB_PORT: "5432"
run: |
python manage.py collectstatic --noinput