A collection of useful git hooks for use with pre-commit.
Create or append to your .pre-commit-config.yaml
configuration:
- repo: https://github.com/lightspeed-hospitality/pre-commit-hooks
rev: v0.6.0
hooks:
- id: circleci-config-pack
- id: circleci-config-validate
- id: poetry-pytest
Before publishing a new version (with a tag) you can test changes on this repository in other projects by using a commit SHA
- repo: https://github.com/lightspeed-hospitality/pre-commit-hooks
rev: 4f707bc9dfeb75d70c4c37ebde63f8dc334f126d
hooks:
- id: circleci-config-pack
- id: circleci-config-validate
- id: poetry-pytest
rev
can be either a tag or a commit SHA
Create a new git tag with the new version and create a release based on the tag.
From pre-commit-hooks
All hooks are defined in .pre-commit-hooks-yaml. For further information and usage check this list of available hooks here.
black
: Python Code Formatterruff
: An extremely fast Python lintercircleci-config-validate
: Test if the CircleCI config file is well formed.circleci-config-pack
: Pack the CircleCI config and build the config.ymldetect-secrets
: Scan for secrets committed into the repoflake8
: Tool For Python Style Guide Enforcementgoogle-java-code-format
isort
: Python import sortingpoetry-pytest
: Use poetry to create a virtual-env and run pytestpoetry-run
: Use poetry to run any check command (pyright, pylint, ...)shellcheck
shfmt
yamllint
checkstyle
: runsmvn checkstyle:check
prettier-xml
: Formats XML using prettier, requiresnode
to be initialized. Requires dummypackage.json
in the root of thepre-commit-hooks
repo for successful initialization
Scan for secrets committed into the repo.
Note: Since detect secrets (on Yelp) seems to not be maintained anymore, we decided to use the IBM fork since at least it's actively developed. Only issue is that it's relatively out of sync from the mainstream, but it should work fine for our needs.
- To generate a baseline of secrets:
-
Install the correct version of detect-secrets:
python3 -m pip install --upgrade "git+https://github.com/ibm/[email protected]+ibm.61.dss#egg=detect-secrets"
-
Run the baseline scan:
detect-secrets scan --base64-limit 4.5 --hex-limit 3 --update .secrets.baseline
-
- Set
args: ['--baseline', '.secrets.baseline']
in your pre-commit config