Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit a4a3a24

Browse files
committed
remaining ADRs
1 parent ae67553 commit a4a3a24

File tree

5 files changed

+143
-89
lines changed

5 files changed

+143
-89
lines changed

docs/user/explanations/decisions/0008-use-tox.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,108 @@ see https://tox.wiki/en/latest/.
2525
pre-commit provides a hook into git commit which runs some of the checks
2626
against the changes you are about to commit.
2727

28+
Decision detail
29+
---------------
30+
31+
There are a number of things that CI needs to run:
32+
33+
- pytest
34+
- black
35+
- mypy
36+
- flake8
37+
- isort
38+
- build documentation
39+
40+
The initial approach this module took was to integrate everything
41+
under pytest that had a plugin, and isort under flake8:
42+
43+
.. digraph:: initial
44+
45+
bgcolor=transparent
46+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
47+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
48+
49+
subgraph cluster_0 {
50+
label = "pytest"
51+
"pytest-black"
52+
"pytest-mypy"
53+
subgraph cluster_1 {
54+
label = "pytest-flake8"
55+
"flake8-isort"
56+
}
57+
}
58+
59+
This had the advantage that a ``pytest tests`` run in CI would catch and
60+
report all test failures, but made each run take longer than it needed to. Also,
61+
flake8 states that it `does not have a public, stable, Python API
62+
<https://flake8.pycqa.org/en/latest/user/python-api.html>`_ so did not
63+
recommend the approach taken by pytest-flake8.
64+
65+
To address this, the tree was rearranged:
66+
67+
.. digraph:: rearranged
68+
69+
bgcolor=transparent
70+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
71+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
72+
73+
pytest
74+
black
75+
mypy
76+
subgraph cluster_1 {
77+
label = "flake8"
78+
"flake8-isort"
79+
}
80+
81+
If using VSCode, this will still run black, flake8 and mypy on file save, but
82+
for those using other editors and for CI another solution was needed. Enter
83+
`pre-commit <https://pre-commit.com/>`_. This allows hooks to be run at ``git
84+
commit`` time on just the files that have changed, as well as on all tracked
85+
files by CI. All that is needed is a one time install of the git commit hook::
86+
87+
$ pre-commit install
88+
89+
Finally tox was added to run all of the CI checks including
90+
the documentation build. mypy was moved out of the pre-commit and into tox
91+
because it was quite long running and
92+
therefore intrusive. tox can be invoked to run all the checks in
93+
parallel with::
94+
95+
$ tox -p
96+
97+
The graph now looks like:
98+
99+
.. digraph:: rearranged
100+
101+
bgcolor=transparent
102+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
103+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
104+
105+
subgraph cluster_0
106+
{
107+
label = "tox -p"
108+
pytest
109+
mypy
110+
"sphinx-build"
111+
subgraph cluster_1 {
112+
label = "pre-commit"
113+
black
114+
subgraph cluster_2 {
115+
label = "flake8"
116+
"flake8-isort"
117+
}
118+
}
119+
}
120+
121+
Now the workflow looks like this:
122+
123+
- Save file, VSCode runs black, flake8 and mypy on it
124+
- Run 'tox -p' and fix issues until it succeeds
125+
- Commit files and pre-commit runs black and flake8 on them (if the
126+
developer had not run tox then this catches some of the most common issues)
127+
- Push to remote and CI runs black, flake8, mypy once on all files
128+
(using tox), then pytest multiple times in a test matrix
129+
28130

29131
Consequences
30132
------------

docs/user/explanations/decisions/0011-requirements-txt.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ Decision
2222
Have every release generate requirements.txt files using pip freeze and
2323
publish them as release assets.
2424

25-
Request that the user to download the asset and commit it into the repo in order
25+
Request that the user download the asset and commit it into the repo in order
2626
to lock dependencies for the next CI build.
2727

28+
TODO: link to the How-To on pinning requirements to be written in
29+
python3-pip-skeleton developer documentation.
30+
2831
Consequences
2932
------------
3033

31-
There is less overhead managing fg lock files.
34+
There is less overhead in managing lock files. Incoming issues with dependencies
35+
will be highlighted early but can be worked around quickly if needed.
3236

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
5. Use containers
2+
=================
3+
4+
Date: 2023-01-18
5+
6+
Status
7+
------
8+
9+
Accepted
10+
11+
Context
12+
-------
13+
14+
Allow developers and users to take advantage of containers.
15+
16+
Decision
17+
--------
18+
19+
Provide a single Dockerfile that can build two kinds of container:
20+
21+
- a minimal runtime container that can be used to execute the application in
22+
isolation without setting up a virtual environment or installing system
23+
dependencies
24+
- a devcontainer for working on the project with the same isolation as above
25+
26+
CI builds the runtime container and publishes it to ghcr.io.
27+
28+
a .devcontainer folder provides the means to build and launch the developer
29+
container using vscode.
30+
31+
Consequences
32+
------------
33+
34+
We can label projects as cloud native.
35+

docs/user/explanations/why-pre-commit.rst

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

docs/user/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ side-bar.
4545

4646
explanations/decisions
4747
explanations/why-use-skeleton
48-
explanations/why-pre-commit
4948
explanations/skeleton
5049

5150
+++

0 commit comments

Comments
 (0)