diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5da284c3..895e88b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,13 +28,28 @@ jobs: SECRET_KEY: BetPHpGoUXUwjaAXm6ArIhV95xLdDZtu8QEGnNXY3eTknIkD AUTH_STAFF_EMAIL_DOMAINS: mozillafoundation.org steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: - python-version: 3.7 - - name: Install Python Dependencies + python-version: 3.11 + - name: Write .env file with DATABASE_URL for CI run: | - pip install -r requirements.txt -r dev-requirements.txt + echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/pulseapi" > .env + # Pillow requires libjpeg-dev, zlib1g-dev, etc. to build from source + - name: Install system dependencies for Pillow build + run: | + sudo apt-get update + sudo apt-get install -y libjpeg-dev zlib1g-dev libpng-dev + # setuptools >=66 removed `convert_path`, which breaks django-allauth 0.48.0 + # See https://github.com/pypa/setuptools/issues/3772 + - name: Install setuptools 65.5.1 for compatibility with django-allauth + run: pip install "setuptools==65.5.1" + - name: Install wheel for building packages like cffi + run: pip install wheel + - name: Install Python Dependencies (no build isolation) + run: | + pip install --no-binary psycopg2-binary psycopg2-binary + pip install --no-build-isolation -r requirements.txt -r dev-requirements.txt python manage.py migrate - name: Run Tests run: | diff --git a/pulseapi/settings.py b/pulseapi/settings.py index c339adb5..ceb4c878 100644 --- a/pulseapi/settings.py +++ b/pulseapi/settings.py @@ -240,17 +240,25 @@ def show_toolbar(request): # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - +# Try to get DATABASE_URL from the environment (e.g. .env file or CI env vars) DATABASE_URL = env('DATABASE_URL') -if DATABASE_URL is not None: - DATABASES['default'].update(dj_database_url.config()) +if DATABASE_URL: + # If DATABASE_URL is provided, use it to configure the default database + # This will typically be a Postgres database in production or CI + DATABASES = { + 'default': dj_database_url.parse(DATABASE_URL) + } +else: + # If DATABASE_URL is not set, fall back to using SQLite + # This is a good default for local development environments + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } + } + # Password validation diff --git a/requirements.in b/requirements.in index a4b75fd5..b393aae3 100644 --- a/requirements.in +++ b/requirements.in @@ -19,4 +19,5 @@ Pillow==8.3.2 protobuf==3.12.2 psycopg2-binary requests +setuptools==65.5.1 whitenoise diff --git a/requirements.txt b/requirements.txt index a5b586c5..517c3969 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # -# pip-compile +# pip-compile requirements.in # boto3==1.16.26 # via -r requirements.in diff --git a/runtime.txt b/runtime.txt index 32a8d83a..cf3b8042 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.7.8 +python-3.11.8