Skip to content

Commit 8355d55

Browse files
committed
feat: add pre-commit to contributor docs
1 parent 1abdab8 commit 8355d55

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

doc/source/contributor/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ This guide is for contributors of the StackHPC Kayobe configuration project.
1111
release-notes
1212
environments/index
1313
package-updates
14+
pre-commit

doc/source/contributor/pre-commit.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
================
2+
Pre-commit Hooks
3+
================
4+
5+
StackHPC Kayobe configuration carries support for
6+
`pre-commit hooks <https://pre-commit.com/>`_ which simplify the use of git
7+
hooks enabling the identification and repairing of broken or poor code
8+
before committing.
9+
These hooks are designed to make working within SKC easier and less error prone.
10+
11+
Currently the following hooks are provided:
12+
13+
- ``check-yaml``: perform basic yaml syntax linting
14+
- ``end-of-file-fixer``: identify and automatically fix missing newline
15+
- ``trailing-whitespace``: identify and automatically fix excessive white space
16+
- ``ripsecrets``: identify and prevent secrets from being committed to the branch
17+
18+
.. warning::
19+
The hook ``ripsecrets`` is capable of preventing the accidental leaking of secrets
20+
such as those found within `secrets.yml` or `passwords.yml`.
21+
However if the secret is contained within a file on it's own and lacks a certain level
22+
of entropy then the secret will not be identified as such as and maybe leaked as a result.
23+
24+
Installation of `pre-commit` hooks is handled via the `install-pre-commit-hooks` playbook
25+
found within the Ansible directory.
26+
Either use `kayobe playbook run` or add the playbook as a hook within Kayobe config such as
27+
within `control-host-bootstrap/post.d`.
28+
Once done you should find `pre-commit` is available within the `kayobe` virtualenv.
29+
30+
All that remains is the installation of the hooks themselves which can be accomplished either by
31+
running `pre-commit run` or using `git commit` when you have changes that need to be committed.
32+
This will trigger a brief installation process of the hooks which may take a few minutes.
33+
This a one time process and will not be required again unless new hooks are added or existing ones are updated.
34+
35+
.. note::
36+
Currently if you run ``pre-commit run --all-files`` it will make a series of changes to
37+
release notes that lack new lines as well configuration files that ``check-yaml`` does not
38+
approve of.

0 commit comments

Comments
 (0)