From c55325b478fe9366507c7145f98b055cf52f78ee Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:51:17 -0500 Subject: [PATCH 1/6] feat: Switch from PostgreSQL to MySQL (for easier co-location with WordPress) --- .github/workflows/ci.yml | 19 ++++++++++--------- README.rst | 2 +- ictcg/settings.py | 10 +--------- requirements.in | 2 +- requirements.txt | 4 ++-- requirements_dev.in | 1 - requirements_dev.txt | 6 ++---- 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00ef204..deb1afd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,9 @@ jobs: env DJANGO_ENV=production python manage.py collectstatic --noinput -v2 - name: Run checks and tests env: + # https://github.com/open-contracting/digitalbuying/issues/2 PYTHONWARNINGS: error,ignore::DeprecationWarning:django.utils.version,ignore::DeprecationWarning:django.http.request,ignore::DeprecationWarning:willow.image,ignore::DeprecationWarning:l18n.translation,ignore:::wagtail.core.signals,ignore:::wagtail.documents.models,ignore:::wagtail.admin.signals,ignore:::wagtail.core.models,ignore:::wagtailtrans.urls.translations,ignore:::wagtailtrans.wagtail_hooks - DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres + DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports[3306] }}/mysql shell: bash run: | ./manage.py migrate @@ -38,14 +39,14 @@ jobs: coverage run --source ictcg manage.py test - uses: coverallsapp/github-action@v2 services: - postgres: - image: postgres:15 + mysql: + image: mysql:8.0 env: - POSTGRES_PASSWORD: postgres + MYSQL_ROOT_PASSWORD: root options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=5 ports: - - 5432/tcp + - 3306/tcp diff --git a/README.rst b/README.rst index fc7d274..9ba1c4b 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ Setup .. code:: bash - createdb digitalbuyingguide + mysql -u root -e "create database digitalbuying" npm install pip install -r requirements.txt ./manage.py migrate diff --git a/ictcg/settings.py b/ictcg/settings.py index e5b1fc9..d9a6efe 100644 --- a/ictcg/settings.py +++ b/ictcg/settings.py @@ -64,8 +64,6 @@ # https://docs.wagtail.org/en/stable/reference/contrib/legacy_richtext.html "wagtail.contrib.legacy.richtext", "wagtail.core", - # https://docs.wagtail.org/en/v2.14.2/reference/contrib/postgres_search.html#postgres-search - "wagtail.contrib.postgres_search", # https://docs.wagtail.org/en/stable/reference/contrib/settings.html "wagtail.contrib.settings", # https://docs.wagtail.org/en/v5.2.7/reference/contrib/modeladmin/index.html @@ -129,7 +127,7 @@ # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { - "default": dj_database_url.config(default="postgresql:///digitalbuyingguide?application_name=digitalbuyingguide"), + "default": dj_database_url.config(default="mysql://root@127.0.0.1/digitalbuying"), } @@ -287,12 +285,6 @@ # https://docs.wagtail.org/en/stable/releases/3.0.html#other-features BASE_URL = "https://digitalbuying.open-contracting.org" -WAGTAILSEARCH_BACKENDS = { - "default": { - "BACKEND": "wagtail.contrib.postgres_search.backend", - }, -} - # https://wagtailtrans.readthedocs.io/en/latest/settings.html WAGTAILTRANS_HIDE_TRANSLATION_TREES = True diff --git a/requirements.in b/requirements.in index e4535e9..d05cd86 100644 --- a/requirements.in +++ b/requirements.in @@ -2,7 +2,7 @@ dj-database-url django django-modelcluster django-taggit -psycopg2 +mysqlclient redis[hiredis] sentry-sdk wagtail==2.11.9 diff --git a/requirements.txt b/requirements.txt index eeab3e7..45c7b2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,12 +48,12 @@ idna==3.10 # via requests l18n==2021.3 # via wagtail +mysqlclient==2.2.7 + # via -r requirements.in openpyxl==3.1.5 # via tablib pillow==9.5.0 # via wagtail -psycopg2==2.9.10 - # via -r requirements.in pytz==2024.2 # via # django diff --git a/requirements_dev.in b/requirements_dev.in index 65c5558..13e2a80 100644 --- a/requirements_dev.in +++ b/requirements_dev.in @@ -1,3 +1,2 @@ -r requirements.txt coverage -psycopg2-binary diff --git a/requirements_dev.txt b/requirements_dev.txt index 48192e8..7b10f12 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -75,6 +75,8 @@ l18n==2021.3 # via # -r requirements.txt # wagtail +mysqlclient==2.2.7 + # via -r requirements.txt openpyxl==3.1.5 # via # -r requirements.txt @@ -83,10 +85,6 @@ pillow==9.5.0 # via # -r requirements.txt # wagtail -psycopg2==2.9.10 - # via -r requirements.txt -psycopg2-binary==2.9.10 - # via -r requirements_dev.in pytz==2024.2 # via # -r requirements.txt From 818977f07d7a5a5601e8f37b1b772eb43ca7b7f2 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:51:31 -0500 Subject: [PATCH 2/6] build: Upgrade to wagtail 2.15 and django 3.2 --- requirements.in | 2 +- requirements.txt | 6 +++--- requirements_dev.txt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.in b/requirements.in index d05cd86..7be89a0 100644 --- a/requirements.in +++ b/requirements.in @@ -5,5 +5,5 @@ django-taggit mysqlclient redis[hiredis] sentry-sdk -wagtail==2.11.9 +wagtail<2.16 git+https://github.com/carrotandcompany/wagtailtrans@master#egg=wagtailtrans diff --git a/requirements.txt b/requirements.txt index 45c7b2d..33efd99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ charset-normalizer==3.4.1 # via requests dj-database-url==0.5.0 # via -r requirements.in -django==3.1.14 +django==3.2.25 # via # -r requirements.in # django-filter @@ -75,13 +75,13 @@ sqlparse==0.5.3 # via django tablib==3.6.1 # via wagtail -unidecode==1.3.8 +telepath==0.3.1 # via wagtail urllib3==1.26.20 # via # requests # sentry-sdk -wagtail==2.11.9 +wagtail==2.15.6 # via # -r requirements.in # wagtailtrans diff --git a/requirements_dev.txt b/requirements_dev.txt index 7b10f12..7bd05e5 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -25,7 +25,7 @@ coverage==7.6.10 # via -r requirements_dev.in dj-database-url==0.5.0 # via -r requirements.txt -django==3.1.14 +django==3.2.25 # via # -r requirements.txt # django-filter @@ -116,7 +116,7 @@ tablib==3.6.1 # via # -r requirements.txt # wagtail -unidecode==1.3.8 +telepath==0.3.1 # via # -r requirements.txt # wagtail @@ -125,7 +125,7 @@ urllib3==1.26.20 # -r requirements.txt # requests # sentry-sdk -wagtail==2.11.9 +wagtail==2.15.6 # via # -r requirements.txt # wagtailtrans From ea98d09069ef3734a8ae3202ece9af133d3b7f2c Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:51:55 -0500 Subject: [PATCH 3/6] ci: Ignore all warnings until upgrades complete ("django.utils.deprecation.RemovedInDjango41Warning: 'wagtail.contrib.forms' defines default_app_config = 'wagtail.contrib.forms.apps.WagtailFormsAppConfig'. Django now detects this configuration automatically. You can remove default_app_config.") --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index deb1afd..a709287 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - name: Run checks and tests env: # https://github.com/open-contracting/digitalbuying/issues/2 - PYTHONWARNINGS: error,ignore::DeprecationWarning:django.utils.version,ignore::DeprecationWarning:django.http.request,ignore::DeprecationWarning:willow.image,ignore::DeprecationWarning:l18n.translation,ignore:::wagtail.core.signals,ignore:::wagtail.documents.models,ignore:::wagtail.admin.signals,ignore:::wagtail.core.models,ignore:::wagtailtrans.urls.translations,ignore:::wagtailtrans.wagtail_hooks + PYTHONWARNINGS: ignore DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.mysql.ports[3306] }}/mysql shell: bash run: | From 07ba33b09f8f83b73deb34574bd758fa305bfe1d Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:01:01 -0500 Subject: [PATCH 4/6] chore(pre-commit): Configure stylelint --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5809303..0e2ebfa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,7 @@ repos: rev: v16.12.0 hooks: - id: stylelint + additional_dependencies: + - stylelint@16.12.0 + - stylelint-config-standard@36.0.1 + - stylelint-config-standard-scss@14.0.0 From 551ee33a5cef0968fc413291788f5ac65eba5977 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:01:10 -0500 Subject: [PATCH 5/6] build(django32): Avoid autofield migrations https://docs.djangoproject.com/en/5.1/releases/3.2/#customizing-type-of-auto-created-primary-keys --- case_studies/apps.py | 6 ++++++ modules/apps.py | 1 + navigation/apps.py | 6 ++++++ sponsors/apps.py | 1 + 4 files changed, 14 insertions(+) create mode 100644 case_studies/apps.py create mode 100644 navigation/apps.py diff --git a/case_studies/apps.py b/case_studies/apps.py new file mode 100644 index 0000000..88f625d --- /dev/null +++ b/case_studies/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ModulesConfig(AppConfig): + name = "case_studies" + default_auto_field = "django.db.models.AutoField" diff --git a/modules/apps.py b/modules/apps.py index 2cb9266..c01b01d 100644 --- a/modules/apps.py +++ b/modules/apps.py @@ -3,3 +3,4 @@ class ModulesConfig(AppConfig): name = "modules" + default_auto_field = "django.db.models.AutoField" diff --git a/navigation/apps.py b/navigation/apps.py new file mode 100644 index 0000000..5ae51e3 --- /dev/null +++ b/navigation/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ModulesConfig(AppConfig): + name = "navigation" + default_auto_field = "django.db.models.AutoField" diff --git a/sponsors/apps.py b/sponsors/apps.py index bec0db4..9a8c476 100644 --- a/sponsors/apps.py +++ b/sponsors/apps.py @@ -3,3 +3,4 @@ class SponsorsConfig(AppConfig): name = "sponsors" + default_auto_field = "django.db.models.AutoField" From 1ddb27b0917f3e186f744464559fdaf67711c735 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:12:06 -0500 Subject: [PATCH 6/6] ci: Specify which app labels to check migrations for --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a709287..27ce08f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,9 +34,9 @@ jobs: shell: bash run: | ./manage.py migrate - ./manage.py makemigrations --check --dry-run + ./manage.py makemigrations --check --dry-run base case_studies guidelines modules navigation sponsors streams ./manage.py check --fail-level WARNING - coverage run --source ictcg manage.py test + coverage run --source ictcg,base,case_studies,guidelines,modules,navigation,sponsors,streams manage.py test - uses: coverallsapp/github-action@v2 services: mysql: