Merge ~jugmac00/lpci:improve-contribution-documentation into lpci:main

Proposed by Jürgen Gmach
Status: Merged
Merged at revision: a4f7bd58b2b27b8f1ada8505d55d4994e4f155c8
Proposed branch: ~jugmac00/lpci:improve-contribution-documentation
Merge into: lpci:main
Diff against target: 147 lines (+39/-18)
2 files modified
CONTRIBUTING.rst (+26/-18)
tox.ini (+13/-0)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+416744@code.launchpad.net

Commit message

Improve the contribution documentation

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote (last edit ):

@Guruprasad: I added a couple of comments why I think the documentation needed some updates. What do you think?

Revision history for this message
Guruprasad (lgp171188) wrote :

Should running the plain `tox` command run the unit tests twice - once each for the unit test environment and once for the coverage environment. The latter is sufficient to cover both needs, right?

Revision history for this message
Jürgen Gmach (jugmac00) wrote (last edit ):

> Should running the plain `tox` command run the unit tests twice - once each for the unit test environment and once for the coverage environment.

Yes, this is a common approach.

Once we use tox 4, we can use a different approach. As then it is more easily possible to declare dependencies between environments, resp. run environments in succession.

Other approaches I have seen.... Every testenv, which runs tests, also runs coverage. This approach works nicely for CI, but is pretty annoying when developing locally, as then you always need to scroll up to find the reason for error.

So all in all - I think we are using the best approach.

Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
2index e4c23d1..64753c6 100644
3--- a/CONTRIBUTING.rst
4+++ b/CONTRIBUTING.rst
5@@ -6,8 +6,6 @@ Prerequisites
6
7 * Python 3.8+
8 * `tox <https://tox.wiki/en/latest/>`_
9-* `pyenv <https://github.com/pyenv/pyenv>`_, if you want to use and test against
10- multiple versions of Python
11
12 Usage
13 -----
14@@ -23,20 +21,23 @@ List the ``tox`` environments available for this project.
15
16 .. code:: bash
17
18- $ tox -l
19- lint
20- mypy
21- py38
22- py39
23- py310
24+ $ tox -lv
25+ default environments:
26+ lint -> run linters
27+ mypy -> run static type checker
28+ py38 -> run test suite
29+ py39 -> run test suite
30+ py310 -> run test suite
31+ coverage -> generate coverage report
32
33 Run the project's tests.
34
35 .. code:: bash
36
37- $ tox -e py38 # Replace with the installed Python version, if 3.8 is unavailable.
38+ $ tox -e py38 # You can replace ``py38`` with another Python version.
39
40-Since ``tox`` uses ``pytest`` under the hood to run the tests, arguments can be passed to pytest.
41+Since ``tox`` uses `pytest <https://docs.pytest.org/>`_ under the hood to run
42+the tests, arguments can be passed to ``pytest``.
43
44 .. code:: bash
45
46@@ -50,14 +51,15 @@ Run the tests with coverage.
47
48 $ tox -e coverage
49
50-Run the linter.
51+Run the linters.
52
53 .. code:: bash
54
55 $ tox -e lint
56
57-Alternatively, you can run ``pre-commit install`` to install the git pre-commit hooks,
58-which run the linter.
59+We also support running linters via `pre-commit <https://pre-commit.com/>`_.
60+If you want ``pre-commit`` to run automatically on ``git commit``,
61+you need to run ``pre-commit install`` once.
62
63 Run the ``mypy`` static type checker.
64
65@@ -72,12 +74,18 @@ Update the requirements and regenerate ``requirements.txt``.
66 $ <modify requirements.in>
67 $ tox -e pip-compile
68
69-If any of the ``tox`` environments use a version of Python that is not installed, edit
70-``tox.ini`` and replace the value for the ``basepython`` key under that environment.
71+Build the documentation locally.
72
73-To update the `project's documentation
74-<https://lpcraft.readthedocs.io/en/latest/>`_, you need to trigger a manual
75-build on the project's dashboard on https://readthedocs.org.
76+ .. code:: bash
77+
78+ $ tox -e docs
79+
80+.. note::
81+
82+ In order to update the `project's documentation
83+ <https://lpcraft.readthedocs.io/en/latest/>`_ online,
84+ after having pushed your changes to the repository, you need to trigger a
85+ manual build on the project's dashboard on https://readthedocs.org.
86
87 Getting help
88 ------------
89diff --git a/tox.ini b/tox.ini
90index 318e847..cba2529 100644
91--- a/tox.ini
92+++ b/tox.ini
93@@ -10,6 +10,8 @@ skip_missing_interpreters =
94 true
95
96 [testenv]
97+description =
98+ run test suite
99 commands =
100 pytest {posargs}
101 deps =
102@@ -17,6 +19,8 @@ deps =
103 .[test]
104
105 [testenv:lint]
106+description =
107+ run linters
108 basepython =
109 python3.8
110 deps =
111@@ -26,6 +30,8 @@ commands =
112 pre-commit run -a
113
114 [testenv:pip-compile]
115+description =
116+ update and regenerate requirements.txt
117 basepython =
118 python3.8
119 deps =
120@@ -35,6 +41,8 @@ commands =
121 pip-compile
122
123 [testenv:mypy]
124+description =
125+ run static type checker
126 basepython =
127 python3.8
128 deps =
129@@ -46,6 +54,8 @@ commands =
130 mypy --cache-dir="{envdir}/mypy_cache" --strict {posargs:lpcraft}
131
132 [testenv:coverage]
133+description =
134+ generate coverage report
135 deps =
136 -r requirements.txt
137 .[test]
138@@ -56,6 +66,9 @@ commands =
139 coverage report -m --fail-under=100
140
141 [testenv:docs]
142+description =
143+ generate documentation
144+# the Python version here matches the one in .readthedocs.yaml
145 basepython = python3.9
146 extras = docs
147 commands =

Subscribers

People subscribed via source and target branches