From b1ac88446a64345c1045c07d406771166c1618bb Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:08:42 +0100 Subject: [PATCH 01/23] Add GitHub Actions test workflow. --- .github/workflows/test.yml | 94 ++++++++++++++++++++++++++++++++++++++ tests/settings.py | 16 ++++++- tests/test_integration.py | 2 +- tox.ini | 29 ++++++++---- 4 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..ae7410d33 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,94 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.5', '3.6', '3.7', '3.8'] + database: ['postgresql', 'mariadb', 'sqlite'] + include: + - python-version: '3.8' + tox-env: py38-docs + - python-version: '3.8' + tox-env: py38-style + - python-version: '3.8' + tox-env: py38-readme + + services: + mariadb: + image: mariadb:10.3 + env: + MYSQL_ROOT_PASSWORD: debug_toolbar + MYSQL_DATABASE: debug_toolbar + ports: + - 3306/tcp + options: >- + --health-cmd "mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + postgres: + image: 'postgres:9.5' + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: debug_toolbar + ports: + - 5432/tcp + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install enchant (only for docs) + if: "endsWith(matrix.tox-env, '-docs')" + run: | + sudo apt-get -qq update + sudo apt-get -y install libenchant + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Tox tests + run: tox -v + env: + TOXENV: ${{ matrix.tox-env }} + DATABASE: ${{ matrix.database }} + MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} + POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} + fail_ci_if_error: true diff --git a/tests/settings.py b/tests/settings.py index dbbbb79b2..70bb9ac0b 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -81,11 +81,23 @@ if os.environ.get("DJANGO_DATABASE_ENGINE") == "postgresql": DATABASES = { - "default": {"ENGINE": "django.db.backends.postgresql", "NAME": "debug-toolbar"} + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": "debug_toolbar", + "USER": "root", + "PASSWORD": "debug_toolbar", + "PORT": os.environ.get("POSTGRES_PORT", ""), + } } elif os.environ.get("DJANGO_DATABASE_ENGINE") == "mysql": DATABASES = { - "default": {"ENGINE": "django.db.backends.mysql", "NAME": "debug_toolbar"} + "default": { + "ENGINE": "django.db.backends.mysql", + "NAME": "debug_toolbar", + "USER": "postgres", + "PASSWORD": "postgres", + "PORT": os.environ.get("MYSQL_PORT", ""), + } } else: DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}} diff --git a/tests/test_integration.py b/tests/test_integration.py index 1ab053ab9..8c28f6c6e 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -350,7 +350,7 @@ class DebugToolbarLiveTestCase(StaticLiveServerTestCase): def setUpClass(cls): super().setUpClass() options = Options() - options.headless = bool(os.environ.get("TRAVIS")) + options.headless = bool(os.environ.get("CI")) cls.selenium = webdriver.Firefox(options=options) @classmethod diff --git a/tox.ini b/tox.ini index b8b930b1c..254e12ec1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,6 @@ [tox] envlist = - docs - style - readme + py38-{docs,style,readme} py{35,36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite @@ -23,8 +21,10 @@ deps = selenium sqlparse passenv= - TRAVIS + CI DJANGO_SELENIUM_TESTS + MYSQL_PORT + POSTGRES_PORT setenv = PYTHONPATH = {toxinidir} PYTHONWARNINGS = d @@ -34,14 +34,13 @@ whitelist_externals = make pip_pre = True commands = make coverage TEST_ARGS='{posargs:tests}' -[testenv:docs] +[testenv:py38-docs] commands = make -C {toxinidir}/docs spelling deps = Sphinx sphinxcontrib-spelling -[testenv:style] -basepython = python3 +[testenv:py38-style] commands = make style_check deps = black>=19.10b0 @@ -49,8 +48,20 @@ deps = isort>=5.0.2 skip_install = true -[testenv:readme] -basepython = python3 +[testenv:py38-readme] commands = python setup.py check -r -s deps = readme_renderer skip_install = true + +[gh-actions] +python = + 3.5: py35 + 3.6: py36 + 3.7: py37 + 3.8: py38 + +[gh-actions:env] +DATABASE = + sqlite: sqlite + postgresql: postgresql + mariadb: mariadb From 06f7f0bd211cb17876afe0b7892d9ba2d789c033 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:19:50 +0100 Subject: [PATCH 02/23] Use different strategy to map test matrix to tox envs. --- .github/workflows/test.yml | 12 ++---------- tox.ini | 5 +++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae7410d33..0e94ba398 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,14 +10,7 @@ jobs: max-parallel: 5 matrix: python-version: ['3.5', '3.6', '3.7', '3.8'] - database: ['postgresql', 'mariadb', 'sqlite'] - include: - - python-version: '3.8' - tox-env: py38-docs - - python-version: '3.8' - tox-env: py38-style - - python-version: '3.8' - tox-env: py38-readme + target: ['postgresql', 'mariadb', 'sqlite', 'extra'] services: mariadb: @@ -82,8 +75,7 @@ jobs: - name: Tox tests run: tox -v env: - TOXENV: ${{ matrix.tox-env }} - DATABASE: ${{ matrix.database }} + TARGET: ${{ matrix.target }} MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} diff --git a/tox.ini b/tox.ini index 254e12ec1..38dc7bbd0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py38-{docs,style,readme} + py38-extra-{docs,style,readme} py{35,36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite @@ -61,7 +61,8 @@ python = 3.8: py38 [gh-actions:env] -DATABASE = +TARGET = sqlite: sqlite postgresql: postgresql mariadb: mariadb + extra: extra From 9103b64a6c8d021802d6152f9684f3fb52032c15 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:23:58 +0100 Subject: [PATCH 03/23] List all extra targets? --- .github/workflows/test.yml | 2 +- tox.ini | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e94ba398..79c509b8a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: max-parallel: 5 matrix: python-version: ['3.5', '3.6', '3.7', '3.8'] - target: ['postgresql', 'mariadb', 'sqlite', 'extra'] + target: ['postgresql', 'mariadb', 'sqlite', 'docs', 'style', 'readme'] services: mariadb: diff --git a/tox.ini b/tox.ini index 38dc7bbd0..ec4194795 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py38-extra-{docs,style,readme} + py38-{docs,style,readme} py{35,36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite @@ -65,4 +65,6 @@ TARGET = sqlite: sqlite postgresql: postgresql mariadb: mariadb - extra: extra + docs: docs + style: style + readme: readme From 79186fe2529f0e1125fa5ef8a5ddaff8aeb2cfc6 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:26:10 +0100 Subject: [PATCH 04/23] Add database ports. --- tests/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/settings.py b/tests/settings.py index 70bb9ac0b..e9a187d48 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -86,6 +86,7 @@ "NAME": "debug_toolbar", "USER": "root", "PASSWORD": "debug_toolbar", + "HOST": "127.0.0.1", "PORT": os.environ.get("POSTGRES_PORT", ""), } } @@ -96,6 +97,7 @@ "NAME": "debug_toolbar", "USER": "postgres", "PASSWORD": "postgres", + "HOST": "127.0.0.1", "PORT": os.environ.get("MYSQL_PORT", ""), } } From 6d3ac3a91ab017a55b84988ef1c08830f17efbed Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:29:01 +0100 Subject: [PATCH 05/23] Naming is hard --- tox.ini | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index ec4194795..68e8bfbdd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,8 @@ [tox] envlist = - py38-{docs,style,readme} + docs, + style, + readme, py{35,36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite @@ -34,13 +36,15 @@ whitelist_externals = make pip_pre = True commands = make coverage TEST_ARGS='{posargs:tests}' -[testenv:py38-docs] +[testenv:docs] +basepython = python3.8 commands = make -C {toxinidir}/docs spelling deps = Sphinx sphinxcontrib-spelling -[testenv:py38-style] +[testenv:style] +basepython = python3.8 commands = make style_check deps = black>=19.10b0 @@ -48,7 +52,8 @@ deps = isort>=5.0.2 skip_install = true -[testenv:py38-readme] +[testenv:readme] +basepython = python3.8 commands = python setup.py check -r -s deps = readme_renderer skip_install = true From edd794c51d51a13c0f259586a63483749c7e96a0 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:30:39 +0100 Subject: [PATCH 06/23] Relax codecov. --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79c509b8a..db9824d41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,7 +62,7 @@ jobs: ${{ matrix.python-version }}-v1- - name: Install enchant (only for docs) - if: "endsWith(matrix.tox-env, '-docs')" + if: "matrix.target == 'docs'" run: | sudo apt-get -qq update sudo apt-get -y install libenchant @@ -83,4 +83,3 @@ jobs: uses: codecov/codecov-action@v1 with: name: Python ${{ matrix.python-version }} - fail_ci_if_error: true From 0d13c9a22b25ba58af3f7dd65baea73e68a05dc6 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:45:02 +0100 Subject: [PATCH 07/23] Remove targets. --- .github/workflows/test.yml | 2 +- tox.ini | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db9824d41..caf5866de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: max-parallel: 5 matrix: python-version: ['3.5', '3.6', '3.7', '3.8'] - target: ['postgresql', 'mariadb', 'sqlite', 'docs', 'style', 'readme'] + target: ['postgresql', 'mariadb', 'sqlite'] services: mariadb: diff --git a/tox.ini b/tox.ini index 68e8bfbdd..212e1b626 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist = - docs, - style, - readme, + py38-docs, + py38-style, + py38-readme, py{35,36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite @@ -36,15 +36,13 @@ whitelist_externals = make pip_pre = True commands = make coverage TEST_ARGS='{posargs:tests}' -[testenv:docs] -basepython = python3.8 +[testenv:py38-docs] commands = make -C {toxinidir}/docs spelling deps = Sphinx sphinxcontrib-spelling -[testenv:style] -basepython = python3.8 +[testenv:py38-style] commands = make style_check deps = black>=19.10b0 @@ -52,8 +50,7 @@ deps = isort>=5.0.2 skip_install = true -[testenv:readme] -basepython = python3.8 +[testenv:py38-readme] commands = python setup.py check -r -s deps = readme_renderer skip_install = true @@ -70,6 +67,3 @@ TARGET = sqlite: sqlite postgresql: postgresql mariadb: mariadb - docs: docs - style: style - readme: readme From 2813505356e9e1ed8520ed29da1344400f08169d Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:46:37 +0100 Subject: [PATCH 08/23] Fix apt package name. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index caf5866de..42929b8f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,7 +65,7 @@ jobs: if: "matrix.target == 'docs'" run: | sudo apt-get -qq update - sudo apt-get -y install libenchant + sudo apt-get -y install enchant - name: Install dependencies run: | From 904f315a19f3b8aa484869af846692f10b7647fc Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 13:48:45 +0100 Subject: [PATCH 09/23] Smaller matrix. --- .github/workflows/test.yml | 3 --- tox.ini | 6 ------ 2 files changed, 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42929b8f3..4e2aa3ee4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,6 @@ jobs: max-parallel: 5 matrix: python-version: ['3.5', '3.6', '3.7', '3.8'] - target: ['postgresql', 'mariadb', 'sqlite'] services: mariadb: @@ -62,7 +61,6 @@ jobs: ${{ matrix.python-version }}-v1- - name: Install enchant (only for docs) - if: "matrix.target == 'docs'" run: | sudo apt-get -qq update sudo apt-get -y install enchant @@ -75,7 +73,6 @@ jobs: - name: Tox tests run: tox -v env: - TARGET: ${{ matrix.target }} MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} diff --git a/tox.ini b/tox.ini index 212e1b626..6fc8b202e 100644 --- a/tox.ini +++ b/tox.ini @@ -61,9 +61,3 @@ python = 3.6: py36 3.7: py37 3.8: py38 - -[gh-actions:env] -TARGET = - sqlite: sqlite - postgresql: postgresql - mariadb: mariadb From c362ff7ea84b896dc0d79b627b58cdaf3ad39b82 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:37:19 +0100 Subject: [PATCH 10/23] Fix for database settings. --- .github/workflows/test.yml | 2 +- tests/settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e2aa3ee4..1c2e7402f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - POSTGRES_DB: debug_toolbar + POSTGRES_DB: postgres ports: - 5432/tcp options: >- diff --git a/tests/settings.py b/tests/settings.py index e9a187d48..5dc59c109 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -86,7 +86,7 @@ "NAME": "debug_toolbar", "USER": "root", "PASSWORD": "debug_toolbar", - "HOST": "127.0.0.1", + "HOST": "localhost", "PORT": os.environ.get("POSTGRES_PORT", ""), } } @@ -97,7 +97,7 @@ "NAME": "debug_toolbar", "USER": "postgres", "PASSWORD": "postgres", - "HOST": "127.0.0.1", + "HOST": "localhost", "PORT": os.environ.get("MYSQL_PORT", ""), } } From c25830c2165ce6522baa88c0101c510d49f25e64 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:41:13 +0100 Subject: [PATCH 11/23] Fix settings again. --- tests/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/settings.py b/tests/settings.py index 5dc59c109..bde22e27e 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -84,8 +84,8 @@ "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "debug_toolbar", - "USER": "root", - "PASSWORD": "debug_toolbar", + "USER": "postgres", + "PASSWORD": "postgres", "HOST": "localhost", "PORT": os.environ.get("POSTGRES_PORT", ""), } @@ -95,8 +95,8 @@ "default": { "ENGINE": "django.db.backends.mysql", "NAME": "debug_toolbar", - "USER": "postgres", - "PASSWORD": "postgres", + "USER": "root", + "PASSWORD": "debug_toolbar", "HOST": "localhost", "PORT": os.environ.get("MYSQL_PORT", ""), } From cef82e467a3d2991700a6947dec144600451fd17 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:44:31 +0100 Subject: [PATCH 12/23] Write coverage file. --- .gitignore | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 836dfe93d..564e7b8cc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ htmlcov node_modules package-lock.json geckodriver.log +coverage.xml diff --git a/Makefile b/Makefile index 05ff29203..100acf0af 100644 --- a/Makefile +++ b/Makefile @@ -36,11 +36,11 @@ test_selenium: coverage: python --version - coverage erase DJANGO_SETTINGS_MODULE=tests.settings \ python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests} coverage report coverage html + coverage xml translatable_strings: cd debug_toolbar && python -m django makemessages -l en --no-obsolete From 83a0699eded009d429942069c6cf2d1515398e91 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:48:27 +0100 Subject: [PATCH 13/23] Mysql whatever --- tests/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/settings.py b/tests/settings.py index bde22e27e..454e7c3ca 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -97,7 +97,7 @@ "NAME": "debug_toolbar", "USER": "root", "PASSWORD": "debug_toolbar", - "HOST": "localhost", + "HOST": "127.0.0.1", "PORT": os.environ.get("MYSQL_PORT", ""), } } From f5ec5ed962d57f8fd83e117ad3c9f8d78f7e53bd Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:54:13 +0100 Subject: [PATCH 14/23] remove 3.5 cruft --- .github/workflows/test.yml | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c2e7402f..66ee47a6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - python-version: ['3.5', '3.6', '3.7', '3.8'] + python-version: ['3.6', '3.7', '3.8'] services: mariadb: diff --git a/tox.ini b/tox.ini index ff23da2c9..77355472c 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,6 @@ skip_install = true [gh-actions] python = - 3.5: py35 3.6: py36 3.7: py37 3.8: py38 From 1a6c217f3510528b7e178b08b85412080c225eca Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 14:59:39 +0100 Subject: [PATCH 15/23] Black fix. --- debug_toolbar/panels/cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/panels/cache.py b/debug_toolbar/panels/cache.py index bd65d7d1c..bfaf7018b 100644 --- a/debug_toolbar/panels/cache.py +++ b/debug_toolbar/panels/cache.py @@ -183,7 +183,7 @@ def _store_call_info( trace=None, template_info=None, backend=None, - **kw + **kw, ): if name == "get": if return_value is None: From cb97a619b0822554e5353f067da1e2f624bf6d61 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 15:05:42 +0100 Subject: [PATCH 16/23] Fix for flake8 --- debug_toolbar/panels/history/panel.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/debug_toolbar/panels/history/panel.py b/debug_toolbar/panels/history/panel.py index ca05b749e..047c7be30 100644 --- a/debug_toolbar/panels/history/panel.py +++ b/debug_toolbar/panels/history/panel.py @@ -1,8 +1,6 @@ import json -import sys from collections import OrderedDict -from django.conf import settings from django.http.request import RawPostDataException from django.template.loader import render_to_string from django.templatetags.static import static From 500c6bd6375a657ddc0dfede28fe8a0b3fad4ec2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 15:06:45 +0100 Subject: [PATCH 17/23] Add release workflow. --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..906d6846b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/django-debug-toolbar' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install -U setuptools twine wheel + + - name: Build package + run: | + python setup.py --version + python setup.py sdist --format=gztar bdist_wheel + twine check dist/* + + - name: Upload packages to Jazzband + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: jazzband + password: ${{ secrets.JAZZBAND_RELEASE_KEY }} + repository_url: https://jazzband.co/projects/django-debug-toolbar/upload From 08869a1ab5dd290dac970d0fa52a42a10bed2c63 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 15:10:58 +0100 Subject: [PATCH 18/23] Update changelog and remove Travis cruft. --- .travis.yml | 98 ------------------------------------------------ README.rst | 4 +- docs/changes.rst | 5 +++ 3 files changed, 7 insertions(+), 100 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a5d62049f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,98 +0,0 @@ -dist: bionic -language: python -cache: pip -matrix: - fast_finish: true - include: - - env: TOXENV=docs - before_install: - - sudo apt-get -y install libenchant1c2a - - env: TOXENV=style - - env: TOXENV=readme - - python: 3.6 - env: TOXENV=py36-dj22-sqlite - - python: 3.7 - env: TOXENV=py37-dj22-sqlite - - python: 3.8 - env: TOXENV=py38-dj22-sqlite - - python: 3.6 - env: TOXENV=py36-dj30-sqlite - - python: 3.7 - env: TOXENV=py37-dj30-sqlite - - python: 3.8 - env: TOXENV=py38-dj30-sqlite - - python: 3.6 - env: TOXENV=py36-dj31-sqlite - - python: 3.7 - env: TOXENV=py37-dj31-sqlite - - python: 3.8 - env: TOXENV=py38-dj31-sqlite - - python: 3.6 - env: TOXENV=py36-djmaster-sqlite - - python: 3.7 - env: TOXENV=py37-djmaster-sqlite - - python: 3.8 - env: TOXENV=py38-djmaster-sqlite - - python: 3.8 - env: TOXENV=py38-dj22-postgresql - addons: - postgresql: "9.5" - - python: 3.8 - env: TOXENV=py38-dj30-postgresql - addons: - postgresql: "9.5" - - python: 3.8 - env: TOXENV=py38-dj31-postgresql DJANGO_SELENIUM_TESTS=True - before_install: - - wget https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz - - mkdir geckodriver && tar zxvf geckodriver-v0.27.0-linux64.tar.gz -C geckodriver - - export PATH=$PATH:$PWD/geckodriver - addons: - firefox: latest - postgresql: "9.5" - - python: 3.8 - env: TOXENV=py38-dj22-mariadb - addons: - mariadb: "10.3" - script: - # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160 - - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';" - - mysql -u root -e "CREATE USER 'travis'@'%';" - - mysql -u root -e "CREATE DATABASE debug_toolbar;" - - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';"; - - tox -v - - python: 3.8 - env: TOXENV=py38-dj30-mariadb - addons: - mariadb: "10.3" - script: - # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160 - - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';" - - mysql -u root -e "CREATE USER 'travis'@'%';" - - mysql -u root -e "CREATE DATABASE debug_toolbar;" - - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';"; - - tox -v - - python: 3.8 - env: TOXENV=py38-dj31-mariadb - addons: - mariadb: "10.3" - script: - # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160 - - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';" - - mysql -u root -e "CREATE USER 'travis'@'%';" - - mysql -u root -e "CREATE DATABASE debug_toolbar;" - - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';"; - - tox -v - allow_failures: - - env: TOXENV=py36-djmaster-sqlite - - env: TOXENV=py37-djmaster-sqlite - - env: TOXENV=py38-djmaster-sqlite - - env: TOXENV=py38-djmaster-postgresql - - env: TOXENV=py38-djmaster-mariadb - -install: - - pip install tox codecov -script: - - tox -v -after_success: - - codecov diff --git a/README.rst b/README.rst index 5e02e88b3..8a3c2de93 100644 --- a/README.rst +++ b/README.rst @@ -6,8 +6,8 @@ Django Debug Toolbar :target: https://jazzband.co/ :alt: Jazzband -.. image:: https://travis-ci.org/jazzband/django-debug-toolbar.svg?branch=master - :target: https://travis-ci.org/jazzband/django-debug-toolbar +.. image:: https://github.com/jazzband/django-debug-toolbar/workflows/Test/badge.svg + :target: https://github.com/jazzband/django-debug-toolbar/actions :alt: Build Status .. image:: https://codecov.io/gh/jazzband/django-debug-toolbar/branch/master/graph/badge.svg diff --git a/docs/changes.rst b/docs/changes.rst index cf8c2bf99..e3124d1cf 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,6 +1,11 @@ Change log ========== +unreleased +---------- + +* Moved CI to GitHub Actions: https://github.com/jazzband/django-debug-toolbar/actions + 3.2a1 (2020-10-19) ------------------ From 1ca3e4ac4f05dbb7be26a2aa9b38ab35614cd725 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 15:11:12 +0100 Subject: [PATCH 19/23] Run Selenium on Python 3.8, Django 3.1 and Postgres. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 77355472c..c1f1f2595 100644 --- a/tox.ini +++ b/tox.ini @@ -31,6 +31,7 @@ setenv = PYTHONPATH = {toxinidir} PYTHONWARNINGS = d postgresql: DJANGO_DATABASE_ENGINE = postgresql + py38-dj31-postgresql: DJANGO_SELENIUM_TESTS = true mariadb: DJANGO_DATABASE_ENGINE = mysql whitelist_externals = make pip_pre = True From 9b58a8253d5591e1e2bde8cbfdc739cf303d0171 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 15:26:12 +0100 Subject: [PATCH 20/23] Don't pass DJANGO_SELENIUM_TESTS from CI --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index c1f1f2595..7b7e40391 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,6 @@ deps = sqlparse passenv= CI - DJANGO_SELENIUM_TESTS MYSQL_PORT POSTGRES_PORT setenv = From b52b61a051beb882a10c675f2375289f4bc7c77a Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 17:38:19 +0100 Subject: [PATCH 21/23] Use more test factors to speed up tests. --- .github/workflows/test.yml | 164 ++++++++++++++++++++++++++++++++++--- example/README.rst | 6 +- example/settings.py | 6 +- tests/settings.py | 38 +++------ tox.ini | 33 +++++--- 5 files changed, 192 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66ee47a6d..f392e5bd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Test on: [push, pull_request] jobs: - build: + mysql: runs-on: ubuntu-latest strategy: fail-fast: false @@ -15,23 +15,78 @@ jobs: mariadb: image: mariadb:10.3 env: - MYSQL_ROOT_PASSWORD: debug_toolbar - MYSQL_DATABASE: debug_toolbar - ports: - - 3306/tcp + MYSQL_ROOT_PASSWORD: mysql + MYSQL_DATABASE: mysql options: >- --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5 + ports: + - 3306:3306 + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install enchant (only for docs) + run: | + sudo apt-get -qq update + sudo apt-get -y install enchant + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Test with tox + run: tox + env: + DB_BACKEND: mysql + DB_NAME: mysql + DB_USER: root + DB_PASSWORD: mysql + DB_HOST: "127.0.0.1" + DB_PORT: "3306" + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} + + postgres: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8'] + + services: postgres: image: 'postgres:9.5' env: - POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres ports: - - 5432/tcp + - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s @@ -70,13 +125,98 @@ jobs: python -m pip install --upgrade pip python -m pip install --upgrade tox tox-gh-actions - - name: Tox tests - run: tox -v + - name: Test with tox + run: tox env: - MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }} - POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} + DB_BACKEND: postgresql + DB_NAME: postgres + DB_USER: postgres + DB_PASSWORD: postgres + DB_HOST: localhost + DB_PORT: 5432 - name: Upload coverage uses: codecov/codecov-action@v1 with: name: Python ${{ matrix.python-version }} + + sqlite: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Test with tox + run: tox + env: + DB_BACKEND: sqlite3 + DB_NAME: ":memory:" + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} + + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Get pip cache dir + id: pip-cache + run: | + echo "::set-output name=dir::$(pip cache dir)" + + - name: Cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: + ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox + + - name: Test with tox + run: tox -e docs,style,readme diff --git a/example/README.rst b/example/README.rst index 2b9f41fc2..94c09f8e5 100644 --- a/example/README.rst +++ b/example/README.rst @@ -41,8 +41,8 @@ Run the Django development server:: $ python example/manage.py runserver -You can change the database used by specifying the ``DJANGO_DATABASE_ENGINE`` +You can change the database used by specifying the ``DB_BACKEND`` environment variable:: - $ DJANGO_DATABASE_ENGINE=postgresql python example/manage.py migrate - $ DJANGO_DATABASE_ENGINE=postgresql python example/manage.py runserver + $ DB_BACKEND=postgresql python example/manage.py migrate + $ DB_BACKEND=postgresql python example/manage.py runserver diff --git a/example/settings.py b/example/settings.py index b04d283c8..dae1b591e 100644 --- a/example/settings.py +++ b/example/settings.py @@ -71,8 +71,8 @@ } } -# To use another database, set the DJANGO_DATABASE_ENGINE environment variable. -if os.environ.get("DJANGO_DATABASE_ENGINE", "").lower() == "postgresql": +# To use another database, set the DB_BACKEND environment variable. +if os.environ.get("DB_BACKEND", "").lower() == "postgresql": # % su postgres # % createuser debug_toolbar # % createdb debug_toolbar -O debug_toolbar @@ -83,7 +83,7 @@ "USER": "debug_toolbar", } } -if os.environ.get("DJANGO_DATABASE_ENGINE", "").lower() == "mysql": +if os.environ.get("DB_BACKEND", "").lower() == "mysql": # % mysql # mysql> CREATE DATABASE debug_toolbar; # mysql> CREATE USER 'debug_toolbar'@'localhost'; diff --git a/tests/settings.py b/tests/settings.py index 454e7c3ca..0808c2e8c 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -79,31 +79,19 @@ "second": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, } -if os.environ.get("DJANGO_DATABASE_ENGINE") == "postgresql": - DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql", - "NAME": "debug_toolbar", - "USER": "postgres", - "PASSWORD": "postgres", - "HOST": "localhost", - "PORT": os.environ.get("POSTGRES_PORT", ""), - } - } -elif os.environ.get("DJANGO_DATABASE_ENGINE") == "mysql": - DATABASES = { - "default": { - "ENGINE": "django.db.backends.mysql", - "NAME": "debug_toolbar", - "USER": "root", - "PASSWORD": "debug_toolbar", - "HOST": "127.0.0.1", - "PORT": os.environ.get("MYSQL_PORT", ""), - } - } -else: - DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}} - +DATABASES = { + "default": { + "ENGINE": "django.db.backends.%s" % os.getenv("DB_BACKEND"), + "NAME": os.getenv("DB_NAME"), + "USER": os.getenv("DB_USER"), + "PASSWORD": os.getenv("DB_PASSWORD"), + "HOST": os.getenv("DB_HOST", ""), + "PORT": os.getenv("DB_PORT", ""), + "TEST": { + "USER": "default_test", + }, + }, +} # Debug Toolbar configuration diff --git a/tox.ini b/tox.ini index 7b7e40391..1921606ed 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] envlist = - py38-docs - py38-style - py38-readme + docs + style + readme py{36,37,38}-dj22-sqlite py{36,37,38}-dj{30,31}-sqlite py{36,37,38}-djmaster-sqlite - py{37,38}-dj{22,30,31}-{postgresql,mariadb} + py{37,38}-dj{22,30,31}-{postgresql,mysql} [testenv] deps = @@ -15,7 +15,7 @@ deps = dj31: Django==3.1.* sqlite: mock postgresql: psycopg2-binary - mariadb: mysqlclient + mysql: mysqlclient djmaster: https://github.com/django/django/archive/master.tar.gz coverage Jinja2 @@ -24,25 +24,28 @@ deps = sqlparse passenv= CI - MYSQL_PORT - POSTGRES_PORT + DB_BACKEND + DB_NAME + DB_USER + DB_PASSWORD + DB_HOST + DB_PORT + GITHUB_* setenv = PYTHONPATH = {toxinidir} PYTHONWARNINGS = d - postgresql: DJANGO_DATABASE_ENGINE = postgresql py38-dj31-postgresql: DJANGO_SELENIUM_TESTS = true - mariadb: DJANGO_DATABASE_ENGINE = mysql whitelist_externals = make pip_pre = True commands = make coverage TEST_ARGS='{posargs:tests}' -[testenv:py38-docs] +[testenv:docs] commands = make -C {toxinidir}/docs spelling deps = Sphinx sphinxcontrib-spelling -[testenv:py38-style] +[testenv:style] commands = make style_check deps = black>=19.10b0 @@ -50,7 +53,7 @@ deps = isort>=5.0.2 skip_install = true -[testenv:py38-readme] +[testenv:readme] commands = python setup.py check -r -s deps = readme_renderer skip_install = true @@ -60,3 +63,9 @@ python = 3.6: py36 3.7: py37 3.8: py38 + +[gh-actions:env] +DB_BACKEND = + mysql: mysql + postgresql: postgresql + sqlite3: sqlite From 4ea68eac5a0efef33cb6cc71649ef9a568cd3532 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 17:42:41 +0100 Subject: [PATCH 22/23] Run coverage combine --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 0ddde5fe7..9bdf70d14 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ coverage: python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests} coverage report coverage html + coverage combine coverage xml translatable_strings: From b74c95b1aa962dd3ed27849e66e89f050504f9ce Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 28 Nov 2020 17:44:51 +0100 Subject: [PATCH 23/23] Meh --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 9bdf70d14..0ddde5fe7 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,6 @@ coverage: python -b -W always -m coverage run -m django test -v2 $${TEST_ARGS:-tests} coverage report coverage html - coverage combine coverage xml translatable_strings: