|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -uo pipefail |
| 3 | + |
| 4 | +# Validates the manifest tree, Kustomize rendering, and helper scripts. |
| 5 | +# Same checks the .github/workflows/validate.yml workflow runs — install the |
| 6 | +# tools locally and you can reproduce CI before pushing. |
| 7 | +# |
| 8 | +# Tools required: |
| 9 | +# yamllint, shellcheck, kustomize, helm, kubeconform |
| 10 | +# |
| 11 | +# macOS install: |
| 12 | +# brew install yamllint shellcheck kustomize helm kubeconform |
| 13 | +# |
| 14 | +# Usage: ./ci/validate.sh |
| 15 | + |
| 16 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 17 | +PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 18 | +cd "$PROJECT_DIR" || exit 1 |
| 19 | + |
| 20 | +# ---- Tool check ---- |
| 21 | +missing=() |
| 22 | +for tool in yamllint shellcheck kustomize helm kubeconform; do |
| 23 | + command -v "$tool" >/dev/null 2>&1 || missing+=("$tool") |
| 24 | +done |
| 25 | +if [[ ${#missing[@]} -gt 0 ]]; then |
| 26 | + echo "ERROR: missing required tools: ${missing[*]}" |
| 27 | + echo " macOS install: brew install ${missing[*]}" |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | +# Run all checks, collecting failures rather than aborting on the first one — |
| 32 | +# so the developer sees the full picture in a single run. |
| 33 | +failed=() |
| 34 | + |
| 35 | +echo "==> yamllint" |
| 36 | +yamllint . || failed+=("yamllint") |
| 37 | + |
| 38 | +echo "" |
| 39 | +echo "==> shellcheck scripts/*.sh ci/*.sh" |
| 40 | +shellcheck scripts/*.sh ci/*.sh || failed+=("shellcheck") |
| 41 | + |
| 42 | +echo "" |
| 43 | +echo "==> kustomize + kubeconform per leaf" |
| 44 | +for leaf in manifests/root manifests/platform manifests/product manifests/cassandra manifests/keycloak manifests/quine-enterprise; do |
| 45 | + echo " --- $leaf ---" |
| 46 | + if ! kustomize build --enable-helm "$leaf" \ |
| 47 | + | kubeconform --strict --ignore-missing-schemas --summary; then |
| 48 | + failed+=("$leaf") |
| 49 | + fi |
| 50 | +done |
| 51 | + |
| 52 | +echo "" |
| 53 | +if [[ ${#failed[@]} -gt 0 ]]; then |
| 54 | + echo "FAILED: ${failed[*]}" |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | +echo "All checks passed." |
0 commit comments