Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: CI

on: [push, pull_request]

jobs:
test:
name: Test Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, Redis.py ${{ matrix.redis-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
django-version:
- '2.2'
- '3.1'
- '3.2'
redis-version:
- 'latest'

# only test pre-release dependencies for the latest Python
include:
# latest Django with pre-release redis
- django-version: '3.2'
redis-version: 'master'
python-version: '3.9'

# latest redis with pre-release Django
- django-version: 'main'
redis-version: 'latest'
python-version: '3.9'

# pre-release Django and redis
- django-version: 'main'
redis-version: 'master'
python-version: '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 dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions

- name: Tox tests
run: |
REDIS_PRIMARY=$(tests/start_redis.sh)
REDIS_SENTINEL=$(tests/start_redis.sh --sentinel)
CONTAINERS="$REDIS_PRIMARY $REDIS_SENTINEL"
trap "docker stop $CONTAINERS && docker rm $CONTAINERS" EXIT
tests/wait_for_redis.sh $REDIS_PRIMARY 6379
tests/wait_for_redis.sh $REDIS_SENTINEL 26379

tox
env:
DJANGO: ${{ matrix.django-version }}
REDIS: ${{ matrix.redis-version }}

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Install dependencies
run: python -m pip install tox

- name: Run
run: tox -e lint
20 changes: 0 additions & 20 deletions .github/workflows/lint.yml

This file was deleted.

120 changes: 0 additions & 120 deletions .github/workflows/test.yml

This file was deleted.

6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Redis cache backend for Django
:target: https://jazzband.co/
:alt: Jazzband

.. image:: https://github.com/jazzband/django-redis/workflows/Test/badge.svg
:target: https://github.com/jazzband/django-redis/actions
[![Test]()]()

.. image:: https://github.com/jazzband/django-redis/actions/workflows/ci.yml/badge.svg
:target: https://github.com/jazzband/django-redis/actions/workflows/ci.yml
:alt: GitHub Actions

.. image:: https://codecov.io/gh/jazzband/django-redis/branch/master/graph/badge.svg
Expand Down
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

61 changes: 60 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ classifiers =
Environment :: Web Environment
Framework :: Django
Framework :: Django :: 2.2
Framework :: Django :: 3.0
Framework :: Django :: 3.1
Framework :: Django :: 3.2
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Expand Down Expand Up @@ -46,3 +46,62 @@ max-line-length = 88

[isort]
profile = black

[tox:tox]
minversion = 3.15.0
envlist =
lint
# tests against released versions
py{36,37,38,39}-dj{22,31,32}-redislatest
# tests against unreleased versions
py39-dj32-redismaster
py39-djmain-redis{latest,master}

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, lint
3.9: py39

[gh-actions:env]
DJANGO =
2.2: dj22
3.1: dj31
3.2: dj32
main: djmain
REDIS =
latest: redislatest
master: redismaster

[testenv]
commands =
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_json {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_lz4 {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_msgpack {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_sentinel {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_sharding {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_usock {posargs}
{envpython} -b -Wa tests/runtests.py --settings=settings.sqlite_zlib {posargs}

deps =
dj22: Django>=2.2,<2.3
dj31: Django>=3.1,<3.2
dj32: Django>=3.2,<3.3
djmain: https://github.com/django/django/archive/main.tar.gz
msgpack>=0.6.0
redismaster: https://github.com/andymccurdy/redis-py/archive/master.tar.gz
lz4>=0.15

[testenv:lint]
basepython = python3
commands =
black --target-version py36 --check --diff setup.py django_redis/ tests/
flake8 setup.py django_redis/ tests/
isort --check-only --diff django_redis/ tests/
deps =
black
flake8
isort >= 5.0.2
skip_install = true
36 changes: 15 additions & 21 deletions tests/README.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
Test requirements
-----------------
Running the test suite
----------------------

Python packages
~~~~~~~~~~~~~~~
.. code-block:: bash

Install the development requirements using the requirements.txt file:
# start redis and a sentinel (uses docker with image redis:latest)
PRIMARY=$(tests/start_redis.sh)
SENTINEL=$(tests/start_redis.sh --sentinel)

pip install -r requirements.txt
# or just wait 5 - 10 seconds and most likely this would be the case
tests/wait_for_redis.sh $PRIMARY 6379
tests/wait_for_redis.sh $SENTINEL 26379

redis
~~~~~
# run the tests
tox

* redis listening on default socket 127.0.0.1:6379
* for runtests-sentinel.py: redis sentinel listening on default socket
127.0.0.1:26379 with the following config:

sentinel monitor default_service 127.0.0.1 6379 1
sentinel down-after-milliseconds default_service 3200
sentinel failover-timeout default_service 10000
sentinel parallel-syncs default_service 1

After this, run this command:

python runtests.py
python runtests.py <test_file>.<TestClass>.<MethodName>
# shut down redis
for container in $PRIMARY $SENTINEL; do
docker stop $container && docker rm $container
done
12 changes: 0 additions & 12 deletions tests/runtests-herd.py

This file was deleted.

Loading