Skip to content

Commit 7ceb3c7

Browse files
committed
use Nox to run tests
1 parent ad2cdc2 commit 7ceb3c7

18 files changed

+92
-82
lines changed

.github/workflows/release-pkg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ jobs:
2626
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2727
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2828
run: |
29-
python setup.py bdist_wheel
29+
python setup.py sdist bdist_wheel
3030
twine upload dist/*

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install Python Dependencies
26-
run: pip install -r requirements/ci.txt
26+
run: pip install -r requirements/test-run.txt
2727
- name: Run Tests
28-
run: TOX_PARALLEL_NO_SPINNER=1 tox --parallel -- --headless
28+
run: HEADLESS_BROWSER=1 nox

docs/source/installation.rst

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ simply run the following to re-evaluate the ``package.json``:
7272
Running The Tests
7373
-----------------
7474

75-
The test suite for IDOM is executed using Tox_ and covers:
75+
The test suite for IDOM is executed using Nox_ and covers:
7676

77-
1. Server-side Python code using PyTest_
77+
1. Server-side Python code with PyTest_
7878

7979
2. The end-to-end application using Selenium_
8080

81-
3. (`Coming soon <https://github.com/rmorshea/idom/issues/195>`_) Client side Javascript code
81+
3. (`Coming soon <https://github.com/idom-team/idom/issues/195>`_) Client side Javascript code
8282

8383
To run the full suite of tests you'll need to install:
8484

@@ -95,19 +95,13 @@ run:
9595

9696
.. code-block:: bash
9797
98-
tox --factor py38
99-
100-
.. note::
101-
102-
You can substitute ``py38`` for your prefered Python version, however only
103-
a subset of the tests are configured to run on versions besides 3.8
104-
98+
nox
10599
106100
If you prefer to run the tests using a headless browser:
107101

108102
.. code-block:: bash
109103
110-
tox --factor py38 -- --headless
104+
HEADLESS_BROWSER=1 nox
111105
112106
113107
Building The Documentation
@@ -119,7 +113,7 @@ installed ``docker`` you'll need to build and then run a container with the serv
119113
.. code-block:: bash
120114
121115
docker build . --file docs/Dockerfile --tag idom-docs:latest
122-
docker run -p 5000:5000 -e DEBUG=true -it idom-docs:latest
116+
docker run -it -p 5000:5000 -e DEBUG=true --rm idom-docs:latest
123117
124118
You should then navigate to http://127.0.0.1:5000 to see the documentation.
125119

@@ -137,4 +131,4 @@ You should then navigate to http://127.0.0.1:5000 to see the documentation.
137131
.. _pip: https://pypi.org/project/pip/
138132
.. _PyTest: pytest <https://docs.pytest.org
139133
.. _Selenium: https://www.seleniumhq.org/
140-
.. _Tox: https://tox.readthedocs.io/en/latest/
134+
.. _Nox: https://nox.thea.codes/en/stable/#

idom/core/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .vdom import VdomDict # noqa
99

1010

11-
ComponentConstructor = Callable[..., "Component"]
11+
ComponentConstructor = Callable[..., "AbstractComponent"]
1212
ComponentRenderFunction = Callable[..., Union["AbstractComponent", "VdomDict"]]
1313

1414

noxfile.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
from typing import Iterable
3+
4+
import nox
5+
from nox.sessions import Session
6+
7+
8+
HEADLESS_BROWSER = bool(int(os.environ.get("HEADLESS_BROWSER", "0")))
9+
BLACK_DEFAULT_EXCLUDE = r"\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist"
10+
11+
12+
@nox.session
13+
def test_without_coverage(session: Session) -> None:
14+
_test_setup(session)
15+
session.install(".[all]")
16+
_test_run(session, extra_args=["--no-cov"])
17+
18+
19+
@nox.session
20+
def test_with_coverage(session: Session) -> None:
21+
_test_setup(session)
22+
session.install("-e", ".[all]") # coverage requires a dev install
23+
_test_run(session)
24+
25+
26+
@nox.session
27+
def check_types(session: Session) -> None:
28+
session.install("-r", "requirements/check-types.txt")
29+
session.run("mypy", "--strict", "idom")
30+
session.run("mypy", "tests")
31+
32+
33+
@nox.session
34+
def check_style(session: Session) -> None:
35+
session.install("-r", "requirements/check-style.txt")
36+
session.run(
37+
"black",
38+
".",
39+
"--check",
40+
"--exclude",
41+
rf"/({BLACK_DEFAULT_EXCLUDE}|node_modules)/",
42+
)
43+
session.run("flake8", "idom", "tests", "docs")
44+
45+
46+
@nox.session
47+
def build_docs(session: Session) -> None:
48+
session.install("-r", "requirements/build-docs.txt")
49+
session.install("-e", ".[all]")
50+
session.run("sphinx-build", "-b", "html", "docs/source", "docs/build")
51+
session.run("sphinx-build", "-b", "doctest", "docs/source", "docs/build")
52+
53+
54+
def _test_setup(session: Session) -> None:
55+
session.env.update(os.environ)
56+
session.install("-r", "requirements/test-env.txt")
57+
58+
59+
def _test_run(session: Session, extra_args: Iterable[str] = ()) -> None:
60+
args = ["pytest", "tests"]
61+
if HEADLESS_BROWSER:
62+
args.append("--headless")
63+
args.extend(extra_args)
64+
session.run(*args)

requirements.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
-r requirements/prod.txt
2-
-r requirements/dev.txt
3-
-r requirements/docs.txt
4-
-r requirements/extras.txt
1+
pre-commit
2+
twine
3+
wheel
4+
setuptools_scm
5+
-r requirements/build-docs.txt
6+
-r requirements/check-style.txt
7+
-r requirements/check-types.txt
8+
-r requirements/pkg-deps.txt
9+
-r requirements/pkg-extras.txt
10+
-r requirements/test-env.txt
11+
-r requirements/test-run.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.

requirements/ci.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

requirements/dev.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

requirements/test-run.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nox

requirements/tox.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[bdist_wheel]
2+
universal=1
3+
14
[mypy]
25
ignore_missing_imports = True
36
warn_unused_configs = True
@@ -37,48 +40,3 @@ omit =
3740
all-files = true
3841
source-dir = docs/source
3942
build-dir = docs/build
40-
41-
[tox:tox]
42-
envlist =
43-
py3{7,8}-nocov,
44-
py39-{cov,mypy,lint,docs}
45-
46-
[gh-actions]
47-
python =
48-
3.7: py37-nocov
49-
3.8: py38-nocov
50-
3.9: py39-{cov,mypy,lint,docs}
51-
52-
[testenv]
53-
wheel = true
54-
extras = all
55-
passenv = *
56-
usedevelop =
57-
nocov: false
58-
cov: true
59-
deps =
60-
nocov: -r requirements/test.txt
61-
cov: -r requirements/test.txt
62-
commands =
63-
nocov: pytest tests --no-cov {posargs}
64-
cov: pytest tests {posargs}
65-
66-
[testenv:mypy]
67-
deps = -r requirements/mypy.txt
68-
commands = mypy --strict idom
69-
70-
[testenv:lint]
71-
skip_install = true
72-
deps = -r requirements/lint.txt
73-
commands =
74-
black . --check --exclude "idom/client/app/node_modules/.*"
75-
flake8 idom tests docs
76-
77-
[testenv:docs]
78-
deps = -r requirements/docs.txt
79-
commands =
80-
sphinx-build -b html docs/source docs/build
81-
sphinx-build -b doctest docs/source docs/build
82-
83-
[bdist_wheel]
84-
universal=1

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@
6262

6363

6464
requirements = []
65-
with open(os.path.join(here, "requirements", "prod.txt"), "r") as f:
65+
with open(os.path.join(here, "requirements", "pkg-deps.txt"), "r") as f:
6666
for line in map(str.strip, f):
6767
if not line.startswith("#"):
6868
requirements.append(line)
6969
package["install_requires"] = requirements
7070

7171
_current_extras = []
7272
extra_requirements = {"all": []} # type: ignore
73-
extra_requirements_path = os.path.join(here, "requirements", "extras.txt")
73+
extra_requirements_path = os.path.join(here, "requirements", "pkg-extras.txt")
7474
with open(extra_requirements_path, "r") as f:
7575
for line in map(str.strip, f):
7676
if line.startswith("#") and line[1:].strip().startswith("extra="):

0 commit comments

Comments
 (0)