From 4a0fb36e5398dc072d1a629199fd8991e0c44bf6 Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Sun, 3 Dec 2023 23:19:20 +0100 Subject: [PATCH 1/6] Fixed tox config to run flake8 without errors. Changes were based on the following: - "honeypot" had to be replaced by module's actual name - a multiline condition with a line break before a binary operator triggers flake8's W503; changing that line would trigger another error or warning, or more require more changes elsewhere --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 953b562..76847cb 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py37-django{22,30}, flake8 [testenv:flake8] deps = flake8 -commands = flake8 --ignore=E402,E731 honeypot +commands = flake8 --ignore=E402,W503,E731 markupfield [testenv] deps = From b123282e83265f23c5172ba7a7e7bfc8a1e57496 Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Mon, 4 Dec 2023 21:44:43 +0100 Subject: [PATCH 2/6] Overhauled GitHub action to run tests with tox. - removed parts related to testing multiple DB that didn't work - updated test matrices based on currently supported releases - simplified GitHub action by relying more on tox - added a separate job for linter --- .github/workflows/test.yml | 77 +++++++++++++++++--------------------- tox.ini | 28 ++++++++++++-- 2 files changed, 59 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35d6195..1828f1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,50 +7,43 @@ on: branches: [ main ] jobs: - build: + tests: + name: run tests for python ${{ matrix.python }}, django ${{ matrix.django }} runs-on: ubuntu-latest - - services: - postgres: - image: postgres - env: - POSTGRES_USER: 'test' - POSTGRES_PASSWORD: 'test' - POSTGRES_DB: 'test' - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - strategy: - max-parallel: 4 matrix: - python-version: [3.7, 3.9, '3.10'] - db: ["sqlite", "postgres"] - django-version: [2.2, 3.2, "4.0b1"] - exclude: - - python-version: 3.7 - db: sqlite - django-version: "4.0b1" - - python-version: 3.7 - db: postgres - django-version: "4.0b1" + python: [ "3.8", "3.9", "3.10", "3.11" ] + django: [ "3.2", "4.1", "4.2" ] + exclude: + - python: "3.11" + django: "3.2" + - python: "3.12" + django: "3.2" + - python: "3.12" + django: "4.1" + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: install python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: install tox + run: python3 -m pip install tox tox-gh + - name: run tests + run: tox -e py${{ matrix.python }}-django${{ matrix.django }} + lint: + name: check for any style errors + runs-on: ubuntu-latest steps: - # Python & dependency installation - - uses: actions/checkout@v2 - - name: setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: install dependencies - run: pip install --pre Django==${{ matrix.django-version }} markdown docutils psycopg2-binary - # - name: lint with flake8 - # run: flake8 --show-source --statistics --ignore=E203,E501,W503 - - name: make executable - run: chmod a+x run_tests.sh - - name: run tests - run: ./run_tests.sh + - name: checkout repository + uses: actions/checkout@v4 + - name: install python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: install tox + run: python3 -m pip install tox + - name: run linter + run: tox -e flake8 diff --git a/tox.ini b/tox.ini index 76847cb..a317ca6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,39 @@ [tox] -envlist = py37-django{22,30}, flake8 +envlist = + ; python releases: https://www.python.org/downloads/ + ; django releases: https://www.djangoproject.com/download/ + ; python+django support: https://docs.djangoproject.com/en/dev/faq/install/ + py{38,39,310}-django3.2, + py{38,39,310,311}-django4.1, + py{38,39,310,311,312}-django4.2, + flake8 [testenv:flake8] deps = flake8 commands = flake8 --ignore=E402,W503,E731 markupfield [testenv] +allowlist_externals = + ./run_tests.sh +commands = + ./run_tests.sh deps = - django22: Django==2.2 - django30: Django==3.0 + django3.2: Django ~= 3.2.9 + django4.1: Django ~= 4.1.3 + django4.2: Django ~= 4.2.0 markdown docutils psycopg2-binary -commands = ./run_tests.sh pip_pre = True [flake8] max-line-length=99 + +[gh] +python = + ; https://github.com/tox-dev/tox-gh + 3.8 = py38 + 3.9 = py39 + 3.10 = py310 + 3.11 = py311 + 3.12 = py312 From 8acfa7fbf72fd83fbda170ab14300f2e5a025bad Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Tue, 5 Dec 2023 09:14:07 +0100 Subject: [PATCH 3/6] Added Python 3.12 to GitHub Actions. - forgot to add Python 3.12 to GitHub Actions in previous commit - the long deprecated method assertEquals of unittest.TestCase was removed with the release of Python 3.12; had to be replaced --- .github/workflows/test.yml | 2 +- markupfield/tests/tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1828f1b..1029cb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.8", "3.9", "3.10", "3.11" ] + python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] django: [ "3.2", "4.1", "4.2" ] exclude: - python: "3.11" diff --git a/markupfield/tests/tests.py b/markupfield/tests/tests.py index 5ba9c5f..6a19151 100644 --- a/markupfield/tests/tests.py +++ b/markupfield/tests/tests.py @@ -386,7 +386,7 @@ def test_form_create(self): form.save() actual = Post.objects.get(title=self.data["title"]) - self.assertEquals(actual.body.raw, self.data["body"]) + self.assertEqual(actual.body.raw, self.data["body"]) def test_form_update(self): existing = Post.objects.create( @@ -404,7 +404,7 @@ def test_form_update(self): form.save() actual = Post.objects.get(title=update["title"]) - self.assertEquals(actual.body.raw, update["body"]) + self.assertEqual(actual.body.raw, update["body"]) class MarkupFieldLocalFileTestCase(TestCase): From 97917c63728aa34fc333a793c4324eaf33f815c5 Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Wed, 6 Dec 2023 22:48:12 +0100 Subject: [PATCH 4/6] Fixed typo in Github Action workflow. --- .github/workflows/test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1029cb8..566be17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,13 +14,13 @@ jobs: matrix: python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] django: [ "3.2", "4.1", "4.2" ] - exclude: - - python: "3.11" - django: "3.2" - - python: "3.12" - django: "3.2" - - python: "3.12" - django: "4.1" + exclude: + - python: "3.11" + django: "3.2" + - python: "3.12" + django: "3.2" + - python: "3.12" + django: "4.1" steps: - name: checkout repository uses: actions/checkout@v4 From af56fa550794710705e3d189000591250d6b6acc Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Thu, 7 Dec 2023 08:16:30 +0100 Subject: [PATCH 5/6] Added databases to test matrix. --- .github/workflows/test.yml | 19 +++++++++++++++++-- markupfield/tests/settings.py | 6 ++++-- tox.ini | 9 ++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 566be17..a6cd048 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,12 +8,27 @@ on: jobs: tests: - name: run tests for python ${{ matrix.python }}, django ${{ matrix.django }} + name: run tests for python ${{ matrix.python }}, django ${{ matrix.django }}, ${{ matrix.database }} runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_DB: "test" + POSTGRES_USER: "test" + POSTGRES_PASSWORD: "test" + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 strategy: matrix: python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] django: [ "3.2", "4.1", "4.2" ] + database: [ "sqlite", "postgres" ] exclude: - python: "3.11" django: "3.2" @@ -31,7 +46,7 @@ jobs: - name: install tox run: python3 -m pip install tox tox-gh - name: run tests - run: tox -e py${{ matrix.python }}-django${{ matrix.django }} + run: tox -e py${{ matrix.python }}-django${{ matrix.django }}-${{ matrix.database }} lint: name: check for any style errors diff --git a/markupfield/tests/settings.py b/markupfield/tests/settings.py index fb3be75..4214a00 100644 --- a/markupfield/tests/settings.py +++ b/markupfield/tests/settings.py @@ -10,8 +10,10 @@ "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": "test", - "USER": "postgres", - "PASSWORD": "", + "USER": "test", + "PASSWORD": "test", + "HOST": "127.0.0.1", + "PORT": "5432", } } else: diff --git a/tox.ini b/tox.ini index a317ca6..c22450b 100644 --- a/tox.ini +++ b/tox.ini @@ -3,9 +3,9 @@ envlist = ; python releases: https://www.python.org/downloads/ ; django releases: https://www.djangoproject.com/download/ ; python+django support: https://docs.djangoproject.com/en/dev/faq/install/ - py{38,39,310}-django3.2, - py{38,39,310,311}-django4.1, - py{38,39,310,311,312}-django4.2, + py{38,39,310}-django3.2-{sqlite,postgres}, + py{38,39,310,311}-django4.1-{sqlite,postgres}, + py{38,39,310,311,312}-django4.2-{sqlite,postgres}, flake8 [testenv:flake8] @@ -25,6 +25,9 @@ deps = docutils psycopg2-binary pip_pre = True +setenv = + postgres: DB = postgres + sqlite: DB = sqlite [flake8] max-line-length=99 From 6f71450a48283368e2371a75df0146811d821ad7 Mon Sep 17 00:00:00 2001 From: Alan Verresen Date: Thu, 7 Dec 2023 08:35:45 +0100 Subject: [PATCH 6/6] Added Django 5.0 to test matrix. --- .github/workflows/test.yml | 6 +++++- tox.ini | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6cd048..c467ef9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] - django: [ "3.2", "4.1", "4.2" ] + django: [ "3.2", "4.1", "4.2", "5.0" ] database: [ "sqlite", "postgres" ] exclude: - python: "3.11" @@ -36,6 +36,10 @@ jobs: django: "3.2" - python: "3.12" django: "4.1" + - python: "3.8" + django: "5.0" + - python: "3.9" + django: "5.0" steps: - name: checkout repository uses: actions/checkout@v4 diff --git a/tox.ini b/tox.ini index c22450b..53489b9 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist = py{38,39,310}-django3.2-{sqlite,postgres}, py{38,39,310,311}-django4.1-{sqlite,postgres}, py{38,39,310,311,312}-django4.2-{sqlite,postgres}, + py{310,311,312}-django5.0-{sqlite,postgres}, flake8 [testenv:flake8] @@ -21,6 +22,7 @@ deps = django3.2: Django ~= 3.2.9 django4.1: Django ~= 4.1.3 django4.2: Django ~= 4.2.0 + django5.0: Django ~= 5.0.0 markdown docutils psycopg2-binary