Skip to content

Commit

Permalink
⬆️(backend) pin django to a version < 5
Browse files Browse the repository at this point in the history
Since Django 4.2, we have dropped the support of mysql < 8. We have
dropped the job on circleci for `test-back-mysql-5`. We have
updated in settings `STORAGES` configuration for staticfiles and
default file storage declaration.
  • Loading branch information
jonathanreveille committed May 13, 2024
1 parent 7a48859 commit 50ac3f9
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 124 deletions.
101 changes: 0 additions & 101 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,99 +246,6 @@ jobs:
name: upload files to crowdin
command: crowdin upload sources -c crowdin/config.yml

test-back-mysql-5:
docker:
- image: cimg/python:3.10
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
environment:
DJANGO_SETTINGS_MODULE: settings
DJANGO_CONFIGURATION: Test
DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly
PYTHONPATH: /home/circleci/fun/sandbox
RICHIE_ES_HOST: localhost
DB_ENGINE: django.db.backends.mysql
# The DB_HOST should match the host name and cannot be set from here
# where it will be escaped. See the test command instead:
# DB_HOST=${HOSTNAME}
DB_HOST:
DB_NAME: richie
DB_USER: fun
DB_PASSWORD: pass
DB_PORT: 3306
# services
- image: cimg/mysql:5.7
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: test_richie
MYSQL_USER: fun
MYSQL_PASSWORD: pass
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
- image: elasticsearch:7.14.0
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
environment:
discovery.type: single-node
- image: docker.io/bitnami/redis:6.0-debian-10
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
name: redis-primary
environment:
ALLOW_EMPTY_PASSWORD: yes
REDIS_REPLICATION_MODE: master
- image: docker.io/bitnami/redis-sentinel:6.0-debian-10
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
name: redis-sentinel
environment:
REDIS_MASTER_HOST: redis-primary
working_directory: ~/fun
steps:
- checkout
- restore_cache:
keys:
- v2-back-dependencies-{{ .Revision }}
# Attach the frontend production build
- attach_workspace:
at: ~/fun
- *install-libcairo2-dev
# While running tests, we need to make the /data directory writable for
# the circleci user
- run:
name: Create writable /data
command: |
sudo mkdir /data && \
sudo chown circleci:circleci /data
# Run back-end (Django) test suite
#
# Nota bene:
#
# 1. to run the django test suite, we need to ensure that both MySQL and
# ElasticSearch services are up and ready. To achieve this, we wrap the
# pytest command execution with dockerize, a tiny tool installed in the
# CircleCI image. In our case, dockerize will wait up to one minute
# that both the database and elastisearch containers opened their
# expected tcp port (3306 and 9200 resp.).
# 2. We should avoid using localhost for the DB_HOST with MySQL as the
# client will try to use a local socket (_e.g._
# `/var/run/mysqld/mysqld.sock`) instead of the database host and port
# ¯\_(ツ)_/¯.
- run:
name: Run tests
command: |
DB_HOST=${HOSTNAME} dockerize \
-wait tcp://${HOSTNAME}:3306 \
-wait tcp://${HOSTNAME}:9200 \
-timeout 60s \
~/.local/bin/pytest
test-back-mysql-8:
docker:
- image: cimg/python:3.10
Expand Down Expand Up @@ -1082,13 +989,6 @@ workflows:
filters:
tags:
only: /.*/
- test-back-mysql-5:
requires:
- build-back
- build-front-production
filters:
tags:
only: /.*/
- test-back-mysql-8:
requires:
- build-back
Expand Down Expand Up @@ -1139,7 +1039,6 @@ workflows:
- package-back:
requires:
- test-front
- test-back-mysql-5
- test-back-mysql-8
- test-back-postgresql
- test-back-postgresql-es6
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## Changed

- Update configuration setting `STATICFILES_STORAGE` and
`DEFAULT_FILE_STORAGE` with `STORAGES` dictionary configuration
- Pin Django version < 5 and dropped support for mysql version < 5
- Upgrade to Django 4.1 version
- Upgrade to Django 4.0 version and postgres to version 12 in
docker compose file
Expand Down
30 changes: 16 additions & 14 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ $ make migrate

## Unreleased

- Dropped support for postgres version < 12
- Dropped support for MySQL version < 8
- Add new `dashboard-splitted-card` theme scheme
```
dashboard-splitted-card: (
Expand Down Expand Up @@ -45,7 +47,7 @@ $ make migrate
`scss/trumps/_bootstrap.scss` file. You have to import it in your `_main.scss` file.
```scss
// ...

// Import bootstrap reset
@import 'richie-education/scss/trumps/bootstrap';
```
Expand All @@ -67,7 +69,7 @@ $ make migrate
the urls module of your app.
```python
from richie.apps.courses.urls import redirects_urlpatterns as courses_redirects_urlpatterns

urlpatterns += [
re_path(r"^redirects/", include([*courses_redirects_urlpatterns])),
]
Expand All @@ -81,20 +83,20 @@ $ make migrate
@import '@openfun/cunningham-react/dist/style';
@import 'richie-education/scss/vendors/cunningham-tokens';
@import 'richie-education/scss/vendors/css/cunningham-tokens';

