Skip to content

Commit c638cca

Browse files
committed
use nox to run all scripts
1 parent 2d0779b commit c638cca

14 files changed

+360
-217
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ jobs:
2424
- name: Install Python Dependencies
2525
run: pip install -r requirements/test-run.txt
2626
- name: Run Tests
27-
env:
28-
HEADLESS: 1
29-
run: nox
27+
run: |
28+
nox -s test -- pytest[--headless]
3029
test-other-systems:
3130
runs-on: ${{ matrix.os }}
3231
strategy:
@@ -46,7 +45,5 @@ jobs:
4645
- name: Install Python Dependencies
4746
run: pip install -r requirements/test-run.txt
4847
- name: Run Tests
49-
env:
50-
HEADLESS: 1
51-
NO_COVERAGE_CHECK: 1
52-
run: nox
48+
run: |
49+
nox -s test -- pytest[--headless,--no-cov]

docs/__init__.py

Whitespace-only changes.

docs/main.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,13 @@ async def forward_to_index(request):
5050
idom.run = original_run
5151

5252

53-
server = PerClientStateServer(component, {"redirect_root_to_index": False}).register(
54-
app
55-
)
53+
PerClientStateServer(component, {"redirect_root_to_index": False}).register(app)
5654

5755

58-
def production():
59-
server.run(
56+
if __name__ == "__main__":
57+
app.run(
6058
host="0.0.0.0",
6159
port=int(os.environ.get("PORT", 5000)),
6260
workers=int(os.environ.get("WEB_CONCURRENCY", 1)),
6361
debug=bool(int(os.environ.get("DEBUG", "0"))),
6462
)
65-
66-
67-
def local(path=""):
68-
from selenium.webdriver import Chrome
69-
70-
thread = server.daemon("127.0.0.1", 5000)
71-
path = f"docs/{path}" if path else ""
72-
driver = Chrome()
73-
driver.get(f"http://127.0.0.1:5000/{path}")
74-
thread.join()
75-
76-
77-
if __name__ == "__main__":
78-
production()

docs/source/_exts/interactive_widget.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
2+
13
from docutils.nodes import raw
24
from docutils.parsers.rst import Directive
35
from sphinx.application import Sphinx
46

7+
_IDOM_SERVER_LOC = os.environ.get("IDOM_DOC_EXAMPLE_SERVER_HOST", "")
8+
59

610
class IteractiveWidget(Directive):
711

@@ -21,7 +25,7 @@ def run(self):
2125
<div id="{container_id}" class="interactive widget-container center-content" style="" />
2226
<script async type="module">
2327
const loc = window.location;
24-
const idom_url = "//" + loc.host;
28+
const idom_url = "//" + ("{_IDOM_SERVER_LOC}" || loc.host);
2529
const http_proto = loc.protocol;
2630
const ws_proto = http_proto === "https:" ? "wss:" : "ws:";
2731
@@ -31,7 +35,7 @@ def run(self):
3135
enableWidgetButton.setAttribute("class", "enable-widget-button")
3236
3337
enableWidgetButton.addEventListener("click", () => {{
34-
import("/client/index.js").then((module) => {{
38+
import(http_proto + idom_url + "/client/index.js").then((module) => {{
3539
fadeOutAndThen(enableWidgetButton, () => {{
3640
mount.removeChild(enableWidgetButton);
3741
mount.setAttribute("class", "interactive widget-container");

docs/source/developer-installation.rst

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

docs/source/developer-workflow.rst

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
Developer Workflow
2+
==================
3+
4+
This project uses the `GitHub Flow`_ for collaboration and consists of Python code and
5+
Javascript code. A variety of tools are used to aid in its development. Below is a short
6+
list of the tools which will be most commonly referenced in the sections to follow:
7+
8+
.. list-table::
9+
:header-rows: 1
10+
11+
* - Tool
12+
- Used For
13+
14+
* - Git_
15+
- version control
16+
17+
* - Nox_
18+
- automating development tasks.
19+
20+
* - PyTest_
21+
- executing the Python-based test suite
22+
23+
* - pre-commit_
24+
- helping impose basic syle guidelines
25+
26+
* - NPM_
27+
- managing and installing Javascript packages
28+
29+
* - Selenium_ and ChromeDriver_
30+
- to control the browser while testing
31+
32+
* - `GitHub Actions`_
33+
- hosting and running our CI/CD suite
34+
35+
* - Docker_ and Heroku_
36+
- containerizing and hosting this documentation
37+
38+
39+
Development Environment
40+
-----------------------
41+
42+
In order to work with IDOM's source code you'll need to install Git_ (or `Git Bash`_ on
43+
Windows). Once done you can clone a local copy of this repository:
44+
45+
.. code-block:: bash
46+
47+
git clone https://github.com/rmorshea/idom.git
48+
cd idom
49+
50+
At this point you should be able to run the command below to:
51+
52+
- Install an editable version of the Python code
53+
54+
- Download, build, and install Javascript dependencies
55+
56+
- Install some pre-commit hooks for Git
57+
58+
.. code-block:: bash
59+
60+
pip install -e . -r requirements.txt && pre-commit install
61+
62+
If you modify any Javascript, you'll need to re-install IDOM:
63+
64+
.. code-block:: bash
65+
66+
pip install -e .
67+
68+
However you may also ``cd`` to the ``idom/client/app`` directory which contains a
69+
``package.json`` that you can use to run standard ``npm`` commands from.
70+
71+
72+
Running The Tests
73+
-----------------
74+
75+
The test suite for IDOM is executed using Nox_ and covers:
76+
77+
1. Server-side Python code with PyTest_
78+
79+
2. The end-to-end application using Selenium_
80+
81+
To run the full suite of tests you'll need to install:
82+
83+
- `Google Chrome`_
84+
85+
- ChromeDriver_.
86+
87+
.. warning::
88+
89+
Be sure the version of `Google Chrome`_ and ChromeDriver_ you install are compatible.
90+
91+
Once you've installed the aforementined browser and web driver you should be able to
92+
run:
93+
94+
.. code-block:: bash
95+
96+
nox -s test
97+
98+
If you prefer to run the tests using a headless browser:
99+
100+
.. code-block:: bash
101+
102+
nox -s test -- pytest[--headless]
103+
104+
105+
Building The Documentation
106+
--------------------------
107+
108+
To build and display the documentation simply run:
109+
110+
.. code-block:: bash
111+
112+
nox -s docs
113+
114+
This will compile the documentation from its source files into HTML, start a web server,
115+
and open a browser to display the now generated documentation. Whenever you change any
116+
source files the web server will automatically rebuild the documentation and refresh the
117+
page. Under the hood this is using
118+
`sphinx-autobuild <https://github.com/executablebooks/sphinx-autobuild>`__.
119+
120+
To run some of the examples in the documentation as if they were tests run:
121+
122+
.. code-block::
123+
124+
nox -s test_docs
125+
126+
Building the documentation as it's deployed in production requires Docker_. Once you've
127+
installed, you can run:
128+
129+
.. code-block:: bash
130+
131+
nox -s docs_in_docker
132+
133+
You should then navigate to to see the documentation.
134+
135+
136+
Making a Pull Request
137+
---------------------
138+
139+
Under construction...
140+
141+
142+
Release Process
143+
---------------
144+
145+
Under construction...
146+
147+
148+
How It's Published to PyPI
149+
..........................
150+
151+
Under construction...
152+
153+
154+
How Docs are Deployed to Heroku
155+
...............................
156+
157+
Under construction...
158+
159+
160+
Other Core Repositories
161+
-----------------------
162+
163+
IDOM involves several other core projects. For documentation on them you should refer to
164+
their respective documentation in the links below
165+
166+
- https://github.com/idom-team/idom-client-react - Javascript client for IDOM
167+
- https://github.com/idom-team/flake8-idom-hooks - Enforces the :ref:`Rules of Hooks`
168+
169+
170+
.. Links
171+
.. =====
172+
173+
.. _Google Chrome: https://www.google.com/chrome/
174+
.. _ChromeDriver: https://chromedriver.chromium.org/downloads
175+
.. _Docker: https://docs.docker.com/get-docker/
176+
.. _Git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
177+
.. _Git Bash: https://gitforwindows.org/
178+
.. _NPM: https://www.npmjs.com/get-npm
179+
.. _PyPI: https://pypi.org/project/idom
180+
.. _pip: https://pypi.org/project/pip/
181+
.. _PyTest: pytest <https://docs.pytest.org
182+
.. _Selenium: https://www.seleniumhq.org/
183+
.. _Nox: https://nox.thea.codes/en/stable/#
184+
.. _React: https://reactjs.org/
185+
.. _Heroku: https://www.heroku.com/what
186+
.. _GitHub Actions: https://github.com/features/actions
187+
.. _pre-commit: https://pre-commit.com/
188+
.. _GitHub Flow: https://guides.github.com/introduction/flow/

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Libraries for defining and controlling interactive webpages with Python
2020
:caption: Developer Guide
2121

2222
contributing
23-
developer-installation
23+
developer-workflow
2424
specifications
2525
package-api
2626

docs/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For more installation options see the :ref:`Extra Features` section.
1717

1818
.. note::
1919

20-
To contribute to IDOM, refer to the :ref:`Developer Installation` instructions.
20+
To contribute to IDOM, refer to the :ref:`Developer Workflow` instructions.
2121

2222

2323
Extra Features

0 commit comments

Comments
 (0)