diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9c249bf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + if: github.repository == 'jazzband/django-defender' + 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-defender/upload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e71faf5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +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', 'pypy3'] + + steps: + - uses: actions/checkout@v2 + + - name: Start Redis + uses: supercharge/redis-github-action@1.1.0 + + - 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/.travis.yml b/.travis.yml deleted file mode 100644 index f6025f1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: python -dist: xenial -cache: pip -python: -- '3.6' -- '3.7' -- '3.8' -- '3.9' -- pypy3 -services: -- redis-server -install: pip install tox-travis codecov -script: tox -after_success: -- codecov -deploy: - provider: pypi - user: jazzband - server: https://jazzband.co/projects/django-defender/upload - distributions: sdist bdist_wheel - skip_existing: true - password: - secure: d/PVFgBDMpG6UvBOxXBLH4vc7+tiPsjhq4YLgXfX0iXbdNHUnnCyDLg/XUQ7x0e7kRj+lhmBzytZxu3IpOY+5MuWk4JTqwoBHGuUlmTC9XEVvioqd/nFW7qVe36YKZHKuMDlmwBNQarJZdSBUFAoCfklZKI09sXA1qc8E3BLAb8= - on: - tags: true - repo: jazzband/django-defender - python: 3.7 diff --git a/CHANGES.rst b/CHANGES.rst index 39c40f0..9132453 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,11 @@ Changes ======= +Unreleased +---------- + +- Move CI to GitHub Actions. + 0.8.0 ----- diff --git a/README.rst b/README.rst index 4187c65..fa68597 100644 --- a/README.rst +++ b/README.rst @@ -14,15 +14,15 @@ django-defender :target: https://pypi.org/project/django-defender/ :alt: Supported Django versions -.. image:: https://travis-ci.org/jazzband/django-defender.svg - :target: https://travis-ci.org/jazzband/django-defender - :alt: Build Status +.. image:: https://github.com/jazzband/django-defender/workflows/Test/badge.svg + :target: https://github.com/jazzband/django-defender/actions + :alt: GitHub Actions .. image:: https://codecov.io/gh/jazzband/django-defender/branch/master/graph/badge.svg :target: https://codecov.io/gh/jazzband/django-defender :alt: Coverage -.. image:: https://readthedocs.org/projects/python-dockerflow/badge/?version=latest +.. image:: https://readthedocs.org/projects/django-defender/badge/?version=latest :alt: Documentation Status :target: https://django-defender.readthedocs.io/en/latest/?badge=latest diff --git a/defender/travis_settings.py b/defender/ci_settings.py similarity index 96% rename from defender/travis_settings.py rename to defender/ci_settings.py index a4942c4..64e1e50 100644 --- a/defender/travis_settings.py +++ b/defender/ci_settings.py @@ -59,7 +59,7 @@ LOGIN_REDIRECT_URL = "/admin" DEFENDER_LOGIN_FAILURE_LIMIT = 10 DEFENDER_COOLOFF_TIME = 2 DEFENDER_REDIS_URL = "redis://localhost:6379/1" -# don't use mock redis in unit tests, we will use real redis on travis. +# don't use mock redis in unit tests, we will use real redis on CI. DEFENDER_MOCK_REDIS = False # Celery settings: @@ -68,7 +68,7 @@ BROKER_BACKEND = "memory" BROKER_URL = "memory://" # set the default Django settings module for the 'celery' program. -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "defender.travis_settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "defender.ci_settings") app = Celery("defender") diff --git a/exampleapp/settings.py b/exampleapp/settings.py index 88b2849..840f2c1 100644 --- a/exampleapp/settings.py +++ b/exampleapp/settings.py @@ -57,7 +57,7 @@ LOGIN_REDIRECT_URL = "/admin" DEFENDER_LOGIN_FAILURE_LIMIT = 1 DEFENDER_COOLOFF_TIME = 60 DEFENDER_REDIS_URL = "redis://localhost:6379/1" -# don't use mock redis in unit tests, we will use real redis on travis. +# don't use mock redis in unit tests, we will use real redis on CI. DEFENDER_MOCK_REDIS = False # Let's use custom function and strip username string from request. DEFENDER_GET_USERNAME_FROM_REQUEST_PATH = ( diff --git a/requirements.txt b/requirements.txt index a5320a1..919b052 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -e . coverage mockredispy -django-redis-cache==2.1.1 -celery<5 +django-redis-cache +celery diff --git a/setup.py b/setup.py index 512dc21..087d2e0 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ setup( packages=find_packages(), package_data=get_package_data("defender"), python_requires='~=3.5', - install_requires=["Django>=2.2,<3.2", "redis<3.6"], + install_requires=["Django", "redis"], tests_require=[ "mockredispy>=2.9.0.11,<3.0", "coverage", diff --git a/tox.ini b/tox.ini index 919835b..0f08f95 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] envlist = # list of supported Django/Python versioons: - py{36,37,38,39,py3}-django{22,30,31,master} + py{36,37,38,39,py3}-dj{22,30,31,master} py38-{lint,docs} -[travis] +[gh-actions] python = 3.6: py36 3.7: py37 @@ -15,14 +15,19 @@ python = [testenv] deps = -rrequirements.txt - django22: django>=2.2,<2.3 - django30: django>=3.0,<3.1 - django31: django>=3.1,<3.2 - djangomaster: https://github.com/django/django/archive/master.tar.gz + dj22: django>=2.2,<2.3 + dj30: django>=3.0,<3.1 + dj31: django>=3.1,<3.2 + djmaster: https://github.com/django/django/archive/master.tar.gz usedevelop = True commands = - {envbindir}/coverage run --source=defender {envbindir}/django-admin test defender --settings=defender.travis_settings + {envbindir}/coverage run --source=defender {envbindir}/django-admin test defender --settings=defender.ci_settings {envbindir}/coverage report -m + {envbindir}/coverage xml + +[testenv:py{36,37,38,39,py3}-dj{master}] +ignore_errors = true +ignore_outcome = true [testenv:py38-docs] basepython = python3.8