Skip to content

Commit

Permalink
Merge pull request #191 from CycloneDX/feat/pre-commit-hooks
Browse files Browse the repository at this point in the history
[DEV] Add pre-commit hooks
  • Loading branch information
madpah committed Apr 11, 2022
2 parents e5b426f + f38215f commit 91ceeb1
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
fail_fast: true
repos:
- repo: local
hooks:
- id: system
name: mypy
entry: poetry run tox -e mypy
pass_filenames: false
language: system
- repo: local
hooks:
- id: system
name: isort
entry: poetry run isort .
pass_filenames: false
language: system
- repo: local
hooks:
- id: system
name: autopep8
entry: poetry run autopep8 --in-place -r cyclonedx tests
pass_filenames: false
language: system
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Get it all applied via:

```shell
poetry run isort .
poetry run autopep8 --in-place -r .
poetry run autopep8 --in-place -r cyclonedx tests
```

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

## Pre-commit hooks

If you like to take advantage of [pre-commit hooks], you can do so to cover most of the topics on this page when
contributing.

```shell
pre-commit install
```

All our pre-commit checks will run locally before you can commit!

[poetry]: https://python-poetry.org
[PEP8]: https://www.python.org/dev/peps/pep-0008
[Sphinx]: https://www.sphinx-doc.org/
[readthedocs.io]: https://cyclonedx-python-library.readthedocs.io/
[RST]: https://en.wikipedia.org/wiki/ReStructuredText
[pre-commit hooks]: https://pre-commit.com
83 changes: 83 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Contributing
====================================================

Pull requests are welcome, but please read these contributing guidelines first.

Setup
----------------------------------------------------

This project uses `poetry`_. Have it installed and setup first.

To install dev-dependencies and tools:

.. code-block::
poetry install
Code style
----------------------------------------------------

This project uses `PEP8`_ Style Guide for Python Code. This project loves sorted imports. Get it all applied via:

.. code-block::
poetry run isort .
poetry run autopep8 --in-place -r cyclonedx tests
Documentation
----------------------------------------------------

This project uses `Sphinx`_ to generate documentation which is automatically published to `readthedocs.io`_.

Source for documentation is stored in the ``docs`` folder in `RST`_ format.

You can generate the documentation locally by running:

.. code-block::
cd docs
pip install -r requirements.txt
make html
Testing
----------------------------------------------------

Run all tests in dedicated environments, via:

.. code-block::
poetry run tox
Sign your commits
----------------------------------------------------

Please sign your commits, to show that you agree to publish your changes under the current terms and licenses of the
project. We can't accept contributions, however great, if you do not sign your commits.

.. code-block::
git commit --signed-off ...
Pre-commit hooks
----------------------------------------------------

If you like to take advantage of `pre-commit hooks`_, you can do so to cover most of the topics on this page when
contributing.

.. code-block::
pre-commit install
All our pre-commit checks will run locally before you can commit!


.. _poetry: https://python-poetry.org
.. _PEP8: https://www.python.org/dev/peps/pep-0008
.. _Sphinx: https://www.sphinx-doc.org/
.. _readthedocs.io: https://cyclonedx-python-library.readthedocs.io/
.. _RST: https://en.wikipedia.org/wiki/ReStructuredText
.. _pre-commit hooks: https://pre-commit.com
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ programmatically generate SBOMs.

install
architecture
contributing
support
changelog

Expand Down

0 comments on commit 91ceeb1

Please sign in to comment.