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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..f392e5bd0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,222 @@ +name: Test + +on: [push, pull_request] + +jobs: + mysql: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8'] + + services: + mariadb: + image: mariadb:10.3 + env: + 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_PASSWORD: postgres + ports: + - 5432:5432 + 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) + 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: 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/.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/.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/Makefile b/Makefile index cab610452..0ddde5fe7 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 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/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: 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 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) ------------------ 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 dbbbb79b2..0808c2e8c 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -79,17 +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"} - } -elif os.environ.get("DJANGO_DATABASE_ENGINE") == "mysql": - DATABASES = { - "default": {"ENGINE": "django.db.backends.mysql", "NAME": "debug_toolbar"} - } -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/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 91ff4277b..1921606ed 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ envlist = 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 @@ -23,13 +23,18 @@ deps = selenium sqlparse passenv= - TRAVIS - DJANGO_SELENIUM_TESTS + CI + DB_BACKEND + DB_NAME + DB_USER + DB_PASSWORD + DB_HOST + DB_PORT + GITHUB_* setenv = PYTHONPATH = {toxinidir} PYTHONWARNINGS = d - postgresql: DJANGO_DATABASE_ENGINE = postgresql - mariadb: DJANGO_DATABASE_ENGINE = mysql + py38-dj31-postgresql: DJANGO_SELENIUM_TESTS = true whitelist_externals = make pip_pre = True commands = make coverage TEST_ARGS='{posargs:tests}' @@ -41,7 +46,6 @@ deps = sphinxcontrib-spelling [testenv:style] -basepython = python3 commands = make style_check deps = black>=19.10b0 @@ -50,7 +54,18 @@ deps = skip_install = true [testenv:readme] -basepython = python3 commands = python setup.py check -r -s deps = readme_renderer skip_install = true + +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + +[gh-actions:env] +DB_BACKEND = + mysql: mysql + postgresql: postgresql + sqlite3: sqlite