Skip to content

Commit

Permalink
Use tox for running tests in CI and running dev commands
Browse files Browse the repository at this point in the history
...for better parity between local dev and Travis. This also
simplifies setting up a local dev environment.

Implements the proposal in marshmallow-code#1020 (comment)

Close marshmallow-code#1020
  • Loading branch information
sloria committed Oct 27, 2018
1 parent 25e773a commit e4de670
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 151 deletions.
47 changes: 23 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
# Config file for automatic testing at travis-ci.org

language: python
# http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
sudo: false
cache: pip
python:
- "3.6"
- "3.5"
- "3.4"
- "2.7"
- "2.6"
- "pypy"

before_install:
- pip install -U pip
# Workaround for travis issue: https://github.com/marshmallow-code/marshmallow/issues/681
- pip install -U six

install:
- pip install -U .[reco]
- pip install -U -r dev-requirements.txt
install: travis_retry pip install -U tox

script: invoke test
script: tox
jobs:
fast_finish: true

include:
- python: '3.6'
env: TOXENV=lint
- python: '2.6'
env: TOXENV=py26
- python: '2.7'
env: TOXENV=py27
- python: '3.4'
env: TOXENV=py34
- python: '3.5'
env: TOXENV=py35
- python: '3.6'
env: TOXENV=py36
- python: 'pypy'
env: TOXENV=pypy
- python: '3.6'
env: TOXENV=docs

- stage: PyPI Release
if: tag IS present
python: "3.6"
env: []
# Override before_install, install, and script to no-ops
before_install: true
install: true
script: echo "Releasing to PyPI..."
after_success: true
install: skip
script: skip
deploy:
provider: pypi
user: sloria
Expand Down
31 changes: 10 additions & 21 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Setting Up for Local Development
$ git clone https://github.com/marshmallow-code/marshmallow.git
$ cd marshmallow

2. Install development requirements. It is highly recommended that you use a virtualenv. ::
2. Install development requirements. **It is highly recommended that you use a virtualenv.**
Use the following command to install an editable version of
marshmallow along with its development requirements.

# After activating your virtualenv
$ pip install -r dev-requirements.txt

3. Install marshmallow in develop mode. ::
::

$ pip install -e .
# After activating your virtualenv
$ pip install -e '.[dev]'

Git Branch Structure
********************
Expand Down Expand Up @@ -104,9 +104,9 @@ Running tests

To run all tests: ::

$ invoke test
$ pytest

To run tests on Python 2.6, 2.7, 3.4, 3.5, and PyPy virtual environments (must have each interpreter installed): ::
(Optional) To run tests on Python 2.6, 2.7, 3.4, 3.5, and PyPy virtual environments (must have each interpreter installed): ::

$ tox

Expand All @@ -117,20 +117,9 @@ Documentation

Contributions to the documentation are welcome. Documentation is written in `reStructured Text`_ (rST). A quick rST reference can be found `here <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_. Builds are powered by Sphinx_.

To install the packages for building the docs, run the following in the root of the project: ::

$ pip install -r docs/requirements.txt

To build the docs: ::

$ invoke docs -b

The ``-b`` (for "browse") automatically opens up the docs in your browser after building.

You can also build the docs in "watch" mode: ::
To build the docs in "watch" mode: ::

$ pip install sphinx-autobuild
$ invoke docs -wb
$ tox -e watch-docs

Changes in the `docs/` directory will automatically trigger a rebuild.

Expand Down
15 changes: 0 additions & 15 deletions dev-requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
import marshmallow # flake8: noqa
import marshmallow # noqa
from marshmallow.compat import OrderedDict

# -- General configuration -----------------------------------------------------
Expand Down
19 changes: 17 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
import re
from setuptools import setup, find_packages

EXTRA_REQUIREMENTS = ['python-dateutil', 'simplejson']
EXTRAS_REQUIRE = {
'reco': ['python-dateutil', 'simplejson'],
'tests': [
'pytest==3.9.2',
'pytz',
],
'lint': [
'flake8==2.4.1',
],
}
EXTRAS_REQUIRE['dev'] = (
EXTRAS_REQUIRE['reco'] +
EXTRAS_REQUIRE['tests'] +
EXTRAS_REQUIRE['lint'] +
['tox']
)

def find_version(fname):
"""Attempts to find the version number in the file names fname.
Expand Down Expand Up @@ -41,7 +56,7 @@ def read(fname):
packages=find_packages(exclude=('test*', 'examples')),
package_dir={'marshmallow': 'marshmallow'},
include_package_data=True,
extras_require={'reco': EXTRA_REQUIREMENTS},
extras_require=EXTRAS_REQUIRE,
license='MIT',
zip_safe=False,
keywords=('serialization', 'rest', 'json', 'api', 'marshal',
Expand Down
83 changes: 0 additions & 83 deletions tasks.py

This file was deleted.

41 changes: 36 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
[tox]
envlist=py26,py27,py34,py35,pypy
envlist = lint,py26,py27,py34,py35,pypy,docs

[testenv]
deps=
-rdev-requirements.txt
commands=
invoke test
extras = tests,reco
commands = pytest {posargs}

[testenv:lint]
extras = lint
commands = flake8 .

[testenv:py26]
commands = pytest --ignore=tests/test_py3/ {posargs}

[testenv:pypy]
commands = pytest --ignore=tests/test_py3/ {posargs}

[testenv:py27]
commands = pytest --ignore=tests/test_py3/ {posargs}

[testenv:docs]
deps = -rdocs/requirements.txt
extras =
commands = sphinx-build docs/ docs/_build {posargs}

; Below tasks are for development only (not run in CI)

[testenv:watch-docs]
deps =
-rdocs/requirements.txt
sphinx-autobuild
extras =
commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} -z marshmallow

[testenv:watch-readme]
deps = restview
skip_install = true
commands = restview README.rst

0 comments on commit e4de670

Please sign in to comment.