From 652a5470a803419482043b437bc33fc8c61b3d6c Mon Sep 17 00:00:00 2001 From: Antoine Cezar Date: Mon, 25 Jan 2016 01:27:26 +0100 Subject: [PATCH] Use docker for mutiple Python version testing Tox as the disaventage to requires all the target versions to be installed on your system. With docker you don't need to touch your system in order to test them all. (aside from having docker) --- CONTRIBUTING.rst | 25 ++++++++++--------------- Makefile | 28 +++++++++++++++++++++++----- docker-test.sh | 10 ++++++++++ requirements_test.txt | 1 - tox.ini | 9 --------- 5 files changed, 43 insertions(+), 30 deletions(-) create mode 100755 docker-test.sh delete mode 100644 tox.ini diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ed626ee..7cdcc57 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -66,7 +66,7 @@ Ready to contribute? Here's how to set up `flockcontext` for local development. $ mkvirtualenv flockcontext $ cd flockcontext/ - $ python setup.py develop + $ make develop 4. Create a branch for local development:: @@ -74,21 +74,23 @@ Ready to contribute? Here's how to set up `flockcontext` for local development. Now you can make your changes locally. -5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: +5. When you're done making changes, check that your changes pass the tests:: + $ make test - $ flake8 flockcontext tests - $ python setup.py test - $ tox +6. Check also that they pass the linter:: + $ pip install flake8 + $ make lint - To get flake8 and tox, just pip install them into your virtualenv. +7. And that they pass other Python versions (requires https://docs.docker.com/):: + $ make test-all -6. Commit your changes and push your branch to GitHub:: +8. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature -7. Submit a pull request through the GitHub website. +9. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- @@ -102,10 +104,3 @@ Before you submit a pull request, check that it meets these guidelines: 3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/AntoineCezar/flockcontext/pull_requests and make sure that the tests pass for all supported Python versions. - -Tips ----- - -To run a subset of tests:: - - $ python -m unittest tests.test_flock diff --git a/Makefile b/Makefile index 4b74d60..edd0ef8 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,12 @@ help: @echo "test - run tests quickly with the default Python" @echo "test-all - run tests on every Python version with tox" @echo "coverage - check code coverage quickly with the default Python" + @echo "coverage-html - check code coverage quickly with the default Python" @echo "docs - generate Sphinx HTML documentation, including API docs" @echo "release - package and upload a release" @echo "dist - package" - @echo "install - install the package to the active Python's site-packages" + @echo "develop - link the package into the active Python's site-packages" + @echo "install - install the package into the active Python's site-packages" clean: clean-build clean-pyc clean-test clean-coverage @@ -42,15 +44,28 @@ lint: test: python setup.py test -test-all: - tox +test-all: test-py27 test-py33 test-py34 test-py35 -coverage: clean-coverage .coverage +test-py27: + ./docker-test.sh python:2.7 + +test-py33: + ./docker-test.sh python:3.3 + +test-py34: + ./docker-test.sh python:3.4 + +test-py35: + ./docker-test.sh python:3.5 + +coverage: .coverage coverage report -m + +coverage-html: .coverage coverage html open htmlcov/index.html -.coverage: +.coverage: clean-coverage coverage run --source flockcontext setup.py test docs: @@ -70,5 +85,8 @@ dist: clean python setup.py bdist_wheel ls -l dist +develop: clean + python setup.py develop + install: clean python setup.py install diff --git a/docker-test.sh b/docker-test.sh new file mode 100755 index 0000000..e718784 --- /dev/null +++ b/docker-test.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +FLAVOUR=$1 +FLAVOUR_SLUG=$(echo "$FLAVOUR" | sed 's/\W/-/') + +docker run --rm -it \ + --name "flockcontext-test-$FLAVOUR_SLUG" \ + -v "$PWD:/home/docker/code" \ + $FLAVOUR \ + /bin/sh -c "cd /home/docker/code && python setup.py install && python setup.py test" diff --git a/requirements_test.txt b/requirements_test.txt index 82248d5..4ebc8ae 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,2 +1 @@ coverage -tox diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 875f9d0..0000000 --- a/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py27, py3 - -[testenv] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/flockcontext -commands = python setup.py test -deps = - -r{toxinidir}/requirements.txt