diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ed44f29..306600cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,11 @@ on: [push, pull_request] jobs: test: - name: Test Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, Redis.py ${{ matrix.redis-version }} + name: > + Test Python ${{ matrix.python-version }}, + Django ${{ matrix.django-version }}, + Redis.py ${{ matrix.redis-version }} + runs-on: ubuntu-latest strategy: @@ -40,67 +44,93 @@ jobs: 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: - env_vars: DJANGO,REDIS,PYTHON - env: - DJANGO: ${{ matrix.django-version }} - REDIS: ${{ matrix.redis-version }} - PYTHON: ${{ matrix.python-version }} + - 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: pip-test-python-${{ matrix.python-version }}-django-${{ matrix.django-version }}-redis-${{ matrix.redis-version }}-${{ hashFiles('**/setup.*') }} + restore-keys: | + pip-test-python-${{ matrix.python-version }}-django-${{ matrix.django-version }}-redis-${{ matrix.redis-version }} + pip-test-python-${{ matrix.python-version }} + pip-test- + + - 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: + env_vars: DJANGO,REDIS,PYTHON + env: + DJANGO: ${{ matrix.django-version }} + REDIS: ${{ matrix.redis-version }} + PYTHON: ${{ matrix.python-version }} lint: - name: Lint + name: Lint (${{ matrix.tool }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + tool: + - 'black' + - 'flake8' + - 'isort' + steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - 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: pip-lint-${{ hashFiles('**/setup.*') }} + restore-keys: | + pip-lint- - name: Install dependencies - run: python -m pip install tox + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade tox - name: Run - run: tox -e lint + run: tox -e ${{ matrix.tool }} diff --git a/setup.cfg b/setup.cfg index fc1aebb0..9cd3054a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -59,7 +59,9 @@ profile = black [tox:tox] minversion = 3.15.0 envlist = - lint + black + flake8 + isort # tests against released versions py{36,37,38,39}-dj{22,31,32}-redislatest # tests against unreleased versions @@ -70,7 +72,7 @@ envlist = python = 3.6: py36 3.7: py37 - 3.8: py38, lint + 3.8: py38, black, flake8, isort 3.9: py39 [gh-actions:env] @@ -110,19 +112,19 @@ deps = redismaster: https://github.com/andymccurdy/redis-py/archive/master.tar.gz lz4>=0.15 -[testenv:lint] +[testenv:{black,flake8,isort}] basepython = python3 +envdir={toxworkdir}/lint 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/ + black: black --target-version py36 {posargs:--check --diff} setup.py django_redis/ tests/ + flake8: flake8 {posargs} setup.py django_redis/ tests/ + isort: isort {posargs:--check-only --diff} django_redis/ tests/ deps = black flake8 isort >= 5.0.2 skip_install = true - [tool:pytest] DJANGO_SETTINGS_MODULE = settings.sqlite