Skip to content

Commit

Permalink
feat!: upgrade to Django 4.2 LTS (#357)
Browse files Browse the repository at this point in the history
Co-authored-by: UsamaSadiq <[email protected]>
  • Loading branch information
awais786 and UsamaSadiq authored Oct 30, 2023
1 parent 7adac53 commit ae4ea9e
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 54 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ jobs:
max-parallel: 4
matrix:
python-version: ['py38']
django-version: ['django32', 'django42']
db-version: ['mysql57', 'mysql80']
# excluding mysql5.7 with Django 4.2 since Django 4.2 has
# dropped support for MySQL<8
exclude:
- django-version: 'django42'
db-version: 'mysql57'
django-version: ['django42']
db-version: ['mysql80']

steps:
- uses: actions/checkout@v2
- name: Start container
run: |
docker-compose -f .travis/docker-compose-travis.yml up -d
- name: Install Dependencies
- name: Install system packages
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "apt-get update && apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config"
Expand Down
11 changes: 0 additions & 11 deletions .travis/docker-compose-travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +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: ""
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_USER: "notes001"
MYSQL_PASSWORD: "secret"
MYSQL_DATABASE: "edx_notes_api"
mysql80:
image: mysql:8.0
container_name: mysql80
Expand Down Expand Up @@ -49,7 +39,6 @@ services:
- ..:/edx/app/edx_notes_api/edx_notes_api
command: tail -f /dev/null
depends_on:
- "mysql57"
- "mysql80"
- "es"
environment:
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,23 @@ develop: requirements test.requirements
piptools: ## install pinned version of pip-compile and pip-sync
pip install -r requirements/pip-tools.txt

define COMMON_CONSTRAINTS_TEMP_COMMENT
# This is a temporary solution to override the real common_constraints.txt\n# In edx-lint, until the pyjwt constraint in edx-lint has been removed.\n# See BOM-2721 for more details.\n# Below is the copied and edited version of common_constraints\n
endef
COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)"
echo "$(COMMON_CONSTRAINTS_TEMP_COMMENT)" | cat - $(@) > temp && mv temp $(@)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
upgrade: piptools $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# This is a temporary solution to override the real common_constraints.txt
# In edx-lint, until the pyjwt constraint in edx-lint has been removed.
# See BOM-271 for more details.
sed -i.'' 's/Django<4.0//g' requirements/common_constraints.txt
# Make sure to compile files after any other files they include!
pip-compile --upgrade -o requirements/travis.txt requirements/travis.in
pip-compile --upgrade --rebuild --allow-unsafe -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
Expand All @@ -76,6 +90,4 @@ upgrade: piptools ## update the requirements/*.txt files with the latest package
pip-compile --upgrade -o requirements/test.txt requirements/test.in
# Let tox control the Django version for tests
grep -e "^django==" requirements/base.txt > requirements/django.txt
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt

sed -i.'' '/^[dD]jango==/d' requirements/test.txt
17 changes: 8 additions & 9 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
asgiref==3.7.2
# via django
backports-zoneinfo==0.2.1
# via django
certifi==2023.7.22
# via
# elasticsearch
Expand All @@ -18,11 +20,11 @@ chardet==3.0.4
# via requests
click==8.1.7
# via edx-django-utils
cryptography==41.0.4
cryptography==41.0.5
# via pyjwt
django==3.2.22
django==4.2.6
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# django-cors-headers
# django-crum
Expand All @@ -34,10 +36,8 @@ django==3.2.22
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
django-cors-headers==3.14.0
# via
# -c requirements/constraints.txt
# -r requirements/base.in
django-cors-headers==4.3.0
# via -r requirements/base.in
django-crum==0.7.9
# via edx-django-utils
django-elasticsearch-dsl==7.4
Expand Down Expand Up @@ -76,7 +76,7 @@ edx-opaque-keys==2.5.1
# via edx-drf-extensions
elasticsearch==7.13.4
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# django-elasticsearch-dsl-drf
Expand Down Expand Up @@ -131,7 +131,6 @@ python-dateutil==2.4.0
# elasticsearch-dsl
pytz==2023.3.post1
# via
# django
# djangorestframework
# drf-yasg
pyyaml==6.0.1
Expand Down
32 changes: 32 additions & 0 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is a temporary solution to override the real common_constraints.txt
# In edx-lint, until the pyjwt constraint in edx-lint has been removed.
# See BOM-2721 for more details.
# Below is the copied and edited version of common_constraints

