Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tox based on work by Daniel Hahler @blueyed.
Pretty awesome !
- Loading branch information
Showing
10 changed files
with
144 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,94 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.3" | ||
matrix: | ||
exclude: | ||
- python: "3.3" | ||
env: DJANGO=1.4.2 | ||
allow_failures: | ||
- env: TOXENV=py27-djangomaster | ||
- env: TOXENV=py34-djangomaster | ||
python: | ||
- "3.4" | ||
env: | ||
- DJANGO=1.4.2 | ||
- DJANGO=1.5 | ||
- DJANGO=1.6 | ||
- DJANGO=1.7 | ||
- DJANGO=1.8 | ||
global: | ||
- PIP_DISABLE_PIP_VERSION_CHECK=true | ||
matrix: | ||
- TOXENV=py27-django14 | ||
- TOXENV=py27-django15 | ||
- TOXENV=py27-django16 | ||
- TOXENV=py27-django17 | ||
- TOXENV=py27-django18 | ||
- TOXENV=py27-djangomaster | ||
|
||
- TOXENV=py34-django15 | ||
- TOXENV=py34-django16 | ||
- TOXENV=py34-django17 | ||
- TOXENV=py34-django18 | ||
- TOXENV=py34-djangomaster | ||
|
||
- TOXENV=checkqa-python2 | ||
- TOXENV=checkqa | ||
install: | ||
- pip install -q Django==$DJANGO --use-mirrors | ||
- pip install pep8 --use-mirrors | ||
- pip install -q -e . --use-mirrors | ||
# Create pip wrapper script, using travis_retry (a function) and | ||
# inject it into tox.ini. | ||
- mkdir -p bin | ||
- PATH=$PWD/bin:$PATH | ||
- PIP_INSTALL=bin/travis_pip_install | ||
- printf '#!/bin/bash -x\n' > $PIP_INSTALL | ||
- declare -f travis_retry >> $PIP_INSTALL | ||
- printf '\necho "=====\nUsing pip-wrapper for \"$@\"\n=====\n" >&2\n' >> $PIP_INSTALL | ||
# Handle "pip install -e" for usedevelop from tox. | ||
- printf '\nif [ "$1" = "-e" ]; then pip install "$@"; exit $?; fi\n' >> $PIP_INSTALL | ||
# First try to install from wheelhouse. | ||
- printf 'for i in "$@"; do pip install --no-index --find-links=${PIP_WHEELHOUSE} "$i"; done\n' >> $PIP_INSTALL | ||
# Then upgrade in case of outdated wheelhouse. | ||
- printf 'for i in "$@"; do travis_retry pip install --upgrade "$i"; done\n' >> $PIP_INSTALL | ||
# ..and add the new/current wheels. | ||
- printf 'pip wheel --wheel-dir=${PIP_WHEELHOUSE} --find-links=${PIP_WHEELHOUSE} "$@"\n' >> $PIP_INSTALL | ||
- chmod +x $PIP_INSTALL | ||
|
||
# Adjust tox.ini. | ||
- sed -i.bak 's/^\[testenv\]/\0\ninstall_command = travis_pip_install {opts} {packages}/' tox.ini | ||
- diff tox.ini tox.ini.bak && { echo "tox.ini was not changed."; return 1; } || true | ||
- sed -i.bak 's/whitelist_externals =/\0\n travis_pip_install/' tox.ini | ||
- diff tox.ini tox.ini.bak && { echo "tox.ini was not changed."; return 1; } || true | ||
# Inject wheel dependency into tox.ini, for travis_pip_install. | ||
- sed -i.bak -e 's/deps =.*/\0\n wheel/' tox.ini | ||
- diff tox.ini tox.ini.bak && { echo "tox.ini was not changed."; return 1; } || true | ||
# Conditionally inject postgres dependency and DSM setting into tox.ini. | ||
- if [ "$USE_POSTGRES" = 1 ]; then sed -i.bak -e 's/deps =/\0\n psycopg2/' -e 's/DJANGO_SETTINGS_MODULE=test_project.settings/\0_postgres/' tox.ini && diff tox.ini tox.ini.bak && { echo "tox.ini was not changed."; return 1; } || true; fi | ||
- cat $PIP_INSTALL | ||
- cat tox.ini | ||
|
||
# Create wheels (skips existing ones from the cached wheelhouse). | ||
- export PIP_WHEELHOUSE=$PWD/wheelhouse | ||
|
||
- travis_pip_install tox | ||
- if [ -n "$EXTRAREQ" ]; then travis_pip_install $EXTRAREQ; fi | ||
|
||
- pip freeze | ||
before_script: | ||
- "pep8 --exclude=tests,migrations --ignore=E124,E128 rules_light" | ||
- RUN_TESTS="tox -- rules_light" | ||
# Run tests either with or without coverage (being installed). | ||
- command -v coveralls && RUN_TESTS="$RUN_TESTS --cov" || true | ||
before_install: | ||
- npm install phantomjs | ||
- phantomjs --version | ||
script: | ||
- python setup.py test | ||
|
||
- ls -l $PWD/wheelhouse > /tmp/wheelhouse.before | ||
- $RUN_TESTS | ||
- ls -l $PWD/wheelhouse > /tmp/wheelhouse.after | ||
- diff /tmp/wheelhouse.before /tmp/wheelhouse.after || true | ||
- test -d .tox/$TOXENV/log && cat .tox/$TOXENV/log/*.log || true | ||
after_success: | ||
- command -v coveralls && { coveralls; return $?; } || true | ||
notifications: | ||
irc: | ||
channels: | ||
irc: | ||
channels: | ||
- "irc.freenode.org#yourlabs" | ||
template: | ||
- "%{repository} (%{commit} %{author}) : %{message} %{build_url} %{compare_url}" | ||
|
||
# Persistent cache across builds (http://docs.travis-ci.com/user/caching/). | ||
cache: | ||
directories: | ||
- $PWD/wheelhouse | ||
before_cache: | ||
- rm -f .tox/$TOXENV/log/*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[pep8] | ||
ignore = E124,E128 | ||
exclude = example_apps,tests,migrations | ||
|
||
[flake8] | ||
ignore = E124,E128 | ||
exclude = example_apps,tests,migrations,__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Test requirements without Django, to work around https://github.com/pypa/pip/issues/2367. | ||
mock | ||
cssselect | ||
pytest | ||
pytest-django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Tox.ini by @blueyed for django-autocomplete-light | ||
[tox] | ||
envlist = py{27,34}-django{15,16,17,18,master}, py27-django14 | ||
|
||
[testenv] | ||
usedevelop = true | ||
commands = py.test --strict -r fEsxXw {posargs:rules_light} | ||
whitelist_externals = | ||
deps = | ||
django14: Django>=1.4,<1.5 | ||
django15: Django>=1.5,<1.6 | ||
django16: Django>=1.6,<1.7 | ||
django17: Django>=1.7,<1.8 | ||
django18: Django>=1.8,<1.9 | ||
djangostable: Django>=1.8,<1.9 | ||
djangomaster: https://github.com/django/django/archive/master.tar.gz | ||
-rtest_project/test_requirements_without_django.txt | ||
setenv = | ||
DJANGO_SETTINGS_MODULE=test_project.settings | ||
PIP_ALLOW_EXTERNAL=true | ||
PYTHONPATH=test_project | ||
|
||
[testenv:checkqa] | ||
basepython = python3.4 | ||
commands = flake8 rules_light | ||
deps = flake8 | ||
|
||
[testenv:checkqa-python2] | ||
basepython = python2.7 | ||
commands = flake8 rules_light | ||
deps = flake8 |
4db600c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! :)
The changes to .travis.yml should maybe get refactored / put into a script the next time this gets re-used though.. ;)
4db600c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4db600c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, most of it is for tox.
4db600c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4db600c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be #pylib.
Most of this is working around tox not allowing to configure it, e.g. the install_command and should be fixed there / get supported from it.
The other part is making tox's config be different based on an environment (CI/TRAVIS being set).
Not too bad after all.. ;)