diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index d9a46abd..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: 2.1 -orbs: - docker: circleci/docker@0.6.0 - -jobs: - test: - docker: - - image: circleci/python:3.8.0 - executor: docker/docker - steps: - - checkout - - run: - command: pip install --user tox coverage coveralls - name: "Install Tox & Coverage" - - run: - command: tox - name: "Run Tox on All Supported Django and Python Versions" - - run: - command: | - mkdir -p test-results/ - tox -e coverage - name: "Generate Coverage Report" - - run: - command: COVERALLS_REPO_TOKEN=Q58WdUuZOi89XHyDeDsGE2lxUGQ2IfqP3 coveralls - name: "Send results to Coveralls" - - store_test_results: - path: test-results/ - build: - docker: - - image: circleci/python:3.8.0 - executor: docker/docker - steps: - - checkout - - run: - command: python3 setup.py sdist - name: Build - - store_artifacts: - path: dist/ - -workflows: - main: - jobs: - - test - - build: - requires: - - test diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 16eb397b..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -service_name: travis-pro -repo_token: Q58WdUuZOi89XHyDeDsGE2lxUGQ2IfqP3 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 39feedd1..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Release to PyPi -on: [push] - -jobs: - build: - name: Publish - runs-on: ubuntu-latest - steps: - - name: Publish package - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1acccaab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/dj-rest-auth' + 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/dj-rest-auth/upload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..39fcc70e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + + 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.py') }}-${{ hashFiles('**/tox.ini') }} + restore-keys: | + ${{ matrix.python-version }}-v1- + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox tox-gh-actions + + - name: Tox tests + run: | + tox -v + + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: Python ${{ matrix.python-version }} diff --git a/README.md b/README.md index a4fe0e87..4b225173 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Dj-Rest-Auth -[![](https://circleci.com/gh/jazzband/dj-rest-auth.svg?style=svg)](https://app.circleci.com/pipelines/github/jazzband/dj-rest-auth) +[![GitHub Actions](https://github.com/jazzband/dj-rest-auth/workflows/Test/badge.svg)](https://github.com/jazzband/dj-rest-auth/actions) [![Jazzband](https://jazzband.co/static/img/badge.svg)](https://jazzband.co/) -[![Coverage Status](https://coveralls.io/repos/github/jazzband/dj-rest-auth/badge.svg?branch=master)](https://coveralls.io/github/jazzband/dj-rest-auth?branch=master) +[![Coverage Status](https://codecov.io/gh/jazzband/dj-rest-auth/branch/master/graph/badge.svg)](https://codecov.io/gh/jazzband/dj-rest-auth) Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Angular), and Mobile applications. @@ -46,14 +46,7 @@ JWT_AUTH_COOKIE = 'jwt-auth' ### Testing -To run the tests within a virtualenv, run `python runtests.py` from the repository directory. -The easiest way to run test coverage is with [`coverage`](https://pypi.org/project/coverage/), -which runs the tests against all supported Django installs. To run the test coverage -within a virtualenv, run `coverage run ./runtests.py` from the repository directory then run `coverage report`. - -#### Tox - -Testing may also be done using [`tox`](https://pypi.org/project/tox/), which +Testing is done using [`tox`](https://pypi.org/project/tox/), which will run the tests against all supported combinations of python and django. Install tox, either globally or within a virtualenv, and then simply run `tox` diff --git a/dj_rest_auth/__init__.py b/dj_rest_auth/__init__.py index e69de29b..0a09a677 100644 --- a/dj_rest_auth/__init__.py +++ b/dj_rest_auth/__init__.py @@ -0,0 +1,15 @@ +__title__ = "dj-rest-auth" +__description__ = "Authentication and Registration in Django Rest Framework." +__url__ = "http://github.com/jazzband/dj-rest-auth" +__author__ = "@iMerica https://github.com/iMerica" +__author_email__ = "imichael@pm.me" +__license__ = "MIT" +__copyright__ = "Copyright 2020 @iMerica https://github.com/iMerica" + +from pkg_resources import get_distribution, DistributionNotFound + +try: + __version__ = get_distribution("dj-rest-auth").version +except DistributionNotFound: + # package is not installed + __version__ = None diff --git a/dj_rest_auth/__version__.py b/dj_rest_auth/__version__.py deleted file mode 100644 index 5bdb5fef..00000000 --- a/dj_rest_auth/__version__.py +++ /dev/null @@ -1,8 +0,0 @@ -__title__ = 'dj-rest-auth' -__description__ = 'Authentication and Registration in Django Rest Framework.' -__url__ = 'http://github.com/jazzband/dj-rest-auth' -__version__ = '2.1.2' -__author__ = '@iMerica https://github.com/iMerica' -__author_email__ = 'imichael@pm.me' -__license__ = 'MIT' -__copyright__ = 'Copyright 2020 @iMerica https://github.com/iMerica' diff --git a/dj_rest_auth/tests/requirements.pip b/dj_rest_auth/tests/requirements.pip deleted file mode 100644 index 07d4b6b2..00000000 --- a/dj_rest_auth/tests/requirements.pip +++ /dev/null @@ -1,6 +0,0 @@ -coveralls==1.11.1 -django-allauth==0.42.0 -djangorestframework-simplejwt==4.6.0 -flake8==3.8.4 -responses==0.12.1 -unittest-xml-reporting==3.0.4 diff --git a/docs/conf.py b/docs/conf.py index 97831a77..770e0fc0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,12 +12,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os -import sys - -about = {} -with open('../dj_rest_auth/__version__.py', 'r', encoding="utf8") as f: - exec(f.read(), about) +from pkg_resources import get_distribution # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -54,10 +49,9 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = about['__version__'] -# The full version, including alpha/beta/rc tags. -release = about['__version__'] +release = get_distribution('dj-rest-auth').version +# for example take major/minor +version = '.'.join(release.split('.')[:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/disclosure.rst b/docs/disclosure.rst index 5b7619ab..98ba5419 100644 --- a/docs/disclosure.rst +++ b/docs/disclosure.rst @@ -8,8 +8,4 @@ Some basic rules: - Keep it legal. - Respect everyone's privacy. -- Contact the core maintainer(s) immediately if you discover a serious security vulnerability (imichael@pm.me for now). - - - - +- Contact the core maintainer(s) immediately if you discover a serious security vulnerability (security@jazzband.co). diff --git a/docs/index.rst b/docs/index.rst index 8569e550..c4d4bb4b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,9 +9,9 @@ Welcome to dj-rest-auth's documentation! .. note:: dj-rest-auth version 1.0.0 now uses Django Simple JWT. - -.. image:: https://circleci.com/gh/jazzband/dj-rest-auth.svg?style=svg - :target: https://circleci.com/gh/jazzband/dj-rest-auth +.. image:: https://github.com/jazzband/dj-rest-auth/workflows/Test/badge.svg + :target: https://github.com/jazzband/dj-rest-auth/actions + :alt: GitHub Actions Contents -------- diff --git a/runtests.py b/runtests.py deleted file mode 100644 index 3cb605bf..00000000 --- a/runtests.py +++ /dev/null @@ -1,26 +0,0 @@ -# This file mainly exists to allow python setup.py test to work. -# flake8: noqa -import os -import sys - -import django -from django.conf import settings -from django.test.utils import get_runner - -os.environ['DJANGO_SETTINGS_MODULE'] = 'dj_rest_auth.tests.settings' -test_dir = os.path.join(os.path.dirname(__file__), 'dj_rest_auth') -sys.path.insert(0, test_dir) - - - -def runtests(): - TestRunner = get_runner(settings) - test_runner = TestRunner(verbosity=1, interactive=True) - if hasattr(django, 'setup'): - django.setup() - failures = test_runner.run_tests(['dj_rest_auth']) - sys.exit(bool(failures)) - - -if __name__ == '__main__': - runtests() diff --git a/setup.py b/setup.py index f42e4e69..d9866028 100644 --- a/setup.py +++ b/setup.py @@ -10,13 +10,10 @@ f.close() -about = {} -with open('dj_rest_auth/__version__.py', 'r', encoding="utf8") as f: - exec(f.read(), about) - setup( name='dj-rest-auth', - version=about['__version__'], + use_scm_version={"version_scheme": "post-release"}, + setup_requires=["setuptools_scm"], author='iMerica', author_email='imichael@pm.me', url='http://github.com/jazzband/dj-rest-auth', @@ -33,14 +30,6 @@ extras_require={ 'with_social': ['django-allauth>=0.40.0,<0.43.0'], }, - tests_require=[ - 'coveralls>=1.11.1' - 'django-allauth==0.42.0', - 'djangorestframework-simplejwt==4.6.0', - 'responses==0.12.1', - 'unittest-xml-reporting==3.0.4', - ], - test_suite='runtests.runtests', include_package_data=True, python_requires='>=3.5', classifiers=[ diff --git a/dj_rest_auth/tests/__init__.py b/tests/__init__.py similarity index 100% rename from dj_rest_auth/tests/__init__.py rename to tests/__init__.py diff --git a/dj_rest_auth/tests/django_urls.py b/tests/django_urls.py similarity index 100% rename from dj_rest_auth/tests/django_urls.py rename to tests/django_urls.py diff --git a/dj_rest_auth/tests/mixins.py b/tests/mixins.py similarity index 100% rename from dj_rest_auth/tests/mixins.py rename to tests/mixins.py diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 00000000..b8892b15 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,4 @@ +django-allauth==0.42.0 +djangorestframework-simplejwt>=4.4.0 +flake8==3.8.4 +responses==0.12.1 diff --git a/dj_rest_auth/tests/settings.py b/tests/settings.py similarity index 94% rename from dj_rest_auth/tests/settings.py rename to tests/settings.py index e038c45a..e0b5650c 100644 --- a/dj_rest_auth/tests/settings.py +++ b/tests/settings.py @@ -1,12 +1,11 @@ import logging import os -import sys PROJECT_ROOT = os.path.abspath(os.path.split(os.path.split(__file__)[0])[0]) logging.disable(logging.CRITICAL) -ROOT_URLCONF = 'urls' +ROOT_URLCONF = 'tests.urls' STATIC_URL = '/static/' STATIC_ROOT = '%s/staticserve' % PROJECT_ROOT STATICFILES_DIRS = ( @@ -19,7 +18,6 @@ IS_DEV = False IS_STAGING = False IS_PROD = False -IS_TEST = 'test' in sys.argv or 'test_coverage' in sys.argv DATABASES = { 'default': { @@ -72,7 +70,6 @@ ) } -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' TEST_OUTPUT_DIR = 'test-results' INSTALLED_APPS = [ diff --git a/dj_rest_auth/tests/test_api.py b/tests/test_api.py similarity index 100% rename from dj_rest_auth/tests/test_api.py rename to tests/test_api.py diff --git a/dj_rest_auth/tests/test_serializers.py b/tests/test_serializers.py similarity index 96% rename from dj_rest_auth/tests/test_serializers.py rename to tests/test_serializers.py index f4238f47..0fa57049 100644 --- a/dj_rest_auth/tests/test_serializers.py +++ b/tests/test_serializers.py @@ -15,7 +15,7 @@ def validate_is_lower(username: str): custom_username_validators = [validate_is_lower] -validator_path = "dj_rest_auth.tests.test_serializers.custom_username_validators" +validator_path = "tests.test_serializers.custom_username_validators" class TestUserDetailsSerializer(TestCase): diff --git a/dj_rest_auth/tests/test_social.py b/tests/test_social.py similarity index 100% rename from dj_rest_auth/tests/test_social.py rename to tests/test_social.py diff --git a/dj_rest_auth/tests/urls.py b/tests/urls.py similarity index 100% rename from dj_rest_auth/tests/urls.py rename to tests/urls.py diff --git a/tox.ini b/tox.ini index 6b42d3c2..b6063c1c 100644 --- a/tox.ini +++ b/tox.ini @@ -10,28 +10,26 @@ [tox] skipsdist = true envlist = - python{3.5,3.6,3.7,3.8,3.9}-django2 - python{3.6,3.7,3.8,3.9}-django3 + py{36,37,38,39}-dj{2,3} -[testenv] -commands = - python ./runtests.py -deps = - -rdj_rest_auth/tests/requirements.pip - django2: Django>=2.2,<2.3 - django3: Django>=3.1.3 +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38, flake8 + 3.9: py39 -# Configuration for coverage and flake8 is being set in `./setup.cfg` -[testenv:coverage] +[testenv] commands = - coverage run ./runtests.py + coverage run {envbindir}/django-admin test -v 2 --pythonpath=./ --settings=tests.settings coverage report + coverage xml deps = - -rdj_rest_auth/tests/requirements.pip + coverage + -rtests/requirements.txt + dj2: Django>=2.2,<2.3 + dj3: Django>=3.1.3 [testenv:flake8] -changedir = {toxinidir}/dj_rest_auth -commands = - flake8 . -deps = - flake8==3.8.4 +commands = flake8 dj_rest_auth tests +deps = flake8