// Override default Richie settings variables
@import 'richie-education/scss/colors/palette';
// ...
```
`yarn build-theme` command generates tokens files `scss/vendors/cunningham-tokens.scss` and
`scss/vendors/css/cunningham-tokens.css`. `$palette` variable is now deprecated and will be
removed in the next major release. Currently this is only an alias to the
`map.get($theme, colors)` ($theme is a sass variable exported by `cunninghtam-tokens.scss`).
- Components `CourseGlimpse` and `CourseGlimpseList` has been moved from `js/widgets/Search` folder to
`map.get($theme, colors)` ($theme is a sass variable exported by `cunninghtam-tokens.scss`).
- Components `CourseGlimpse` and `CourseGlimpseList` has been moved from `js/widgets/Search` folder to
`js/components` folder. Update your overrides.json and path in your custom scss files accordingly.
- `js/utils/test/factories.ts` have been split into multiple files: joanie.ts, richie.ts and
- `js/utils/test/factories.ts` have been split into multiple files: joanie.ts, richie.ts and
reactQuery.ts. Update your import accordingly.

## 2.20.1 to 2.21.0

- Frontend folder architecture has been totally reworked. If you have overridden
Expand Down Expand Up @@ -141,7 +143,7 @@ $ make migrate

## 2.18.x to 2.19.x

- In `_theme.scss`, `course-detail` scheme now accepts two new optional properties to style
- In `_theme.scss`, `course-detail` scheme now accepts two new optional properties to style
the course run CTA and feedback color in the course detail subheader:
- `subheader-run-cta`
- `subheader-run-feedback-color`
Expand Down Expand Up @@ -179,7 +181,7 @@ $ make migrate
"JS_COURSE_REGEX": r"^.*/api/v1.0/(course-runs|products)/([^/]*)/?$",
# A list of course run properties to not update
"COURSE_RUN_SYNC_NO_UPDATE_FIELDS": [],
# The synchronization mode ("manual", "sync_to_public" or "sync_to_draft")
# The synchronization mode ("manual", "sync_to_public" or "sync_to_draft")
"DEFAULT_COURSE_RUN_SYNC_MODE": "sync_to_public",
}
```
Expand Down Expand Up @@ -224,7 +226,7 @@ $ make migrate
- `_main.scss`
```diff
+ @import 'richie-education/scss/tools/utils';

+ @import 'richie-education/js/components/AddressesManagement/styles';
+ @import 'richie-education/js/components/CourseProductCertificateItem/styles';
+ @import 'richie-education/js/components/CourseProductCourseRuns/styles';
Expand All @@ -239,7 +241,7 @@ $ make migrate
...
+ @import 'richie-education/scss/components/templates/richie/multiple-columns';
```

- Only if you have overridden `_palette.scss`:
```diff
$palette = {
Expand Down Expand Up @@ -335,7 +337,7 @@ $ make migrate

## 2.11.x to 2.12.x

- If you overrode `course-detail` theme within `theme.scss`, you have to add these four
- If you overrode `course-detail` theme within `theme.scss`, you have to add these four
new properties
```scss
view-more-runs-color: r-color('firebrick6'),
Expand All @@ -348,8 +350,8 @@ $ make migrate

- If you overrode `richie/base.html`, the `branding_footer` template block has been renamed to
`body_footer_brand` and the link was integrated in the block so it can be customized.
- The file `_colors.scss` has been divided into `_palette.scss` for the palette,
`_gradients.scss`, `_schemes.scss` and `_theme.scss`. Those files are now located in a
- The file `_colors.scss` has been divided into `_palette.scss` for the palette,
`_gradients.scss`, `_schemes.scss` and `_theme.scss`. Those files are now located in a
dedicated folder `colors`.

## 2.9.x to 2.10.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ class Base(StyleguideMixin, DRFMixin, RichieCoursesConfigurationMixin, Configura
# For static files, we want to use a backend that includes a hash in
# the filename, that is calculated from the file content, so that browsers always
# get the updated version of each file.
STATICFILES_STORAGE = values.Value("base.storage.CDNManifestStaticFilesStorage")
STORAGES = {
"staticfiles": {
"BACKEND": values.Value("base.storage.CDNManifestStaticFilesStorage")
}
}

AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)

Expand Down Expand Up @@ -719,7 +723,11 @@ class Development(Base):
class Test(Base):
"""Test environment settings"""

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
STORAGES = {
"staticfile": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"
}
}


class ContinuousIntegration(Test):
Expand All @@ -746,7 +754,7 @@ class Production(Base):
SECURE_CONTENT_TYPE_NOSNIFF = True
SESSION_COOKIE_SECURE = True

DEFAULT_FILE_STORAGE = "base.storage.MediaStorage"
STORAGES = {"default": {"BACKEND": "base.storage.MediaStorage"}}
AWS_DEFAULT_ACL = None
AWS_LOCATION = "media"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"arrow",
"Django==4.1",
"Django<5",
"djangocms-file",
"djangocms-googlemap",
"djangocms-link",
Expand Down
8 changes: 5 additions & 3 deletions sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,11 @@ class Production(Base):
# For static files in production, we want to use a backend that includes a hash in
# the filename, that is calculated from the file content, so that browsers always
# get the updated version of each file.
STATICFILES_STORAGE = (
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
)
STORAGES = {
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"
}
}

# For more details about CMS_CACHE_DURATION, see :
# http://docs.django-cms.org/en/latest/reference/configuration.html#cms-cache-durations
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/courses/test_admin_form_course_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_admin_form_course_run_choices_languages(self):
CourseRunAdminForm.request = request

form = CourseRunAdminForm()
self.assertEqual(form.fields["languages"].choices[32][1], "German")
self.assertEqual(form.fields["languages"].choices[33][1], "German")

with translation.override("fr"):
form = CourseRunAdminForm()
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/search/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run_commit_hooks():
Run commit hooks as if the database transaction had been successful.
"""
while connection.run_on_commit:
_sids, func = connection.run_on_commit.pop(0)
_sids, func, _published_value = connection.run_on_commit.pop(0)
func()

def test_signals_courses_publish(self, mock_bulk, *_):
Expand Down

0 comments on commit 50ac3f9

Please sign in to comment.