From 60c0439165cee264ac65aec2aa240b1d37caf5fd Mon Sep 17 00:00:00 2001 From: Jon Perry Date: Thu, 10 Mar 2022 19:21:52 +0000 Subject: [PATCH 1/2] add pre-commit for validating zarf schema --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18f0e778ac..7ae39f4e53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,3 +39,11 @@ repos: language: script pass_filenames: false description: "Runs `golangci-lint`, requires https://github.com/golangci/golangci-lint" + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.14.0 + hooks: + - id: check-jsonschema + name: "Validate Zarf Schema" + files: "zarf.yaml" + types: [yaml] + args: ["--schemafile", "zarf.schema.json"] From a7c18ef5540edc40f6edf2e0dca91e9cdb588db4 Mon Sep 17 00:00:00 2001 From: Jon Perry Date: Fri, 11 Mar 2022 17:48:48 +0000 Subject: [PATCH 2/2] pre-commit hook to make sure zarf schema is current --- .pre-commit-config.yaml | 11 ++++++++++- hooks/verify-zarf-schema.sh | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 hooks/verify-zarf-schema.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ae39f4e53..86b7f6bef5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,11 +39,20 @@ repos: language: script pass_filenames: false description: "Runs `golangci-lint`, requires https://github.com/golangci/golangci-lint" + - repo: local + hooks: + - id: generate-zarf-schema + name: Check for outdated Zarf schema + entry: hooks/verify-zarf-schema.sh + files: "cli/types/types.go" + types: [go] + language: script + description: "Runs `zarf tools config-schema > zarf.schema.json` to ensure schema is up to date" - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.14.0 hooks: - id: check-jsonschema - name: "Validate Zarf Schema" + name: "Validate Zarf Configs Against Schema" files: "zarf.yaml" types: [yaml] args: ["--schemafile", "zarf.schema.json"] diff --git a/hooks/verify-zarf-schema.sh b/hooks/verify-zarf-schema.sh new file mode 100755 index 0000000000..cc45b23078 --- /dev/null +++ b/hooks/verify-zarf-schema.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +go run cli/main.go tools config-schema > zarf.schema.json