Skip to content

Commit 71886dc

Browse files
committed
docs: Simplify undestanding what's going on
1 parent 1c9823e commit 71886dc

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

.github/CONTRIBUTING.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# Notes for contributors
22

3-
1. Python hooks are supported now too. All you have to do is:
4-
1. add a line to the `console_scripts` array in `entry_points` in `setup.py`
5-
2. Put your python script in the `pre_commit_hooks` folder
6-
7-
Enjoy the clean, valid, and documented code!
8-
93
* [Run and debug hooks locally](#run-and-debug-hooks-locally)
104
* [Run hook performance test](#run-hook-performance-test)
115
* [Run via BASH](#run-via-bash)
@@ -18,6 +12,7 @@ Enjoy the clean, valid, and documented code!
1812
* [Prepare basic documentation](#prepare-basic-documentation)
1913
* [Add code](#add-code)
2014
* [Finish with the documentation](#finish-with-the-documentation)
15+
* [Work with Python hooks](#work-with-python-hooks)
2116

2217
## Run and debug hooks locally
2318

@@ -152,5 +147,38 @@ You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/
152147
153148
### Finish with the documentation
154149
155-
1. Add hook description to [Available Hooks](../README.md#available-hooks).
150+
1. Add the hook description to [Available Hooks](../README.md#available-hooks).
156151
2. Create and populate a new hook section in [Hooks usage notes and examples](../README.md#hooks-usage-notes-and-examples).
152+
153+
### Work with Python hooks
154+
155+
1. [Install `tox`](https://tox.wiki/en/stable/installation.html)
156+
2. To run tests, run:
157+
158+
```bash
159+
tox -qq
160+
```
161+
162+
If there are any issues, copy-paste and run the `python3 ...` command to visualize the pytest coverage report.
163+
164+
3. Before committing any changes (if you do not have `pre-commit` installed locally), run:
165+
166+
```bash
167+
tox r -qq -e pre-commit
168+
```
169+
170+
Make sure that all checks pass.
171+
172+
4. (Optional): If you want to see more explicit MyPy checks, you can run:
173+
174+
```bash
175+
tox r -qq -e pre-commit -- mypy --all-files
176+
```
177+
178+
Then copy-paste and run the `python3 ...` commands to check the strictest MyPy coverage reports.
179+
180+
5. (Optional): You can find all available environments by running:
181+
182+
```bash
183+
tox list
184+
```

.github/workflows/reusable-tox.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ jobs:
292292
--quiet
293293
--
294294
python -Im pre_commit install-hooks
295+
# Create GHA Job Summary markdown table of the coverage report
296+
# For details: ../../tox.ini '[testenv]' 'commands_post'
295297
- name: >-
296298
Run tox envs: `${{ env.TOXENV }}`
297299
id: tox-run
@@ -308,6 +310,7 @@ jobs:
308310
&& format('-- {0}', inputs.tox-run-posargs)
309311
|| ''
310312
}}
313+
# Generate nice picture of passed/failed tests in GHA Job Summary
311314
- name: Produce markdown test summary from JUnit
312315
if: >-
313316
!cancelled()

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ doctest_optionflags = ALLOW_UNICODE ELLIPSIS
4343
empty_parameter_set_mark = xfail
4444

4545
faulthandler_timeout = 30
46-
46+
# Make all warnings as errors
4747
filterwarnings =
4848
error
4949

tox.ini

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ warnings-to-errors = -Werror
1414
description = Run pytest under {envpython}
1515
dependency_groups =
1616
testing
17+
18+
# In:
19+
# 'tox run -e py -- --lf', 'tox run -- --lf', 'tox run -e py313,py312 -- --lf'
20+
# '{posargs}' == '--lf'
1721
commands =
1822
{envpython} \
1923
{[python-cli-options]byte-errors} \
@@ -23,6 +27,9 @@ commands =
2327
{tty:--color=yes} \
2428
{posargs:--cov-report=html:{envtmpdir}{/}htmlcov{/}}
2529
commands_post =
30+
# Create GHA Job Summary markdown table of the coverage report
31+
# https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/
32+
# '-' ignores non-zero exit code
2633
-{envpython} \
2734
{[python-cli-options]byte-errors} \
2835
{[python-cli-options]max-isolation} \
@@ -38,6 +45,7 @@ commands_post =
3845
cov = coverage.Coverage(); \
3946
cov.load(); \
4047
cov.report(file=gh_summary_fd, output_format="markdown")'
48+
# Find path of coverage & testrun report for next step
4149
{envpython} \
4250
{[python-cli-options]byte-errors} \
4351
{[python-cli-options]max-isolation} \
@@ -162,7 +170,8 @@ commands =
162170
commands_post =
163171
package = skip
164172

165-
173+
# In 'tox run -e pre-commit -- mypy-py313 --all'
174+
# '{posargs}' == 'mypy-py313 --all'
166175
[testenv:pre-commit]
167176
description =
168177
Run the quality checks under {basepython}; run as
@@ -183,6 +192,7 @@ commands =
183192
{posargs:--all-files}
184193

185194
# Print out the advice on how to install pre-commit from this env into Git:
195+
# '-' ignores non-zero exit code
186196
-{envpython} \
187197
{[python-cli-options]byte-errors} \
188198
{[python-cli-options]max-isolation} \
@@ -216,6 +226,7 @@ commands_post =
216226
); \
217227
print("codecov-flags=MyPy", file=gh_output_fd); \
218228
gh_output_fd.close()'
229+
#
219230
{envpython} \
220231
{[python-cli-options]byte-errors} \
221232
{[python-cli-options]max-isolation} \

0 commit comments

Comments
 (0)