From 24204c0a79d6e952e82de00b2c9c23a6efb26e93 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 14 Nov 2023 17:29:09 +0100 Subject: [PATCH] Add a pre-commit setup to the repository. This will allow us to run some checks before committing. Signed-off-by: Vincent Demeester --- .envrc | 6 ++++++ .pre-commit-config.yaml | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.envrc b/.envrc index 57593a21e4..75279e6953 100644 --- a/.envrc +++ b/.envrc @@ -15,4 +15,10 @@ if [[ -f .env.sample ]]; then fi fi +if command -v pre-commit >/dev/null; then + if [[ ! -f .git/hooks/pre-commit ]]; then + pre-commit install + fi +fi + dotenv_if_exists || direnv status # https://direnv.net/man/direnv-stdlib.1.html diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..cbcf4a1e5b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_install_hook_types: ["pre-push"] +exclude: '(^docs/themes/hugo-book|^vendor|.*golden$|^\.vale)' +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + - id: check-added-large-files + - id: check-toml + - id: check-shebang-scripts-are-executable + - id: check-json + - id: check-vcs-permalinks + - id: detect-private-key + exclude: ".*_test.go" +- repo: local + hooks: + - id: lint-go + name: "Lint GO" + entry: make + args: ["lint-go"] + language: system + types: [go] + pass_filenames: false + - id: test + name: "Unit testing" + entry: make + args: ["test"] + language: system + types: [go] + pass_filenames: false + - id: lint-yaml + name: "Lint YAML" + entry: make + args: ["lint-yaml"] + language: system + types: [yaml] + pass_filenames: false