Skip to content

Commit a4eb13d

Browse files
authored
add pre-commit hooks and update documentation (#707)
- Introduced pre-commit hooks for code quality and consistency. - Updated CHANGELOG.md and CONTRIBUTING.md for new setup instructions. - Added 'pre-commit' to dev dependencies in pyproject.toml.
1 parent 132ebaa commit a4eb13d

4 files changed

Lines changed: 35 additions & 10 deletions

File tree

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/psf/black
12+
rev: 24.10.0
13+
hooks:
14+
- id: black
15+
- repo: https://github.com/pycqa/isort
16+
rev: 5.13.2
17+
hooks:
18+
- id: isort
19+
name: isort (python)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* rewrite the helper method `add_field_to` such that it always raises an `FieldExistsWarning` instead of return a bool.
1717
* add new helper method `add_fields_to` to directly add multiple fields to one event
1818
* refactored some processors to make use of the new helper methods
19+
* add `pre-commit` hooks to the repository, install new dev dependency and run `pre-commit install` in the root dir
1920

2021
### Bugfix
2122

CONTRIBUTING.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ Issues and engagement in open discussions are also welcome.
3838
* The content should have line breaks after 72 characters.
3939
* The content should describe what was done and why it was done, but not how it was done.
4040

41+
### Pre-Commit Hooks
42+
* We use pre-commit hooks to sanitize files before commiting
43+
* Install the pre-commit hooks with `pre-commit install` in the root directory
44+
4145
### Pull Request and Definition of Done
4246
* draft a Pull Request as soon as possible to signal your commitment.
4347
* write a clear description of what a maintainer have to expect from your PR.
44-
* add an entry in the CHANGELOG.md file for your feature, improvement or bugfix.
48+
* add an entry in the [CHANGELOG.md](https://github.com/fkie-cad/Logprep/blob/main/CHANGELOG.md) file for your feature, improvement or bugfix.
4549
* add the needed documentation in the docs.
4650
* add tests for your work.
4751
* ensure all tests run.
48-
* if you done all of the above, add a maintainer for review and mark your PR as ready.
52+
* if you have done all of the above, add a maintainer for review and mark your PR as ready.
4953

5054
### Deprecations
51-
* If a function or features gets deprecated a warning should be logged with `logger.warning`. The message should start with `[Deprecation]:` and end with an indication when this deprecation will expire, e.g.: `[Expires with logprep=4.0.0]`.
52-
* Furthermore the corresponding code parts should be marked with a comment starting like `# DEPRECATION: <SHORT-Name> <Comment>`. This way it is later easy to find again the lines of code that have to be revised before the deprecation will be fully removed.
53-
* The [CHANGELOG.md](https://github.com/fkie-cad/Logprep/blob/main/CHANGELOG.md) should be updated such that the next release contains a remark that a feature will be marked as deprecated and indicating in the `Upcoming Changes` section that the deprecation will also be removed in the future.
55+
* If a function or features gets deprecated a warning should be logged with `logger.warning`. The message should start with `[Deprecation]:` and end with an indication when this deprecation will expire, e.g.: `[Expires with logprep=4.0.0]`.
56+
* Furthermore, the corresponding code parts should be marked with a comment starting like `# DEPRECATION: <SHORT-Name> <Comment>`. This way it is later easy to find again the lines of code that have to be revised before the deprecation will be fully removed.
57+
* The [CHANGELOG.md](https://github.com/fkie-cad/Logprep/blob/main/CHANGELOG.md) should be updated such that the next release contains a remark that a feature will be marked as deprecated and indicating in the `Upcoming Changes` section that the deprecation will also be removed in the future.
5458

5559
### Code Quality and Style
5660
* We adhere to PEP-8.
@@ -78,14 +82,14 @@ Issues and engagement in open discussions are also welcome.
7882
* Before we make a new release we update the [CHANGELOG.md](https://github.com/fkie-cad/Logprep/blob/main/CHANGELOG.md)
7983
There we rename the section `next release` to the version that will be released and add a new section `next release`.
8084
This section is continuously updated during the development of the next release.
81-
* Once this update is pushed and merged we tag a new release in git, prefixed with `v`, resulting in a tag like `v2.0.1`.
85+
* Once this update is pushed and merged we tag a new release in git, prefixed with `v`, resulting in a tag like `v2.0.1`.
8286
We adhere to the [SemVer](https://semver.org/) Specifications.
83-
* Once the tag is pushed we create a release in Github. The release description should contain the changes documented
87+
* Once the tag is pushed we create a release in GitHub. The release description should contain the changes documented
8488
in the [CHANGELOG.md](https://github.com/fkie-cad/Logprep/blob/main/CHANGELOG.md).
85-
* A configured Github Action then takes this published release and automatically uploads a new build to [PyPI Logprep](https://pypi.org/project/logprep/).
89+
* A configured GitHub Action then takes this published release and automatically uploads a new build to [PyPI Logprep](https://pypi.org/project/logprep/).
8690

8791
### Helm Chart Release Workflow
8892

8993
* To release a new helm chart we update the versions in the [Chart.yaml](https://github.com/fkie-cad/Logprep/blob/main/charts/logprep/Chart.yaml) in a feature branch.
90-
* Then we merge this change to the main branch.
91-
* There a pipeline packages the helm chart an makes the actual helm chart release on the release page.
94+
* Then we merge this change to the main branch.
95+
* There a pipeline packages the helm chart and makes the actual helm chart release on the release page.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ dev = [
115115
"cibuildwheel",
116116
"asgiref",
117117
"pytest-asyncio",
118+
"pre-commit",
118119
]
119120

120121
doc = [

0 commit comments

Comments
 (0)