Skip to content
/ hulks Public

Olist custom linting hooks 💚 👽

License

Notifications You must be signed in to change notification settings

olist/hulks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

23b85bf Â· Aug 2, 2023

History

31 Commits
Jul 25, 2023
Aug 2, 2023
Aug 2, 2023
Aug 2, 2023
Jul 24, 2023
Feb 22, 2019
Jul 24, 2023
Jul 24, 2023
Feb 20, 2020
May 4, 2018
Jul 24, 2023
Aug 2, 2023
Jul 25, 2023
Aug 2, 2023
May 4, 2018

Repository files navigation

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:

repos:
  - repo: git@github.com:olist/hulks.git
  rev: main
  hooks:
    - id: check-invalid-domains

Update 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-hook <files>

To 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 properly

Guidelines

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 <filenames>.

Release

Check if CHANGES.rst contains the correct version number (follow semver). Create the proper tags with:

make release