# A central location for most common version constraints
# (across edx repos) for pip-installation.
#
# Similar to other constraint files this file doesn't install any packages.
# It specifies version constraints that will be applied if a package is needed.
# When pinning something here, please provide an explanation of why it is a good
# idea to pin this package across all edx repos, Ideally, link to other information
# that will help people in the future to remove the pin when possible.
# Writing an issue against the offending project and linking to it here is good.
#
# Note: Changes to this file will automatically be used by other repos, referencing
# this file from Github directly. It does not require packaging in edx-lint.


# using LTS django version


# 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
elasticsearch<7.14.0

# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected
django-simple-history==3.0.0

# tox>4.0.0 isn't yet compatible with many tox plugins, causing CI failures in almost all repos.
# Details can be found in this discussion: https://github.com/tox-dev/tox/discussions/1810
tox<4.0.0
11 changes: 7 additions & 4 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version constraints for pip installation.
# Version constraints for pip-installation.
#
# This file doesn't install any packages. It specifies version constraints
# that will be applied if a package is needed.
Expand All @@ -8,8 +8,11 @@
# pin when possible. Writing an issue against the offending project and
# linking to it here is good.

# This file contains all common constraints for edx-repos
-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
-c common_constraints.txt

# Keeping Django to latest Django 4.2 LTS
# This constraint can be removed once the global constraint has been updated
Django<4.3

astroid==1.6.6
requests==2.25.0
Expand All @@ -21,4 +24,4 @@ python-dateutil==2.4.0
newrelic==4.8.0.110
more-itertools==5.0.0
pylint==1.5.0
django-cors-headers==3.14.0

2 changes: 1 addition & 1 deletion requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==3.2.22
django==4.2.6
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ wheel==0.41.2
# via -r requirements/pip.in

# The following packages are considered to be unsafe in a requirements file:
pip==23.3
pip==23.3.1
# via -r requirements/pip.in
setuptools==68.2.2
# via -r requirements/pip.in
25 changes: 13 additions & 12 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ astroid==1.6.6
# -c requirements/constraints.txt
# -r requirements/test.in
# pylint
backports-zoneinfo==0.2.1
# via
# -r requirements/base.txt
# django
certifi==2023.7.22
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -41,7 +45,7 @@ coverage[toml]==7.3.2
# via
# -r requirements/test.in
# pytest-cov
cryptography==41.0.4
cryptography==41.0.5
# via
# -r requirements/base.txt
# pyjwt
Expand All @@ -52,7 +56,7 @@ diff-cover==7.7.0
distlib==0.3.7
# via virtualenv
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.txt
# django-cors-headers
# django-crum
Expand All @@ -64,10 +68,8 @@ distlib==0.3.7
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
django-cors-headers==3.14.0
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
django-cors-headers==4.3.0
# via -r requirements/base.txt
django-crum==0.7.9
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -115,7 +117,7 @@ edx-opaque-keys==2.5.1
# edx-drf-extensions
elasticsearch==7.13.4
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.txt
# django-elasticsearch-dsl-drf
Expand All @@ -130,7 +132,7 @@ exceptiongroup==1.1.3
# via pytest
factory-boy==3.3.0
# via -r requirements/test.in
faker==19.11.0
faker==19.12.0
# via factory-boy
filelock==3.12.4
# via
Expand Down Expand Up @@ -222,7 +224,7 @@ pynacl==1.5.0
# via
# -r requirements/base.txt
# edx-django-utils
pytest==7.4.2
pytest==7.4.3
# via
# -r requirements/test.in
# pytest-cov
Expand All @@ -242,7 +244,6 @@ python-slugify==8.0.1
pytz==2023.3.post1
# via
# -r requirements/base.txt
# django
# djangorestframework
# drf-yasg
pyyaml==6.0.1
Expand Down Expand Up @@ -291,7 +292,7 @@ tomli==2.0.1
# tox
tox==3.28.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/common_constraints.txt
# -r requirements/test.in
typing-extensions==4.8.0
# via
Expand All @@ -308,7 +309,7 @@ urllib3==1.26.18
# -r requirements/base.txt
# elasticsearch
# requests
virtualenv==20.24.5
virtualenv==20.24.6
# via tox
wrapt==1.15.0
# via astroid
4 changes: 2 additions & 2 deletions requirements/travis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ tomli==2.0.1
# via tox
tox==3.28.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/common_constraints.txt
# -r requirements/travis.in
# tox-battery
tox-battery==0.6.2
# via -r requirements/travis.in
virtualenv==20.24.5
virtualenv==20.24.6
# via tox
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[tox]
envlist = py38-django{32, 42}
envlist = py38-django{42}
skipsdist = true

[testenv]
deps =
django32: Django>=3.2,<4.0
django42: Django>=4.2,<4.3
-r {toxinidir}/requirements/test.txt
passenv =
Expand Down

0 comments on commit ae4ea9e

Please sign in to comment.