diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c25c1545 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/Makefile b/Makefile index a34fcdc4..d306a474 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index ef32f51a..78a602ca 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/docs/tutorials/install-pre-commit-hooks.md b/docs/tutorials/install-pre-commit-hooks.md new file mode 100644 index 00000000..6642b3cd --- /dev/null +++ b/docs/tutorials/install-pre-commit-hooks.md @@ -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 +``` diff --git a/tools/Dockerfile b/tools/Dockerfile index 500da543..86220d79 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -32,7 +32,9 @@ RUN pacman --sync --refresh --noconfirm \ python-kubernetes \ python-netaddr \ python-pip \ + python-pre-commit \ python-rich \ + shellcheck \ sudo \ terraform \ yamllint