diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed41256..5cfeb7e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,8 +5,25 @@ jobs: build: name: Execute tests runs-on: ubuntu-latest + + services: + postgres: + image: postgres:17 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test_db + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + env: DJANGO_SETTINGS_MODULE: pythonie.settings.tests + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db + steps: - uses: actions/checkout@v2 - name: Set Up Python 3.12 @@ -16,7 +33,7 @@ jobs: - name: Install the dependencies run: | python -m pip install --upgrade pip setuptools uv - python -m uv pip install -r requirements/main.txt -r requirements/dev.txt + python -m uv pip install -r requirements/main.txt -r requirements/dev.txt -r requirements/production.txt - name: Run the tests run: | python pythonie/manage.py test pythonie --verbosity=2 diff --git a/pythonie/pythonie/settings/base.py b/pythonie/pythonie/settings/base.py index cf463f7..abdd645 100644 --- a/pythonie/pythonie/settings/base.py +++ b/pythonie/pythonie/settings/base.py @@ -43,6 +43,7 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.contrib.postgres", "compressor", "taggit", "modelcluster", diff --git a/pythonie/pythonie/settings/tests.py b/pythonie/pythonie/settings/tests.py index aa6c9cb..6bb5e72 100644 --- a/pythonie/pythonie/settings/tests.py +++ b/pythonie/pythonie/settings/tests.py @@ -10,13 +10,17 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" -# SQLite (simplest install) -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": join(PROJECT_ROOT, "db.sqlite3"), +# Use PostgreSQL if DATABASE_URL is set (for CI), otherwise use SQLite (for local tests) +if os.getenv("DATABASE_URL"): + DATABASES = {"default": dj_database_url.config(conn_max_age=500)} +else: + # SQLite (simplest install for local development) + DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": join(PROJECT_ROOT, "db.sqlite3"), + } } -} LOGGING.update( { diff --git a/requirements/dev.txt b/requirements/dev.txt index 5209d41..ab0ca7f 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -24,7 +24,7 @@ defusedxml==0.7.1 # via # -c requirements/main.txt # py-serializable -django==5.2.9 +django==6.0 # via # -c requirements/main.txt # django-debug-toolbar diff --git a/requirements/main.in b/requirements/main.in index 7bb8227..1b3aafe 100644 --- a/requirements/main.in +++ b/requirements/main.in @@ -15,6 +15,7 @@ django-storages django-taggit gunicorn pandas +psycopg[binary] pydantic python-dateutil pytz diff --git a/requirements/main.txt b/requirements/main.txt index d165fbf..656a368 100644 --- a/requirements/main.txt +++ b/requirements/main.txt @@ -32,7 +32,7 @@ dj-database-url==3.0.1 # via -r requirements/main.in dj-static==0.0.6 # via -r requirements/main.in -django==5.2.9 +django==6.0 # via # -r requirements/main.in # dj-database-url @@ -123,6 +123,10 @@ pillow==12.0.0 # wagtail pillow-heif==1.1.1 # via willow +psycopg==3.3.2 + # via -r requirements/main.in +psycopg-binary==3.3.2 + # via psycopg pydantic==2.12.5 # via -r requirements/main.in pydantic-core==2.41.5 @@ -167,6 +171,7 @@ typing-extensions==4.15.0 # beautifulsoup4 # django-stubs-ext # django-tasks + # psycopg # pydantic # pydantic-core # typing-inspection diff --git a/requirements/production.in b/requirements/production.in index a1fe1cc..df70576 100644 --- a/requirements/production.in +++ b/requirements/production.in @@ -1,4 +1,2 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile --output-file requirements/production.in requirements/production.txt --c main.txt -psycopg[binary] \ No newline at end of file +# production.in +-c main.txt \ No newline at end of file diff --git a/requirements/production.txt b/requirements/production.txt index 91dc57d..ccc6aaa 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -1,10 +1,2 @@ # This file was autogenerated by uv via the following command: # uv pip compile --output-file requirements/production.txt requirements/production.in -psycopg==3.2.13 - # via -r requirements/production.in -psycopg-binary==3.2.13 - # via psycopg -typing-extensions==4.15.0 - # via - # -c requirements/main.txt - # psycopg