https://github.com/olist/hulks
Olist custom linting hooks :green_heart: :alien:
https://github.com/olist/hulks
hooks lint pre-commit quality
Last synced: about 1 month ago
JSON representation
Olist custom linting hooks :green_heart: :alien:
- Host: GitHub
- URL: https://github.com/olist/hulks
- Owner: olist
- License: apache-2.0
- Created: 2018-05-04T21:14:37.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2023-08-02T16:53:34.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T20:40:11.872Z (6 months ago)
- Topics: hooks, lint, pre-commit, quality
- Language: Python
- Homepage: https://github.com/olist/hulks
- Size: 53.7 KB
- Stars: 26
- Watchers: 16
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - hulks - Olist custom linting hooks :green_heart: :alien: (Python)
README
=====
hulks
=====|CI Build Status|
----
Olist custom pre-commit plugins
Usage
~~~~~To configure custom pre-commit hooks, create or add an entry in your ``.pre-commit-config.yaml``
as follows:.. code-block:: yaml
repos:
- repo: [email protected]:olist/hulks.git
rev: main
hooks:
- id: check-invalid-domainsUpdate pre-commit plugins::
pre-commit autoupdate
Test the custom hook(s) against all your codebase::
pre-commit run -a -v
The list of available hooks could be found on pre_commit_hooks_file_ or using ``setup.py show_hooks`` command::
python setup.py -q show_hooks
Development
~~~~~~~~~~~Create an virtualenv using ``Python 3.6+`` and install the development requirements::
pip install -r requirements-dev.txt
Optionally, add the package in your current virtualenv for easier access::
python setup.py develop
# now you should be able to call any hook by the entry name:
# my-hookTo execute the repository tests::
make tests
Creating new hooks
~~~~~~~~~~~~~~~~~~To create a new hook:
* Copy the example hook: ``cp hulks/example.py hulks/my_hulk.py``
* Add an entry in ``.pre-commit-hooks.yaml`` (more options in pre-commit-documentation_)
* Develop and test your hook following the guidelines below
* Update ``CHANGES.rst`` properlyGuidelines
~~~~~~~~~~Keep in mind that all plugins are installed via ``setup.py`` script by ``pre-commit``.
The following guides should help us when creating new hooks:
* Add an entry in ``.pre-commit-hooks.yaml``
* the ``name`` entry should be the hook path (eg ``hulks.my_hook``)
* Your hook entrypoint is always a function named ``main``
* Add your hook dependencies in ``requirements.txt``Testing
~~~~~~~To test a newly added hook, you can:
* Follow these instructions_. (you must commit your code before testing)
* Add the hook to another project ``.pre-commit-config.yaml``. (you must commit your code before testing)
* Update ``pre-commit`` (``pre-commit autoupdate``)
* Or simple run ``python -m hulks.my_new_hook ``.Release
~~~~~~~Check if ``CHANGES.rst`` contains the correct version number (follow semver_).
Create the proper tags with::make release
.. _instructions: https://pre-commit.com/#developing-hooks-interactively
.. _pre-commit-documentation: https://pre-commit.com/#new-hooks
.. _pre_commit_hooks_file: https://github.com/olist/hulks/blob/main/.pre-commit-hooks.yaml
.. _semver: https://semver.org/
.. |CI Build Status| image:: https://github.com/olist/hulks/actions/workflows/test.yml/badge.svg