Skip to content

Commit

Permalink
feat: upgrade to Django 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gsueros authored and UsamaSadiq committed Oct 16, 2023
1 parent 2c68e9e commit d8b01ba
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 57 deletions.
9 changes: 0 additions & 9 deletions .ci/docker-compose-ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
version: "2"

services:
mysql57:
image: mysql:5.7
container_name: mysql57
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
MYSQL_ROOT_PASSWORD: "password"
MYSQL_DATABASE: "discovery"

mysql80:
image: mysql:8.0
container_name: mysql80
Expand Down Expand Up @@ -50,7 +42,6 @@ services:
- ../course_discovery/assets:/edx/var/discovery/staticfiles
command: tail -f /dev/null
depends_on:
- "mysql57"
- "mysql80"
- "es"
- "memcached"
Expand Down
8 changes: 2 additions & 6 deletions .ci/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ set -e

apt-get update
apt-get install -y --no-install-recommends firefox gettext
if [ "$TOXENV" == "py38-django42" ]
then
make requirements_dj42
else
make requirements
fi
make requirements

make test
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ jobs:
fail-fast: false
matrix:
python-version: ['py38']
django-version: ['django32', 'django42']
db-version: ['mysql57', 'mysql80']
django-version: ['django42']
db-version: ['mysql80']
pytest-split-group: [1, 2, 3, 4, 5, 6]
status: ['']
exclude:
- django-version: "django42"
db-version: "mysql57"

steps:
- uses: actions/checkout@v3
Expand All @@ -32,7 +29,7 @@ jobs:
# See https://github.com/actions/toolkit/issues/399
continue-on-error: ${{ matrix.status == 'ignored' }}
- name: Upload coverage
if: matrix.db-version == 'mysql57' # TODO: Remove this condition when removing 'mysql57' db-version.
if: matrix.db-version == 'mysql80'
uses: actions/upload-artifact@v2
with:
name: coverage${{ matrix.pytest-split-group }}
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ requirements.python: ## Install Python requirements for local development.

requirements: requirements.js requirements.python ## Install Python and JS requirements for local development

requirements.python_dj42: ## Install Python requirements for Django 4.2 env
pip install -r requirements/local.txt -r requirements/django42.txt

requirements_dj42: requirements.js requirements.python_dj42 ## Install Python and JS requirements for Django 4.2 env

production-requirements: ## Install Python and JS requirements for production
pip install -r requirements.txt
npm install --production
Expand All @@ -60,6 +55,8 @@ $(COMMON_CONSTRAINTS_TXT):
upgrade: $(COMMON_CONSTRAINTS_TXT)
sed 's/django-simple-history==3.0.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
pip install -q -r requirements/pip_tools.txt
pip-compile --allow-unsafe --upgrade -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
Expand All @@ -72,9 +69,6 @@ upgrade: $(COMMON_CONSTRAINTS_TXT)
grep -e "^django==" requirements/local.txt > requirements/django.txt
sed -i.tmp '/^[dD]jango==/d' requirements/local.txt
rm -rf requirements/local.txt.tmp
grep -e "^django-admin-sortable2==" requirements/local.txt >> requirements/django.txt
sed -i.tmp "/^django-admin-sortable2==/d" requirements/local.txt
rm -rf requirements/local.txt.tmp
chmod a+rw requirements/*.txt

test: clean ## Run tests and generate coverage report
Expand Down
2 changes: 2 additions & 0 deletions course_discovery/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,3 +773,5 @@
SIMPLE_HISTORY_DATE_INDEX = False

CSRF_TRUSTED_ORIGINS_WITH_SCHEME = [] # just for Django 4.2 upgrade

USE_DEPRECATED_PYTZ = True
2 changes: 1 addition & 1 deletion requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


# using LTS django version
Django<4.0


# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
Expand Down
9 changes: 3 additions & 6 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Stay on an LTS release
django<4.0

# We are creating a local copy of the common constraints file and override/remove the global constraint which we don't need.
# This approach is used temporarily and will be improved in https://openedx.atlassian.net/browse/BOM-2721
# This file contains all common constraints for edx-repos
-c common_constraints.txt

# Stay on an LTS release
django<4.3

# Elasticsearch upgrades need to be done in lockstep across Open edX
elasticsearch>=7.8,<7.14
elasticsearch-dsl>=7.2,<8.0
Expand All @@ -23,9 +23,6 @@ algoliasearch<2.0.0
# Remove this pin once newer stable version is released
authlib==1.0.0rc1

# The latest version require Django 4.0, remove once we have upgraded to Django 4.0
django-admin-sortable2<2.0.0

# The latest versions of django-stdimage has breaking changes
# Remove this pin after fixing them.
django-stdimage<=5.3.0
Expand Down
3 changes: 1 addition & 2 deletions requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
django==3.2.22
django-admin-sortable2==1.0.4
django==4.2.6
2 changes: 0 additions & 2 deletions requirements/django42.txt

This file was deleted.

8 changes: 3 additions & 5 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# celery
# django
# kombu
bcrypt==4.0.1
# via paramiko
Expand Down Expand Up @@ -171,7 +172,6 @@ distlib==0.3.7
distro==1.8.0
# via docker-compose
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# algoliasearch-django
Expand Down Expand Up @@ -218,9 +218,8 @@ distro==1.8.0
# social-auth-app-django
# taxonomy-connector
# xss-utils
# via
# -c requirements/constraints.txt
# -r requirements/base.in
django-admin-sortable2==2.1.10
# via -r requirements/base.in
django-appconf==1.0.5
# via django-compressor
django-autocomplete-light==3.9.7
Expand Down Expand Up @@ -737,7 +736,6 @@ pytz==2023.3.post1
# via
# -r requirements/base.in
# babel
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down
11 changes: 4 additions & 7 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# celery
# django
# kombu
beautifulsoup4==4.12.2
# via
Expand Down Expand Up @@ -117,9 +118,8 @@ defusedxml==0.7.1
# djangorestframework-xml
# python3-openid
# social-auth-core
django==3.2.22
django==4.2.6
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# algoliasearch-django
Expand Down Expand Up @@ -164,10 +164,8 @@ django==3.2.22
# social-auth-app-django
# taxonomy-connector
# xss-utils
django-admin-sortable2==1.0.4
# via
# -c requirements/constraints.txt
# -r requirements/base.in
django-admin-sortable2==2.1.10
# via -r requirements/base.in
django-appconf==1.0.5
# via django-compressor
django-autocomplete-light==3.9.7
Expand Down Expand Up @@ -545,7 +543,6 @@ python3-openid==3.2.0
pytz==2023.3.post1
# via
# -r requirements/base.in
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38-django{32, 42}
envlist = py38-django{42}
skipsdist=true

[pytest]
Expand All @@ -8,8 +8,7 @@ testpaths = course_discovery/apps

[testenv]
deps =
django32: -r requirements/django.txt
django42: -r requirements/django42.txt
django42: -r requirements/django.txt
-r{toxinidir}/requirements/local.txt
passenv =
CONN_MAX_AGE
Expand All @@ -24,8 +23,7 @@ passenv =
DB_ENGINE
CACHE_BACKEND
PYTEST_SPLIT_GROUP

whitelist_externals =
allowlist_externals =
make
commands =
make clean static
Expand Down

0 comments on commit d8b01ba

Please sign in to comment.