Skip to content

Commit

Permalink
GitHub actions updates: split linters & cache config (#513)
Browse files Browse the repository at this point in the history

Co-authored-by: Terence D. Honles <[email protected]>
  • Loading branch information
WisdomPill and terencehonles authored Apr 12, 2021
1 parent 2bc68e5 commit e5e8342
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 59 deletions.
134 changes: 82 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
16 changes: 9 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e5e8342

Please sign in to comment.