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

Commit 5a96d1a

Browse files
committed
Add diagrams to pre-commit docs
1 parent bae5c35 commit 5a96d1a

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

docs/explanations/why-pre-commit.rst

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ There are a number of things that CI needs to run:
1212
The initial approach this module took was to integrate everything
1313
under pytest that had a plugin, and isort under flake8:
1414

15-
- pytest
16-
17-
- pytest-black
18-
- pytest-mypy
19-
- pytest-flake8
20-
21-
- flake8-isort
15+
.. digraph:: initial
16+
17+
bgcolor=transparent
18+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
19+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
20+
21+
subgraph cluster_0 {
22+
label = "pytest"
23+
"pytest-black"
24+
"pytest-mypy"
25+
subgraph cluster_1 {
26+
label = "pytest-flake8"
27+
"flake8-isort"
28+
}
29+
}
2230

2331
This had the advantage that a ``pipenv run tests`` run in CI would catch and
2432
report all test failures, but made each run take longer than it needed to. Also,
@@ -28,12 +36,19 @@ recommend the approach taken by pytest-flake8.
2836

2937
To address this, the tree was rearranged:
3038

31-
- pytest
32-
- black
33-
- mypy
34-
- flake8
39+
.. digraph:: rearranged
40+
41+
bgcolor=transparent
42+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
43+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
3544

36-
- flake8-isort
45+
pytest
46+
black
47+
mypy
48+
subgraph cluster_1 {
49+
label = "flake8"
50+
"flake8-isort"
51+
}
3752

3853
If using VSCode, this will still run black, flake8 and mypy on file save, but
3954
for those using other editors and for CI another solution was needed. Enter
@@ -45,13 +60,22 @@ files by CI. All that is needed is a one time install of the git commit hook::
4560

4661
The graph now looks like:
4762

48-
- pytest
49-
- pre-commit
50-
51-
- black
52-
- mypy
53-
- flake8
54-
- flake8-isort
63+
.. digraph:: rearranged
64+
65+
bgcolor=transparent
66+
graph [fontname="Lato" fontsize=10 style=filled fillcolor="#8BC4E9"]
67+
node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"]
68+
69+
pytest
70+
subgraph cluster_0 {
71+
label = "pre-commit"
72+
black
73+
mypy
74+
subgraph cluster_1 {
75+
label = "flake8"
76+
"flake8-isort"
77+
}
78+
}
5579

5680
Now the workflow looks like this:
5781

0 commit comments

Comments
 (0)