diff --git a/.gitignore b/.gitignore index ac41fdd8..1207cc48 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,10 @@ pip-delete-this-directory.txt .idea/ # PyTest cache -.cache/ +.pytest_cache/ + +# Coverage +.coverage # Tox .tox/ diff --git a/.travis.yml b/.travis.yml index 2a30c0c5..09cd5729 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ ---- language: python sudo: false cache: pip @@ -6,45 +5,38 @@ cache: pip matrix: include: - python: 2.7 - env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" + env: TOXENV=py27-django111-drf36 - python: 2.7 - env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" + env: TOXENV=py27-django111-drf37 - python: 3.4 - env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" + env: TOXENV=py34-django111-drf36 - python: 3.4 - env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" + env: TOXENV=py34-django111-drf37 - python: 3.4 - env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" + env: TOXENV=py34-django20-drf37 - python: 3.5 - env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" + env: TOXENV=py35-django111-drf36 - python: 3.5 - env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" + env: TOXENV=py35-django111-drf37 - python: 3.5 - env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" + env: TOXENV=py35-django20-drf37 - python: 3.6 - env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" + env: TOXENV=py36-django111-drf36 - python: 3.6 - env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" + env: TOXENV=py36-django111-drf37 - python: 3.6 - env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" -before_install: - # Force an upgrade of py & pytest to avoid VersionConflict - - pip install --upgrade py - # Faker requires a newer pytest - - pip install "pytest>3.3" - - pip install codecov flake8 isort + env: TOXENV=py36-django20-drf37 + - python: 3.6 + env: TOXENV=flake8 + - python: 3.6 + env: TOXENV=isort install: - - pip install Django${DJANGO} djangorestframework${DRF} - - python setup.py install + - pip install tox script: - - flake8 - - isort --check-only --verbose --recursive --diff rest_framework_json_api - # example has extra dependencies that are installed in a dev environment - # but are not installed in CI. Explicitly set those packages. - - isort --check-only --verbose --recursive --diff --thirdparty pytest --thirdparty polymorphic --thirdparty pytest_factoryboy --thirdparty packaging example - - coverage run setup.py -v test + - tox after_success: - - codecov + - pip install codecov + - codecov -e TOXENV diff --git a/setup.cfg b/setup.cfg index 10bd79e4..0e89958c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,11 @@ universal = 1 [flake8] ignore = F405 max-line-length = 100 -exclude = docs/conf.py,build,migrations +exclude = + docs/conf.py, + build, + migrations, + .tox, [isort] indent = 4 @@ -18,3 +22,9 @@ known_standard_library = mock line_length = 100 multi_line_output = 3 skip_glob=*migrations* + +[coverage:report] +omit= + .tox/* + .eggs/* +show_missing = True diff --git a/setup.py b/setup.py index c99639a0..7ff381e2 100755 --- a/setup.py +++ b/setup.py @@ -108,6 +108,7 @@ def get_package_data(package): 'factory-boy', 'pytest-django', 'pytest', + 'pytest-cov', 'django-polymorphic>=2.0', 'packaging', 'django-debug-toolbar' diff --git a/tox.ini b/tox.ini index dc7470e0..c5c341fb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,12 @@ [tox] envlist = py{27,34,35,36}-django111-drf{36,37}, + py{34,35,36}-django20-drf{37}, [testenv] deps = django111: Django>=1.11,<1.12 + django20: Django>=2.0,<2.1 drf36: djangorestframework>=3.6.3,<3.7 drf37: djangorestframework>=3.7.0,<3.8 @@ -13,7 +15,12 @@ setenv = DJANGO_SETTINGS_MODULE=example.settings.test commands = - python setup.py test {posargs} + python setup.py test --addopts '--cov --no-cov-on-fail' {posargs} + +[testenv:flake8] +deps = flake8 +commands = flake8 +skip_install = true [testenv:isort] deps = @@ -22,4 +29,4 @@ commands = isort --check-only --verbose --recursive --diff rest_framework_json_api # example has extra dependencies that are installed in a dev environment # but are not installed in CI. Explicitly set those packages. - isort --check-only --verbose --recursive --diff --thirdparty pytest --thirdparty polymorphic --thirdparty pytest_factoryboy example + isort --check-only --verbose --recursive --diff --thirdparty pytest --thirdparty polymorphic --thirdparty pytest_factoryboy --thirdparty packaging example