Skip to content

Use tox to run test in travis #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2018
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ pip-delete-this-directory.txt
.idea/

# PyTest cache
.cache/
.pytest_cache/

# Coverage
.coverage

# Tox
.tox/
Expand Down
46 changes: 19 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
---
language: python
sudo: false
cache: pip
# Favor explicit over implicit and use an explicit build matrix.
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
12 changes: 11 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def get_package_data(package):
'factory-boy',
'pytest-django',
'pytest',
'pytest-cov',
'django-polymorphic>=2.0',
'packaging',
'django-debug-toolbar'
Expand Down
11 changes: 9 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 =
Expand All @@ -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