diff --git a/.github/workflows/setup-and-run-tests.yml b/.github/workflows/setup-and-run-tests.yml new file mode 100644 index 0000000..5a6354f --- /dev/null +++ b/.github/workflows/setup-and-run-tests.yml @@ -0,0 +1,24 @@ +name: Setup django-redis-metrics and run tests + +on: push + +jobs: + setup-and-run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [ "3.9", "3.10", "3.11" ] + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: "actions/setup-python@v4" + with: + python-version: "${{ matrix.python-version }}" + + - name: Run make install_requirements + run: make install_requirements + + - name: run make test + run: make test diff --git a/Makefile b/Makefile index 3e04349..8274fd5 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,14 @@ build: .PHONY: upload upload: - python -m twine upload --repository pypi dist/* \ No newline at end of file + python -m twine upload --repository pypi dist/* + +.PHONY: test +test: + python runtest.py + +.PHONY: install_requirements +install_requirements: + pip install --upgrade pip + pip install --upgrade pip-tools + pip install -r requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt index 7721a4d..3429915 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --config=pyproject.toml --no-emit-index-url --output-file=docs/requirements.txt docs/requirements.in +# pip-compile --no-emit-index-url --output-file=docs/requirements.txt docs/requirements.in # alabaster==0.7.13 # via sphinx @@ -32,7 +32,7 @@ packaging==23.1 # via # build # sphinx -pip-tools==7.2.0 +pip-tools==7.3.0 # via -r docs/requirements.in pygments==2.16.1 # via sphinx @@ -50,17 +50,17 @@ sphinx==7.1.2 # sphinxcontrib-htmlhelp # sphinxcontrib-qthelp # sphinxcontrib-serializinghtml -sphinxcontrib-applehelp==1.0.5 +sphinxcontrib-applehelp==1.0.6 # via sphinx -sphinxcontrib-devhelp==1.0.3 +sphinxcontrib-devhelp==1.0.4 # via sphinx -sphinxcontrib-htmlhelp==2.0.2 +sphinxcontrib-htmlhelp==2.0.3 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.4 +sphinxcontrib-qthelp==1.0.5 # via sphinx -sphinxcontrib-serializinghtml==1.1.6 +sphinxcontrib-serializinghtml==1.1.7 # via sphinx urllib3==2.0.4 # via requests diff --git a/requirements.in b/requirements.in index 2795a77..f0d8088 100644 --- a/requirements.in +++ b/requirements.in @@ -7,6 +7,8 @@ isort coverage redis django +django-redis +django-user-sessions sphinx -toml; python_version < '3.11' -twine \ No newline at end of file +toml +twine diff --git a/requirements.txt b/requirements.txt index 88bf166..1ff5389 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,8 +8,6 @@ alabaster==0.7.13 # via sphinx asgiref==3.7.2 # via django -async-timeout==4.0.2 - # via redis babel==2.12.1 # via sphinx black==23.7.0 @@ -22,8 +20,6 @@ build==0.10.0 # pip-tools certifi==2023.7.22 # via requests -cffi==1.15.1 - # via cryptography charset-normalizer==3.2.0 # via requests click==8.1.6 @@ -32,9 +28,14 @@ click==8.1.6 # pip-tools coverage==7.2.7 # via -r requirements.in -cryptography==41.0.3 - # via secretstorage django==4.2.4 + # via + # -r requirements.in + # django-redis + # django-user-sessions +django-redis==5.3.0 + # via -r requirements.in +django-user-sessions==2.0.0 # via -r requirements.in docutils==0.20.1 # via @@ -54,10 +55,6 @@ isort==5.12.0 # via -r requirements.in jaraco-classes==3.3.0 # via keyring -jeepney==0.8.0 - # via - # keyring - # secretstorage jinja2==3.1.2 # via sphinx keyring==24.2.0 @@ -81,7 +78,7 @@ packaging==23.1 # sphinx pathspec==0.11.2 # via black -pip-tools==7.2.0 +pip-tools==7.3.0 # via -r requirements.in pkginfo==1.9.6 # via twine @@ -89,8 +86,6 @@ platformdirs==3.10.0 # via black pycodestyle==2.11.0 # via flake8 -pycparser==2.21 - # via cffi pyflakes==3.1.0 # via flake8 pygments==2.16.1 @@ -103,7 +98,9 @@ pyproject-hooks==1.0.0 readme-renderer==40.0 # via twine redis==4.6.0 - # via -r requirements.in + # via + # -r requirements.in + # django-redis requests==2.31.0 # via # requests-toolbelt @@ -115,8 +112,6 @@ rfc3986==2.0.0 # via twine rich==13.5.2 # via twine -secretstorage==3.3.3 - # via keyring six==1.16.0 # via bleach snowballstemmer==2.2.0 @@ -129,20 +124,22 @@ sphinx==7.1.2 # sphinxcontrib-htmlhelp # sphinxcontrib-qthelp # sphinxcontrib-serializinghtml -sphinxcontrib-applehelp==1.0.5 +sphinxcontrib-applehelp==1.0.6 # via sphinx -sphinxcontrib-devhelp==1.0.3 +sphinxcontrib-devhelp==1.0.4 # via sphinx -sphinxcontrib-htmlhelp==2.0.2 +sphinxcontrib-htmlhelp==2.0.3 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.4 +sphinxcontrib-qthelp==1.0.5 # via sphinx -sphinxcontrib-serializinghtml==1.1.6 +sphinxcontrib-serializinghtml==1.1.7 # via sphinx sqlparse==0.4.4 # via django +toml==0.10.2 + # via -r requirements.in twine==4.0.2 # via -r requirements.in urllib3==2.0.4 diff --git a/runtest.py b/runtest.py new file mode 100644 index 0000000..64c6977 --- /dev/null +++ b/runtest.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +import sys + +try: + import django + from django.conf import settings + from django.test.utils import get_runner + + settings.configure( + DEBUG=True, + USE_TZ=True, + DATABASES={ + "default": { + "ENGINE": "django.db.backends.sqlite3", + } + }, + ROOT_URLCONF="redis_metrics.urls", + INSTALLED_APPS=[ + "django.contrib.auth", + "django.contrib.contenttypes", + "user_sessions", + "django_redis", + "django.contrib.sessions", + "redis_metrics", + ], + MIDDLEWARE=[ + "django.contrib.sessions.middleware.SessionMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + ], + SECRET_KEY="notasecret", + NOSE_ARGS=["-s"], + TEMPLATES=[ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": ["redis_metrics/templatetags", "redis_metrics/templates"], + } + ], + ) + django.setup() +except ImportError: + raise ImportError("To fix this error, run: pip install -r requirements.txt") + + +if __name__ == "__main__": + TestRunner = get_runner(settings) + test_runner = TestRunner() + failures = test_runner.run_tests(["redis_metrics.tests"]) + sys.exit(bool(failures))