From 23ee814adaa0f7065d8b91785af640798d870246 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:40:55 +0200 Subject: [PATCH 01/12] Add tox configuration --- tox.ini | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b73a75f --- /dev/null +++ b/tox.ini @@ -0,0 +1,33 @@ +[tox] +minversion = 3.14.6 +envlist = + py{36,37,38}-dj22-wagtail29 + py{37,38,39,310}-dj32-wagtail{215,216} + py{38,39,310}-dj40-wagtail{216,30} + py{38,39,310}-dj40-wagtail40 + py{39,310}-dj41-wagtail40 + coverage-report + +[testenv] +commands = coverage run --parallel -m pytest {posargs} +extras = test +deps = + dj22: django>=2.2,<3.0 + dj32: django>=3.2,<3.3 + dj40: django>=4.0,<4.1 + dj41: django>=4.1,<5.0 + wagtail113: wagtail>=1.13,<2.0 + wagtail29: wagtail>=2.9,<2.10 + wagtail215: wagtail>=2.15,<2.16 + wagtail216: wagtail>=2.16,<3.0 + wagtail30: wagtail>=3.0,<4.0 + wagtail40: wagtail>=4.0,<5.0 + +[testenv:coverage-report] +basepython = python3.7 +deps = coverage +pip_pre = true +skip_install = true +commands = + coverage combine + coverage report From c11301c1758c8cc46699581f1ec6d63cea349b6d Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:42:26 +0200 Subject: [PATCH 02/12] Add testing dependencies --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e1cba3b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +wagtail>=1.0 +pytest==6.2.5 +pytest-cov==3.0.0 +pytest-django==4.5.0 +pytest-pythonpath==0.7.3 +coverage==6.0 \ No newline at end of file From ad2bdb5aa4aaf581e4a4e0014d9f955400b98745 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:42:59 +0200 Subject: [PATCH 03/12] Update setup.py to include testing deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and bump min Wagtail version to 2.9 to narrow down the testing matrix though this package should still work even for older versions (but who whould be using older versions of wagtail [pre 2.x in 2022?] 😀) --- setup.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 27c5e20..ac722dc 100755 --- a/setup.py +++ b/setup.py @@ -13,6 +13,18 @@ use_setuptools() from setuptools import setup, find_packages +install_requires = [ + 'wagtail>=2.9', +] + +tests_require = [ + "pytest==6.2.5", + "pytest-cov==3.0.0", + "pytest-django==4.5.0", + "pytest-pythonpath==0.7.3", + "coverage==6.0", +] + setup( name='wagtail-accessibility', version='0.2.1', @@ -22,9 +34,11 @@ author_email='liam@takeflight.com.au', url='https://github.com/takeflight/wagtail-accessibility', - install_requires=[ - 'wagtail>=1.0', - ], + install_requires=install_requires, + tests_require=tests_require, + extras_require={ + "test": tests_require, + }, zip_safe=False, license='BSD License', From 719117ef26234d89788e5ff21e508b63ce29edc4 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:47:49 +0200 Subject: [PATCH 04/12] Add test suite --- tests/__init__.py | 0 tests/conftest.py | 16 +++ tests/settings.py | 97 +++++++++++++++++++ tests/test_page.py | 41 ++++++++ tests/testapp/__init__.py | 0 tests/testapp/apps.py | 5 + tests/testapp/migrations/0001_initial.py | 24 +++++ .../migrations/0002_create_simplepage.py | 60 ++++++++++++ tests/testapp/migrations/__init__.py | 0 tests/testapp/models.py | 9 ++ .../templates/testapp/simple_page.html | 5 + tests/urls.py | 16 +++ 12 files changed, 273 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/settings.py create mode 100644 tests/test_page.py create mode 100644 tests/testapp/__init__.py create mode 100644 tests/testapp/apps.py create mode 100644 tests/testapp/migrations/0001_initial.py create mode 100644 tests/testapp/migrations/0002_create_simplepage.py create mode 100644 tests/testapp/migrations/__init__.py create mode 100644 tests/testapp/models.py create mode 100644 tests/testapp/templates/testapp/simple_page.html create mode 100644 tests/urls.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..50cd61a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,16 @@ +import os + +import django +from django.test.utils import override_settings +import pytest + + +def pytest_configure(): + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") + django.setup() + + +@pytest.fixture(scope="session", autouse=True) +def custom_settings(tmpdir_factory): + overrides = override_settings(MEDIA_ROOT=str(tmpdir_factory.mktemp("media"))) + overrides.enable() \ No newline at end of file diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..497ebd6 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,97 @@ +import os + +from wagtail import VERSION as WAGTAIL_VERSION + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +ALLOWED_HOSTS = ["*"] + +SECRET_KEY = "ThisIsForTestingOnly" + +INSTALLED_APPS = [ + "wagtailaccessibility", + "tests.testapp", + + 'wagtail.contrib.forms', + 'wagtail.contrib.redirects', + 'wagtail.embeds', + 'wagtail.sites', + 'wagtail.users', + 'wagtail.snippets', + 'wagtail.documents', + 'wagtail.images', + 'wagtail.search', + 'wagtail.admin', + "wagtail" if WAGTAIL_VERSION >= (3, 0) else "wagtail.core", + + "taggit", + "modelcluster", + + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.sites", + "django.contrib.staticfiles", +] + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", + } +} + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "wagtail.contrib.redirects.middleware.RedirectMiddleware", +] + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ] + }, + } +] + +ROOT_URLCONF = "tests.urls" + +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" + +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "unique-snowflake", + } +} + +STATICFILES_FINDERS = [ + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +] + +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'staticfiles'), +] + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_URL = '/static/' + +if WAGTAIL_VERSION >= (3, 0): + WAGTAILADMIN_BASE_URL = "http://example.com" diff --git a/tests/test_page.py b/tests/test_page.py new file mode 100644 index 0000000..84a80cd --- /dev/null +++ b/tests/test_page.py @@ -0,0 +1,41 @@ +from django.conf import settings +from pytest_django.asserts import assertInHTML, assertJSONEqual + +from tests.testapp.models import SimplePage + + +validity = { + 'is_valid': True +} + +if settings.WAGTAIL_VERSION >= (4, 0): + validity['is_available'] = True + + +def test_preview(admin_client): + simple_page = SimplePage.objects.first() + + post_data = { + 'title': "Accessibility", + 'slug': 'accessibility', + } + + preview_url = "/admin/pages/{}/edit/preview/".format(simple_page.pk) + response = admin_client.post(preview_url, post_data) + + # Check the JSON response + assert response.status_code == 200 + assertJSONEqual(response.content.decode(), validity) + + # Check the user can refresh the preview + preview_session_key = 'wagtail-preview-{}'.format(simple_page.pk) + assert preview_session_key in admin_client.session + + response = admin_client.get(preview_url) + + # Check the HTML response + assert response.status_code == 200 + assertInHTML( + '', + response.content.decode(), + ) diff --git a/tests/testapp/__init__.py b/tests/testapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/testapp/apps.py b/tests/testapp/apps.py new file mode 100644 index 0000000..15626fb --- /dev/null +++ b/tests/testapp/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class TestAppConfig(AppConfig): + name = "tests.testapp" diff --git a/tests/testapp/migrations/0001_initial.py b/tests/testapp/migrations/0001_initial.py new file mode 100644 index 0000000..d3d4bc0 --- /dev/null +++ b/tests/testapp/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ] + + operations = [ + migrations.CreateModel( + name='SimplePage', + fields=[ + ('page_ptr', models.OneToOneField(on_delete=models.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/tests/testapp/migrations/0002_create_simplepage.py b/tests/testapp/migrations/0002_create_simplepage.py new file mode 100644 index 0000000..8454a9a --- /dev/null +++ b/tests/testapp/migrations/0002_create_simplepage.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +def create_simplepage(apps, schema_editor): + # Get models + ContentType = apps.get_model('contenttypes.ContentType') + Page = apps.get_model('wagtailcore.Page') + Site = apps.get_model('wagtailcore.Site') + SimplePage = apps.get_model('testapp.SimplePage') + + # Delete the default simplepage + # If migration is run multiple times, it may have already been deleted + Page.objects.filter(id=2).delete() + + # Create content type for simplepage model + simplepage_content_type, __ = ContentType.objects.get_or_create( + model='simplepage', app_label='testapp') + + # Create a new simplepage + simplepage = SimplePage.objects.create( + title="Home", + draft_title="Home", + slug='testapp', + content_type=simplepage_content_type, + path='00010001', + depth=2, + numchild=0, + url_path='/testapp/', + ) + + # Create a site with the new simplepage set as the root + Site.objects.create( + hostname='localhost', root_page=simplepage, is_default_site=True) + + +def remove_simplepage(apps, schema_editor): + # Get models + ContentType = apps.get_model('contenttypes.ContentType') + SimplePage = apps.get_model('testapp.SimplePage') + + # Delete the default simplepage + # Page and Site objects CASCADE + SimplePage.objects.filter(slug='testapp', depth=2).delete() + + # Delete content type for simplepage model + ContentType.objects.filter(model='simplepage', app_label='testapp').delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('testapp', '0001_initial'), + ] + + operations = [ + migrations.RunPython(create_simplepage, remove_simplepage), + ] diff --git a/tests/testapp/migrations/__init__.py b/tests/testapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/testapp/models.py b/tests/testapp/models.py new file mode 100644 index 0000000..38bd10e --- /dev/null +++ b/tests/testapp/models.py @@ -0,0 +1,9 @@ +try: + from wagtail.models import Page +except ImportError: + # Wagtail<3.0 + from wagtail.core.models import Page + + +class SimplePage(Page): + pass diff --git a/tests/testapp/templates/testapp/simple_page.html b/tests/testapp/templates/testapp/simple_page.html new file mode 100644 index 0000000..23d8288 --- /dev/null +++ b/tests/testapp/templates/testapp/simple_page.html @@ -0,0 +1,5 @@ +{% load wagtailaccessibility_tags %} + +{% tota11y %} + +

