Skip to content

Commit 91ceeb1

Browse files
authored
Merge pull request #191 from CycloneDX/feat/pre-commit-hooks
[DEV] Add pre-commit hooks
2 parents e5b426f + f38215f commit 91ceeb1

File tree

4 files changed

+120
-1
lines changed

4 files changed

+120
-1
lines changed

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
fail_fast: true
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: system
6+
name: mypy
7+
entry: poetry run tox -e mypy
8+
pass_filenames: false
9+
language: system
10+
- repo: local
11+
hooks:
12+
- id: system
13+
name: isort
14+
entry: poetry run isort .
15+
pass_filenames: false
16+
language: system
17+
- repo: local
18+
hooks:
19+
- id: system
20+
name: autopep8
21+
entry: poetry run autopep8 --in-place -r cyclonedx tests
22+
pass_filenames: false
23+
language: system

CONTRIBUTING.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Get it all applied via:
2323

2424
```shell
2525
poetry run isort .
26-
poetry run autopep8 --in-place -r .
26+
poetry run autopep8 --in-place -r cyclonedx tests
2727
```
2828

2929
## Documentation
@@ -57,8 +57,20 @@ to show that you agree to publish your changes under the current terms and licen
5757
git commit --signed-off ...
5858
```
5959

60+
## Pre-commit hooks
61+
62+
If you like to take advantage of [pre-commit hooks], you can do so to cover most of the topics on this page when
63+
contributing.
64+
65+
```shell
66+
pre-commit install
67+
```
68+
69+
All our pre-commit checks will run locally before you can commit!
70+
6071
[poetry]: https://python-poetry.org
6172
[PEP8]: https://www.python.org/dev/peps/pep-0008
6273
[Sphinx]: https://www.sphinx-doc.org/
6374
[readthedocs.io]: https://cyclonedx-python-library.readthedocs.io/
6475
[RST]: https://en.wikipedia.org/wiki/ReStructuredText
76+
[pre-commit hooks]: https://pre-commit.com

docs/contributing.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Contributing
2+
====================================================
3+
4+
Pull requests are welcome, but please read these contributing guidelines first.
5+
6+
Setup
7+
----------------------------------------------------
8+
9+
This project uses `poetry`_. Have it installed and setup first.
10+
11+
To install dev-dependencies and tools:
12+
13+
.. code-block::
14+
15+
poetry install
16+
17+
Code style
18+
----------------------------------------------------
19+
20+
This project uses `PEP8`_ Style Guide for Python Code. This project loves sorted imports. Get it all applied via:
21+
22+
.. code-block::
23+
24+
poetry run isort .
25+
poetry run autopep8 --in-place -r cyclonedx tests
26+
27+
28+
Documentation
29+
----------------------------------------------------
30+
31+
This project uses `Sphinx`_ to generate documentation which is automatically published to `readthedocs.io`_.
32+
33+
Source for documentation is stored in the ``docs`` folder in `RST`_ format.
34+
35+
You can generate the documentation locally by running:
36+
37+
.. code-block::
38+
39+
cd docs
40+
pip install -r requirements.txt
41+
make html
42+
43+
44+
Testing
45+
----------------------------------------------------
46+
47+
Run all tests in dedicated environments, via:
48+
49+
.. code-block::
50+
51+
poetry run tox
52+
53+
54+
Sign your commits
55+
----------------------------------------------------
56+
57+
Please sign your commits, to show that you agree to publish your changes under the current terms and licenses of the
58+
project. We can't accept contributions, however great, if you do not sign your commits.
59+
60+
.. code-block::
61+
62+
git commit --signed-off ...
63+
64+
65+
Pre-commit hooks
66+
----------------------------------------------------
67+
68+
If you like to take advantage of `pre-commit hooks`_, you can do so to cover most of the topics on this page when
69+
contributing.
70+
71+
.. code-block::
72+
73+
pre-commit install
74+
75+
All our pre-commit checks will run locally before you can commit!
76+
77+
78+
.. _poetry: https://python-poetry.org
79+
.. _PEP8: https://www.python.org/dev/peps/pep-0008
80+
.. _Sphinx: https://www.sphinx-doc.org/
81+
.. _readthedocs.io: https://cyclonedx-python-library.readthedocs.io/
82+
.. _RST: https://en.wikipedia.org/wiki/ReStructuredText
83+
.. _pre-commit hooks: https://pre-commit.com

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ programmatically generate SBOMs.
3737

3838
install
3939
architecture
40+
contributing
4041
support
4142
changelog
4243

0 commit comments

Comments
 (0)