From f8e00f288b4b1a905c4b2c38f7f110cb1ceec643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20He=C3=9Felmann?= Date: Mon, 13 Nov 2023 23:42:43 +0100 Subject: [PATCH] feat: add `make generate` to pre-commit hook --- .pre-commit-config.yaml | 5 +++++ scripts/run-make-generate.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 scripts/run-make-generate.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17029307..73a15da0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,11 @@ repos: - id: end-of-file-fixer - repo: local hooks: + - id: make-generate + name: make generate + entry: ./scripts/run-make-generate.sh + language: system + pass_filenames: false - id: grafana-lint name: grafana lint entry: ./scripts/lint-grafana.sh diff --git a/scripts/run-make-generate.sh b/scripts/run-make-generate.sh new file mode 100755 index 00000000..15629235 --- /dev/null +++ b/scripts/run-make-generate.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -eu + +if ! [ -x "$(command -v jb)" ]; then + go install -a github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest +fi + +if ! [ -x "$(command -v jsonnet)" ]; then + go install github.com/google/go-jsonnet/cmd/jsonnet@latest +fi + +if ! [ -x "$(command -v yq)" ]; then + go install github.com/mikefarah/yq/v4@latest +fi + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd 2>/dev/null)" + +make -C "$SCRIPT_DIR"/.. generate