From 40b552b5cfde85b44b6d73f2d89bc2e6d54c4fe3 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 20 May 2026 10:21:37 +0200 Subject: [PATCH] ci: generate schema --- .github/workflows/ci.yml | 41 +++++ .github/workflows/helm-unittest.yml | 1 - .husky/pre-commit | 8 + CONTRIBUTING.md | 16 +- mise.toml | 7 + package-lock.json | 18 ++ package.json | 10 +- values.schema.json | 258 ++++++++++++++++++++++++++++ 8 files changed, 351 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .husky/pre-commit create mode 100644 values.schema.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fb84e4e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI +on: + push: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - &checkout + name: Checkout + uses: actions/checkout@v6 + - &setup_helm + name: Set up Helm + uses: azure/setup-helm@v5 + - name: Lint + run: helm lint . + + unittest: + runs-on: ubuntu-latest + steps: + - *checkout + - *setup_helm + - name: Install helm-unittest + run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false + - name: Test + run: helm unittest . + + + schema: + runs-on: ubuntu-latest + steps: + - *checkout + - *setup_helm + - name: Install helm-values-schema-json plugin + run: helm plugin install https://github.com/losisin/helm-values-schema-json.git --verify=false + - name: Generate values schema json + uses: losisin/helm-values-schema-json-action@v3 + with: + values: values.yaml + output: values.schema.json + fail-on-diff: true \ No newline at end of file diff --git a/.github/workflows/helm-unittest.yml b/.github/workflows/helm-unittest.yml index 9191088..9962bad 100644 --- a/.github/workflows/helm-unittest.yml +++ b/.github/workflows/helm-unittest.yml @@ -20,4 +20,3 @@ jobs: - name: Run Helm unit tests run: helm unittest . - diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..fc4cdc2 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,8 @@ +echo 'running helm lint...' +helm lint . + +echo 'running helm unittest...' +helm unittest . + +echo 'running helm schema generate...' +helm schema -f values.yaml -o values.schema.json \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d9af459..799a25b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,13 @@ Thank you for your interest in contributing! This guide covers everything you ne - [Helm](https://helm.sh/) 3+ - [helm-unittest](https://github.com/helm-unittest/helm-unittest) plugin — for running chart unit tests -- [Node.js](https://nodejs.org/) (see `.node-version`) — only needed for commit linting locally -- [mise](https://mise.jdx.dev/) (optional — manages tool versions automatically) +- [helm-values-schema-json](https://github.com/losisin/helm-values-schema-json) plugin — for generating the schema +- [Node.js](https://nodejs.org/) (see `.node-version`) — only needed for commit linting locally and pre commit hooks +- [mise](https://mise.jdx.dev/) — manages tool versions automatically + +### Installation + +If you install `mise` first you can just run `mise install` and `mise run setup-helm-plugins` and everything will install for you 🙂. ## Development Workflow @@ -48,8 +53,8 @@ This project uses [helm-unittest](https://github.com/helm-unittest/helm-unittest ### Running tests ```bash -# Install the helm-unittest plugin (one-time) -helm plugin install https://github.com/helm-unittest/helm-unittest.git +# Install the needed helm plugins (one-time) +mise run setup-helm-plugins # Run all unit tests helm unittest . @@ -57,6 +62,9 @@ helm unittest . # Lint the chart helm lint . +# Generate the schema +helm schema + # Render templates locally for inspection helm template . ``` diff --git a/mise.toml b/mise.toml index ad84395..b8396ad 100644 --- a/mise.toml +++ b/mise.toml @@ -3,3 +3,10 @@ idiomatic_version_file_enable_tools = ["node"] # use .node-version [tools] helm = "4.0.4" + +[tasks.setup-helm-plugins] +description = "Install all needed helm plugins needed for development" +run = [ + "helm plugin install https://github.com/losisin/helm-values-schema-json.git --verify=false", + "helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false", +] diff --git a/package-lock.json b/package-lock.json index b622f14..cafdd54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "@commitlint/cli": "21.0.1", "@commitlint/config-conventional": "21.0.1", "conventional-changelog-conventionalcommits": "9.3.1", + "husky": "^9.1.7", "semantic-release": "25.0.3" } }, @@ -1383,6 +1384,7 @@ "integrity": "sha512-tQMagCOC59EVgNZcC5zl7XqO30Wki9i9J3acbUvkaosCT6JX3EeFwJD7Qqp4MCikRnzS18WXV3BLIQ66ytu6+Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -2157,6 +2159,22 @@ "node": ">=18.18.0" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", diff --git a/package.json b/package.json index 0466e76..4a24010 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,13 @@ "private": true, "description": "Tooling dependencies for CI (semantic-release and commitlint)", "devDependencies": { - "semantic-release": "25.0.3", - "conventional-changelog-conventionalcommits": "9.3.1", "@commitlint/cli": "21.0.1", - "@commitlint/config-conventional": "21.0.1" + "@commitlint/config-conventional": "21.0.1", + "conventional-changelog-conventionalcommits": "9.3.1", + "husky": "^9.1.7", + "semantic-release": "25.0.3" + }, + "scripts": { + "prepare": "husky" } } diff --git a/values.schema.json b/values.schema.json new file mode 100644 index 0000000..a6ec4e1 --- /dev/null +++ b/values.schema.json @@ -0,0 +1,258 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "controllerManager": { + "type": "object", + "properties": { + "manager": { + "type": "object", + "properties": { + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "containerSecurityContext": { + "type": "object", + "properties": { + "allowPrivilegeEscalation": { + "type": "boolean" + }, + "capabilities": { + "type": "object", + "properties": { + "drop": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "readOnlyRootFilesystem": { + "type": "boolean" + } + } + }, + "image": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "resources": { + "type": "object", + "properties": { + "limits": { + "type": "object", + "properties": { + "cpu": { + "type": "string" + }, + "memory": { + "type": "string" + } + } + }, + "requests": { + "type": "object", + "properties": { + "cpu": { + "type": "string" + }, + "memory": { + "type": "string" + } + } + } + } + } + } + }, + "nodeSelector": { + "type": "object" + }, + "podDisruptionBudget": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "minAvailable": { + "type": "integer" + } + } + }, + "podLabels": { + "type": "object" + }, + "podSecurityContext": { + "type": "object", + "properties": { + "runAsNonRoot": { + "type": "boolean" + }, + "seccompProfile": { + "type": "object", + "properties": { + "type": { + "type": "string" + } + } + } + } + }, + "replicas": { + "type": "integer" + }, + "strategy": { + "type": "object", + "properties": { + "rollingUpdate": { + "type": "object", + "properties": { + "maxSurge": { + "type": "integer" + }, + "maxUnavailable": { + "type": "integer" + } + } + }, + "type": { + "type": "string" + } + } + }, + "tolerations": { + "type": "array" + }, + "topologySpreadConstraints": { + "type": "array", + "items": { + "type": "object", + "properties": { + "maxSkew": { + "type": "integer" + }, + "topologyKey": { + "type": "string" + }, + "whenUnsatisfiable": { + "type": "string" + } + } + } + }, + "watchedNamespaces": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "kubernetesClusterDomain": { + "type": "string" + }, + "metricsService": { + "type": "object", + "properties": { + "ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "protocol": { + "type": "string" + }, + "targetPort": { + "type": "integer" + } + } + } + }, + "type": { + "type": "string" + } + } + }, + "serviceAccount": { + "type": "object", + "properties": { + "annotations": { + "type": "object" + }, + "automount": { + "type": "boolean" + }, + "create": { + "type": "boolean" + }, + "labels": { + "type": "object" + }, + "name": { + "type": "string" + }, + "secrets": { + "type": "array" + } + } + }, + "servingCert": { + "type": "object", + "properties": { + "issuerRef": { + "type": "object", + "properties": { + "kind": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + } + }, + "webhookService": { + "type": "object", + "properties": { + "ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "port": { + "type": "integer" + }, + "protocol": { + "type": "string" + }, + "targetPort": { + "type": "integer" + } + } + } + }, + "type": { + "type": "string" + } + } + } + } +}