Skip to content

Commit

Permalink
Migrate tox to nox (#673)
Browse files Browse the repository at this point in the history
* Migrate tox to nox

* Update documentation fo tox->nox migration

* Apply suggestions from code review

Co-authored-by: Mateusz Nojek <matnojek@gmail.com>

Co-authored-by: Mateusz Nojek <matnojek@gmail.com>
  • Loading branch information
bhirsz and mnojek committed Aug 3, 2022
1 parent 87bf1e0 commit 111b1f7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 81 deletions.
31 changes: 22 additions & 9 deletions CONTRIBUTING.rst
Expand Up @@ -135,6 +135,11 @@ but most of it is located inside ``docs`` directory. The files are usually
written using `reStructuredText format
<https://www.writethedocs.org/guide/writing/reStructuredText/>`_ (.rst).

To generate our documentation use ``nox`` tool that will create environment with required dependencies and generate
the documentation. Documentation will be available under ``docs/_build/index.html`` path::

nox -s docs

User manual
'''''''''''

Expand Down Expand Up @@ -178,19 +183,23 @@ To run pytest tests navigate to directory with test files and run::
Pytest will automatically discover all the tests, run them and display
results. Make sure that tests do not fail.

Together with Robocop installed with ``dev`` dependencies, you will be able to use
`tox <https://github.com/tox-dev/tox>`_ tool (a CI task automation tool) which can run all tests on different environments.
Currently two environments are available - one with Robot Framework v3.* and one with
Robot Framework v4.*. You can simply run::
Nox
''''''''
Robocop contains `nox <https://nox.thea.codes/en/stable/>`_ file for running the tests on all supported
major Robot Framework versions and generating the coverage or docs. The nox tool will create the virtual environment and
install required dependencies for you.

Follow installation instruction from the ``nox`` documentation page. To execute Robocop tests run::

tox
nox

and it will run all tests separately in these two environments and display the results.
Run the following command to see all possible sessions (acting as environments or targets)::

If you want to run tests for only one specific environment, you can choose between
``rf3`` and ``rf4`` and run them with option ``-e``, e.g.::
nox --list

tox -e rf3
You can select only one session per run. For example, to only run tests for ``Python==3.10`` and ``Robot Framework==3.*``::

nox --session "unit-3.10(robot_version='3')"

Unit tests
''''''''''
Expand Down Expand Up @@ -251,6 +260,10 @@ and then::

coverage html

You can also use ``nox`` tool::

nox -s coverage

HTML files will be generated - navigate to ``htmlcov`` directory and open ``index.html`` file.

::
Expand Down
49 changes: 49 additions & 0 deletions noxfile.py
@@ -0,0 +1,49 @@
import nox

UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
nox.options.sessions = [
"unit",
]


def install_dev_deps(session, robot_major_ver):
session.install("-r", f"tests/packages/rf-stable{robot_major_ver}/requirements.txt")
session.install(".[dev]")


def install_doc_deps(session, robot_major_ver):
session.install("-r", f"tests/packages/rf-stable{robot_major_ver}/requirements.txt")
session.install(".[doc]")


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
@nox.parametrize("robot_version", ["3", "4", "5"])
def unit(session, robot_version):
install_dev_deps(session, robot_version)
session.run("pytest", "--benchmark-skip", "tests")


@nox.session()
def coverage(session):
install_dev_deps(session, "5")
session.install("coverage")
session.run("coverage", "run", "-m", "pytest")
session.run("coverage", "html")


@nox.session()
def docs(session):
install_doc_deps(session, "5")
session.run("sphinx-build", "-b", "html", "docs", "docs/_build/")


@nox.session()
def benchmark(session):
install_dev_deps(session, "5")
session.run(
"pytest",
"--benchmark-only",
"--benchmark-enable",
"--benchmark-save=benchmark_results",
"--benchmark-save-data",
)
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -67,7 +67,6 @@
"pytest",
"pytest-benchmark",
"pyyaml",
"tox",
],
"doc": [
"furo",
Expand Down
71 changes: 0 additions & 71 deletions tox.ini

This file was deleted.

0 comments on commit 111b1f7

Please sign in to comment.