From 3ecea398ed61efbdb6d17571196af4cbc94c35a7 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:40:17 +0100 Subject: [PATCH] Add linting to CI --- .github/workflows/code-quality.yml | 2 ++ manage.py | 4 ++-- testsettings.py | 17 +++++++++-------- tox.ini | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 030c95b..d302a43 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -22,6 +22,8 @@ jobs: matrix: toxenv: - isort + - black + - flake8 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/manage.py b/manage.py index 7520d73..819d703 100755 --- a/manage.py +++ b/manage.py @@ -2,8 +2,8 @@ import os import sys -if __name__ == '__main__': - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testsettings') +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsettings") from django.core.management import execute_from_command_line diff --git a/testsettings.py b/testsettings.py index c54e376..e7e1c0c 100644 --- a/testsettings.py +++ b/testsettings.py @@ -1,23 +1,24 @@ - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", } } -ALLOWED_HOSTS = ['example.com',] +ALLOWED_HOSTS = [ + "example.com", +] INSTALLED_APPS = [ - 'django.contrib.sites', - 'regex_redirects', + "django.contrib.sites", + "regex_redirects", ] SECRET_KEY = "notimportant" APPEND_SLASH = False -MIDDLEWARE = ['regex_redirects.middleware.RedirectFallbackMiddleware'] +MIDDLEWARE = ["regex_redirects.middleware.RedirectFallbackMiddleware"] SITE_ID = 1 diff --git a/tox.ini b/tox.ini index a530551..b029965 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,8 @@ envlist = py{38,39,310}-django{32,42} py3{11,12}-django{41,42} isort + black + flake8 skip_missing_interpreters = true [gh-actions] @@ -24,3 +26,18 @@ deps= django42: Django~=4.2.0 commands = python manage.py test regex_redirects + +[testenv:isort] +extras = tests +skipsdist = True +commands = isort --check-only --diff . + +[testenv:black] +extras = tests +skipsdist = True +commands = black --check regex_redirects testsettings.py manage.py + +[testenv:flake8] +extras = tests +skipsdist = True +commands = flake8 .