feat: add pre-commit hooks

This commit is contained in:
Khue Doan 2022-07-19 21:16:19 +07:00
parent c3f4433a1a
commit 214f635697
5 changed files with 50 additions and 3 deletions

27
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adrienverge/yamllint
rev: v1.27.1
hooks:
- id: yamllint
- repo: https://github.com/k8s-at-home/sops-pre-commit
rev: v2.1.1
hooks:
- id: forbid-secrets
- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.1.17
hooks:
- id: helmlint
- id: shellcheck
- id: terraform-fmt
- id: terraform-validate

View File

@ -26,9 +26,6 @@ wait:
tools:
make -C tools
docs:
make -C docs
dev:
make -C metal cluster env=dev
make -C bootstrap
@ -41,3 +38,6 @@ docs:
--publish 8000:8000 \
--volume $(shell pwd):/docs \
squidfunk/mkdocs-material
git-hooks:
pre-commit install

View File

@ -231,6 +231,7 @@ References:
- [Official Cloudflare Tunnel examples](https://github.com/cloudflare/argo-tunnel-examples)
- [Initialize GitOps repository on Gitea and integrate with Tekton by RedHat](https://github.com/redhat-scholars/tekton-tutorial/tree/master/triggers)
- [SSO configuration from xUnholy/k8s-gitops](https://github.com/xUnholy/k8s-gitops)
- [Pre-commit config from k8s-at-home/flux-cluster-template](https://github.com/k8s-at-home/flux-cluster-template)
Here is a list of the contributors who have helped to improve this project.
Big shout-out to them!

View File

@ -0,0 +1,17 @@
# Install pre-commit hooks
> TODO: organize developer-focused documentation
Git hook scripts are useful for identifying simple issues before commiting changes.
Install [pre-commit](https://pre-commit.com/#install) first, one-liner for Arch users:
```sh
sudo pacman -S python-pre-commit
```
Then install git hook scripts:
```sh
make git-hooks
```

View File

@ -32,7 +32,9 @@ RUN pacman --sync --refresh --noconfirm \
python-kubernetes \
python-netaddr \
python-pip \
python-pre-commit \
python-rich \
shellcheck \
sudo \
terraform \
yamllint