Git Product home page Git Product logo

docker-tox's Introduction

Tox

Available on Docker Hub as themattrix/tox.

This image is intended for running tox with Python 2.6, 2.7, 3.3, 3.4, 3.5, PyPy, and PyPy3. Its goal is to make testing your code against multiple Python versions quick and easy. The image contains several ONBUILD commands for initializing the tox environments with your project's requirements.txt files.

Usage

The Dockerfile contains the following ONBUILD commands:

ONBUILD COPY install-prereqs*.sh requirements*.txt tox.ini /app/
ONBUILD ARG SKIP_TOX=false
ONBUILD RUN bash -c " \
    if [ -f '/app/install-prereqs.sh' ]; then \
        bash /app/install-prereqs.sh; \
    fi && \
    if [ $SKIP_TOX == false ]; then \
        TOXBUILD=true tox; \
    fi"

This means your project must contain a tox.ini file.

You can also optionally include an install-prereqs.sh script for installing prerequisites of the project requirements.

To avoid the tox environments being rebuilt every time you want to test your code, tox is run twice - first with the TOXBUILD environment variable set to true, and second without it being set:

  1. $ TOXBUILD=true tox

    Executed during the build phase to initialize all of the environments. It is expected not to install your code nor run your tests; it should only install the requirements which your project needs to be tested.

    This step can be skipped by specifying --build-arg SKIP_TOX=true in the build phase.

  2. $ tox

    Executed during the run phase to test your code.

When your requirements or tox configuration changes, both steps are run. When your code changes, only the second step is run, saving valuable time. This also ensures that your code is always tested in a completely clean environment.

Example tox.ini supporting the TOXBUILD environment variable:

[tox]
envlist = py26,py27,py33,py34,py35,pypy,pypy3
skipsdist = {env:TOXBUILD:false}

[testenv]
passenv = LANG
whitelist_externals = true
deps =
    -rrequirements_test_runner.txt
    -rrequirements_static_analysis.txt
    -rrequirements_test.txt
commands = {env:TOXBUILD:./tests.sh --static-analysis}

For a full example, see the python-pypi-template project, which uses this image.

docker-tox's People

Contributors

themattrix avatar saulshanabrook avatar marx314 avatar

Watchers

James Cloos avatar Radosław Roszkowiak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.