diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a96ffdc..9c8b17c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,21 +6,61 @@ jobs: build: runs-on: ubuntu-latest + services: + memcached: + image: memcached + ports: + - 11211:11211 strategy: + fail-fast: false matrix: - python-version: [3.5, 3.6, 3.7, 3.8] - django: [2.2, 3.0, 3.1, master] + python-version: ['3.6', '3.7', '3.8', '3.9'] + django: ['2.2', '3.1', '3.2', 'main'] + memcache: ['pylibmc', 'pymemcache', 'python-memcached'] exclude: - - python-version: 3.5 - django: 3.0 - - python-version: 3.5 - django: 3.1 - - python-version: 3.5 - django: master - - python-version: 3.6 - django: master - - python-version: 3.7 - django: master + - python-version: '3.6' + django: 'main' + memcache: 'pylibmc' + - python-version: '3.6' + django: 'main' + memcache: 'pymemcache' + - python-version: '3.6' + django: 'main' + memcache: 'python-memcached' + - python-version: '3.7' + django: 'main' + memcache: 'pylibmc' + - python-version: '3.7' + django: 'main' + memcache: 'pymemcache' + - python-version: '3.7' + django: 'main' + memcache: 'python-memcached' + + - memcache: 'pymemcache' + django: '2.2' + python-version: '3.6' + - memcache: 'pymemcache' + django: '2.2' + python-version: '3.7' + - memcache: 'pymemcache' + django: '2.2' + python-version: '3.8' + - memcache: 'pymemcache' + django: '2.2' + python-version: '3.9' + - memcache: 'pymemcache' + django: '3.1' + python-version: '3.6' + - memcache: 'pymemcache' + django: '3.1' + python-version: '3.7' + - memcache: 'pymemcache' + django: '3.1' + python-version: '3.8' + - memcache: 'pymemcache' + django: '3.1' + python-version: '3.9' steps: - uses: actions/checkout@v2 @@ -28,12 +68,16 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install PyLibMC Dependencies + if: ${{ matrix.memcache == 'pylibmc' }} + run: | + sudo apt-get install -y libmemcached-dev zlib1g-dev - name: Install dependencies run: | python -m pip install --upgrade pip - if [[ ${{ matrix.django }} != master ]]; then pip install --pre -q "Django>=${{ matrix.django }},<${{ matrix.django }}.99"; fi - if [[ ${{ matrix.django }} == master ]]; then pip install https://github.com/django/django/archive/master.tar.gz; fi - pip install flake8 django-redis python3-memcached + if [[ ${{ matrix.django }} != main ]]; then pip install --pre -q "Django>=${{ matrix.django }},<${{ matrix.django }}.99"; fi + if [[ ${{ matrix.django }} == main ]]; then pip install https://github.com/django/django/archive/main.tar.gz; fi + pip install flake8 django-redis ${{ matrix.memcache }} - name: Lint with flake8 run: | ./run.sh flake8 diff --git a/test_settings.py b/test_settings.py index d84fa9c..c1815b2 100644 --- a/test_settings.py +++ b/test_settings.py @@ -1,3 +1,14 @@ +try: + import pylibmc # noqa: F401 + memcache_backend = "PyLibMCCache" +except ImportError: + try: + import pymemcache # noqa: F401 + memcache_backend = "PyMemcacheCache" + except ImportError: + import memcache # noqa: F401 + memcache_backend = "MemcachedCache" + SECRET_KEY = 'ratelimit' INSTALLED_APPS = ( @@ -12,8 +23,8 @@ 'LOCATION': 'ratelimit-tests', }, 'connection-errors': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': 'test-connection-errors', + 'BACKEND': f'django.core.cache.backends.memcached.{memcache_backend}', + 'LOCATION': '127.0.0.1:57823', }, 'connection-errors-redis': { 'BACKEND': 'django_redis.cache.RedisCache', diff --git a/tox.ini b/tox.ini index 35e711f..266aa8f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,21 @@ [tox] envlist = - py34-django{111,20}, - py35-django{111,20,21,22b}, - py36-django{111,20,21,22b,master}, - py37-django{20,21,22b,master}, - pypy35-django{111,20,21,22b,master}, + py36-django-{22,31,32}-{pylibmc,python-memcached,pymemcache}, + py37-django-{22,31,32}-{pylibmc,python-memcached,pymemcache}, + py38-django{22,31,32,main}-{pylibmc,python-memcached,pymemcache}, + py39-django{22,31,32,main}-{pylibmc,python-memcached,pymemcache}, + pypy36-django{22,31,32,main}-{pylibmc,python-memcached,pymemcache}, [testenv] deps = - django111: Django>=1.11,<1.12 - django20: Django>=2.0,<2.1 - django21: Django>=2.1,<2.2 - django22b: https://github.com/django/django/archive/stable/2.2.x.tar.gz - djangomaster: https://github.com/django/django/archive/master.tar.gz - python3-memcached>=1.51 - django-redis==4.10.0 + django22: Django>=2.2,<3.0 + django31: Django>=3.1,<3.2 + django32: Django>=3.2,<3.3 + djangomain: -e git+https://github.com/django/django.git#egg=django + python-memcached + pylibmc + pymemcache + django-redis flake8 commands =