{{ page.title }}

diff --git a/tests/urls.py b/tests/urls.py new file mode 100644 index 0000000..07007ef --- /dev/null +++ b/tests/urls.py @@ -0,0 +1,16 @@ +from django.urls import include, path +from wagtail.admin import urls as wagtailadmin_urls +from wagtail.documents import urls as wagtaildocs_urls + +try: + from wagtail import urls as wagtail_urls +except ImportError: + # Wagtail<3.0 + from wagtail.core import urls as wagtail_urls + + +urlpatterns = [ + path("admin/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), + path("", include(wagtail_urls)), +] From 19370db3453e715f12b1ba26834c2bb1793df466 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:48:47 +0200 Subject: [PATCH 05/12] add staticfiles/ to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e7c38f5..2eeb451 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.pyc *.egg-info dist/ + +staticfiles/ \ No newline at end of file From 50b26b6520021043e3826180755566c3c1aba377 Mon Sep 17 00:00:00 2001 From: Victor Miti Date: Wed, 19 Oct 2022 07:49:07 +0200 Subject: [PATCH 06/12] add GitHub Actions --- .github/workflows/python-tox.yml | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/python-tox.yml diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml new file mode 100644 index 0000000..d122b53 --- /dev/null +++ b/.github/workflows/python-tox.yml @@ -0,0 +1,65 @@ +name: Python Tests + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + max-parallel: 4 + matrix: + include: + - toxenv: "py36-dj22-wagtail29" + python-version: 3.6 + - toxenv: "py37-dj22-wagtail29" + python-version: 3.7 + - toxenv: "py37-dj32-wagtail215" + python-version: 3.7 + - toxenv: "py37-dj32-wagtail216" + python-version: 3.7 + - toxenv: "py38-dj22-wagtail29" + python-version: 3.8 + - toxenv: "py38-dj32-wagtail215" + python-version: 3.8 + - toxenv: "py38-dj32-wagtail216" + python-version: 3.8 + - toxenv: "py38-dj40-wagtail216" + python-version: 3.8 + - toxenv: "py38-dj40-wagtail30" + python-version: 3.8 + - toxenv: "py38-dj40-wagtail40" + python-version: 3.8 + - toxenv: "py39-dj32-wagtail215" + python-version: 3.9 + - toxenv: "py39-dj32-wagtail216" + python-version: 3.9 + - toxenv: "py39-dj32-wagtail30" + python-version: 3.9 + - toxenv: "py39-dj32-wagtail40" + python-version: 3.9 + - toxenv: "py310-dj32-wagtail215" + python-version: "3.10" + - toxenv: "py310-dj40-wagtail216" + python-version: "3.10" + - toxenv: "py310-dj40-wagtail30" + python-version: "3.10" + - toxenv: "py310-dj40-wagtail40" + python-version: "3.10" + - toxenv: "py310-dj41-wagtail40" + python-version: "3.10" + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip tox + - name: Run tox - ${{ matrix.toxenv }} + env: + TOX_ENV: ${{ matrix.toxenv }} + run: | + tox -e $TOX_ENV From 5628cd410ce1da64a3051e97f73b3b8699c544c4 Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 12:31:14 +0800 Subject: [PATCH 07/12] Update gitignore --- .gitignore | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2eeb451..68bc17f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,160 @@ -*.pyc -*.egg-info +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ -staticfiles/ \ No newline at end of file +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ From ba4a025cd11af7671a34bfcfacb00c320c7dfa44 Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 12:37:24 +0800 Subject: [PATCH 08/12] Run updatemodulepaths --- tests/settings.py | 5 ++--- tests/testapp/models.py | 6 +----- tests/urls.py | 7 +------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tests/settings.py b/tests/settings.py index 497ebd6..4aef92d 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -22,7 +22,7 @@ 'wagtail.images', 'wagtail.search', 'wagtail.admin', - "wagtail" if WAGTAIL_VERSION >= (3, 0) else "wagtail.core", + "wagtail", "taggit", "modelcluster", @@ -93,5 +93,4 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' -if WAGTAIL_VERSION >= (3, 0): - WAGTAILADMIN_BASE_URL = "http://example.com" +WAGTAILADMIN_BASE_URL = "http://example.com" diff --git a/tests/testapp/models.py b/tests/testapp/models.py index 38bd10e..89f501a 100644 --- a/tests/testapp/models.py +++ b/tests/testapp/models.py @@ -1,8 +1,4 @@ -try: - from wagtail.models import Page -except ImportError: - # Wagtail<3.0 - from wagtail.core.models import Page +from wagtail.models import Page class SimplePage(Page): diff --git a/tests/urls.py b/tests/urls.py index 07007ef..e2883fb 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,13 +1,8 @@ from django.urls import include, path +from wagtail import urls as wagtail_urls from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls -try: - from wagtail import urls as wagtail_urls -except ImportError: - # Wagtail<3.0 - from wagtail.core import urls as wagtail_urls - urlpatterns = [ path("admin/", include(wagtailadmin_urls)), From e04ef9386a686ffe4e44b95f3e25c1956ec9f6eb Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 14:46:22 +0800 Subject: [PATCH 09/12] Adapt tox-gh-actions --- .github/workflows/python-tox.yml | 50 ++++---------------------------- requirements.txt | 5 ++-- tox.ini | 30 +++++++++---------- 3 files changed, 23 insertions(+), 62 deletions(-) diff --git a/.github/workflows/python-tox.yml b/.github/workflows/python-tox.yml index d122b53..d6c966b 100644 --- a/.github/workflows/python-tox.yml +++ b/.github/workflows/python-tox.yml @@ -9,45 +9,7 @@ jobs: strategy: max-parallel: 4 matrix: - include: - - toxenv: "py36-dj22-wagtail29" - python-version: 3.6 - - toxenv: "py37-dj22-wagtail29" - python-version: 3.7 - - toxenv: "py37-dj32-wagtail215" - python-version: 3.7 - - toxenv: "py37-dj32-wagtail216" - python-version: 3.7 - - toxenv: "py38-dj22-wagtail29" - python-version: 3.8 - - toxenv: "py38-dj32-wagtail215" - python-version: 3.8 - - toxenv: "py38-dj32-wagtail216" - python-version: 3.8 - - toxenv: "py38-dj40-wagtail216" - python-version: 3.8 - - toxenv: "py38-dj40-wagtail30" - python-version: 3.8 - - toxenv: "py38-dj40-wagtail40" - python-version: 3.8 - - toxenv: "py39-dj32-wagtail215" - python-version: 3.9 - - toxenv: "py39-dj32-wagtail216" - python-version: 3.9 - - toxenv: "py39-dj32-wagtail30" - python-version: 3.9 - - toxenv: "py39-dj32-wagtail40" - python-version: 3.9 - - toxenv: "py310-dj32-wagtail215" - python-version: "3.10" - - toxenv: "py310-dj40-wagtail216" - python-version: "3.10" - - toxenv: "py310-dj40-wagtail30" - python-version: "3.10" - - toxenv: "py310-dj40-wagtail40" - python-version: "3.10" - - toxenv: "py310-dj41-wagtail40" - python-version: "3.10" + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 @@ -57,9 +19,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip tox - - name: Run tox - ${{ matrix.toxenv }} - env: - TOX_ENV: ${{ matrix.toxenv }} - run: | - tox -e $TOX_ENV + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Test with tox + run: tox diff --git a/requirements.txt b/requirements.txt index e1cba3b..21db5c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -wagtail>=1.0 +wagtail>=4.1 pytest==6.2.5 pytest-cov==3.0.0 pytest-django==4.5.0 pytest-pythonpath==0.7.3 -coverage==6.0 \ No newline at end of file +coverage==6.0 +tox-gh-actions>=3.1 diff --git a/tox.ini b/tox.ini index b73a75f..ad3fc13 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,30 @@ [tox] minversion = 3.14.6 envlist = - py{36,37,38}-dj22-wagtail29 - py{37,38,39,310}-dj32-wagtail{215,216} - py{38,39,310}-dj40-wagtail{216,30} - py{38,39,310}-dj40-wagtail40 - py{39,310}-dj41-wagtail40 + py{38,39,310,311}-dj{32,41}-wagtail{41,50,51} + py{39,310,311}-dj{42}-wagtail{50,51} coverage-report +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + [testenv] commands = coverage run --parallel -m pytest {posargs} extras = test deps = - dj22: django>=2.2,<3.0 dj32: django>=3.2,<3.3 - dj40: django>=4.0,<4.1 - dj41: django>=4.1,<5.0 - wagtail113: wagtail>=1.13,<2.0 - wagtail29: wagtail>=2.9,<2.10 - wagtail215: wagtail>=2.15,<2.16 - wagtail216: wagtail>=2.16,<3.0 - wagtail30: wagtail>=3.0,<4.0 - wagtail40: wagtail>=4.0,<5.0 + dj41: django>=4.1,<4.2 + dj42: django>=4.2,<4.3 + wagtail41: wagtail>=4.1,<5.0 + wagtail50: wagtail>=5.0,<5.1 + wagtail51: wagtail>=5.1,<5.2 [testenv:coverage-report] -basepython = python3.7 +basepython = python3.11 deps = coverage pip_pre = true skip_install = true From fd2956e44ec387f06b192c6344f111b69baca529 Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 14:47:01 +0800 Subject: [PATCH 10/12] Add USE_TZ to avoid removal warnings from Django --- tests/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/settings.py b/tests/settings.py index 4aef92d..95f5db1 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -94,3 +94,5 @@ STATIC_URL = '/static/' WAGTAILADMIN_BASE_URL = "http://example.com" + +USE_TZ = False From d153b1d99478b27b1d305935c4410d8a92437842 Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 23:21:45 +0800 Subject: [PATCH 11/12] Update minimum Wagtail version to 4.1 in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ac722dc..47ef4ad 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import setup, find_packages install_requires = [ - 'wagtail>=2.9', + 'wagtail>=4.1', ] tests_require = [ From cfd12bc91952ccf4856d210c5d91d3dd92c3e654 Mon Sep 17 00:00:00 2001 From: Katherine Domingo Date: Tue, 3 Oct 2023 23:58:22 +0800 Subject: [PATCH 12/12] Update tox.ini envlist to consider that Django 3.2 does not support Python 3.11 --- tox.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ad3fc13..6d3595e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,9 @@ [tox] minversion = 3.14.6 envlist = - py{38,39,310,311}-dj{32,41}-wagtail{41,50,51} - py{39,310,311}-dj{42}-wagtail{50,51} + py{38,39,310}-dj{32,41}-wagtail{41,42,50,51} + py311-dj41-wagtail{41,42,50,51} + py311-dj42-wagtail{50,51} coverage-report [gh-actions]