Skip to content

Commit 7400569

Browse files
committed
Create tox.rst
tox.rst explains how to set up coala in tox properly. Update tox.rst Update tox.rst Update tox.rst Update tox.rst Update tox.rst tox.rst: Documentation file for coala in tox This file ensures that coala is successfully installed in tox properly. Closes coala#344 Update tox.rst Update tox.rst sample tox.rst tox.rst: explains how to setup coala with tox closes coala#344
1 parent a247a76 commit 7400569

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

Users/tox.rst

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
What is Tox?
2+
===============
3+
4+
tox is a generic virtualenv management and test command line tool you can use
5+
for:
6+
7+
- checking your package installs correctly with different Python versions and
8+
interpreters
9+
- running your tests in each of the environments, configuring your test tool
10+
of choice
11+
- acting as a frontend to Continuous Integration servers, greatly reducing
12+
boilerplate and merging CI and shell-based testing.
13+
14+
taken from `tox.readthedocs.io
15+
<https://tox.readthedocs.io/en/latest/>`_.
16+
17+
Basic example.
18+
----------------------------------------------------------------
19+
First, install tox with pip install tox. Then put basic information about
20+
your project and the test
21+
environments you want your project to run in into a tox.ini file residing
22+
right next to your setup.py file:
23+
24+
::
25+
26+
# content of: tox.ini , put in same dir as setup.py
27+
[tox]
28+
envlist = py27,py36
29+
[testenv]
30+
deps = pytest # install pytest in the virtualenv where commands
31+
will be executed
32+
commands =
33+
# whatever extra steps before testing might be necessary
34+
pytest # or any other test runner that you might use
35+
36+
.. note::
37+
38+
You can also try generating a tox.ini file automatically, by running
39+
tox-quickstart and then answering a few simple questions.
40+
To sdist-package, install and test your project against Python2.7 and
41+
Python3.6, just type:
42+
43+
::
44+
45+
tox
46+
47+
.. note::
48+
49+
and watch things happening (you must have python2.7 and python3.6
50+
installed in your environment otherwise you will see errors). When
51+
you run tox a second time you’ll note that it runs much faster
52+
because it keeps track of virtualenv details and will not recreate or
53+
re-install dependencies.You also might want to checkout tox configuration
54+
and usage examples to get some more ideas.
55+
56+
Sections
57+
--------
58+
The ``tox.ini`` file has a number of top level sections defined by ``[ ]``
59+
and subsections within those. For complete documentation
60+
on all subsections inside of a tox section please refer to the tox
61+
documentation.
62+
63+
- ``tox`` : This section contains the ``envlist`` which is used to create
64+
our dynamic matrix. Refer to the `section here <http://tox.readthedocs.io/
65+
en/latest/config.html#generating-environments-conditional-settings>`_ for
66+
more information on how the ``envlist`` works.
67+
68+
- ``purge`` : This section contains commands that only run for scenarios
69+
that purge the cluster and redeploy. You'll see this section being reused in
70+
``testenv``with the following syntax: ``{[purge]commands}``
71+
72+
- ``update`` : This section contains commands taht only run for scenarios
73+
that
74+
deploy a cluster and then upgrade it to another Ceph version.
75+
76+
- ``testenv`` : This is the main section of the ``tox.ini`` file and is run
77+
on every scenario. This section contains many *factors* that define
78+
conditional settings depending on the scenarios defined in the
79+
``envlist``.
80+
For example, the factor``centos7_cluster`` in the ``changedir`` subsection
81+
of ``testenv`` sets the directory that tox will change do when that factor
82+
is selected. This is an important behavior that allows us to use the same
83+
``tox.ini`` and reuse commands while tweaking certain sections per testing
84+
scenario.
85+
86+
Modifying or Adding environments
87+
--------------------------------
88+
89+
The tox environments are controlled by the ``envlist`` subsection of the
90+
``[tox]`` section. Anything inside of ``{}`` is considered a *factor* and
91+
will be included
92+
in the dynamic matrix that tox creates. Inside of ``{}`` you can include
93+
a comma separated list of the *factors*. Do not use a hyphen (``-``) as part
94+
of the *factor* name as those are used by tox as the separator between
95+
different factor sets.
96+
97+
For example, if wanted to add a new test *factor* for the next Ceph
98+
release of luminious this is how you'd accomplish that. Currently, the first
99+
factor set in our ``envlist``
100+
is used to define the Ceph release (``{jewel,kraken,rhcs}-...``). To add
101+
luminous you'd change that to look like ``{luminous,kraken,rhcs}-...``.
102+
In the ``testenv`` section
103+
this is a subsection called ``setenv`` which allows you to provide environment
104+
variables to the tox environment and we support an environment variable
105+
called ``CEPH_STABLE_RELEASE``.
106+
To ensure that all the new tests that are created by adding the luminous
107+
*factor* you'd do this in that section:
108+
``luminous: CEPH_STABLE_RELEASE=luminous``.
109+
110+
Note
111+
112+
For more information about Tox configuration, consult the
113+
`official documentation <https://tox.readthedocs.io/en/latest/>`_.

0 commit comments

Comments
 (0)