Skip to content

Commit 501a83f

Browse files
authored
feat: Add values.schema.json validation. (#296)
1 parent 06c9e95 commit 501a83f

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v5
1919

20-
- uses: actions/setup-python@v6
20+
- uses: actions/setup-node@v4
2121
with:
22-
python-version: '3.13'
22+
node-version: '18'
2323

24-
- name: Install uv
25-
run: |
26-
curl -LsSf https://astral.sh/uv/install.sh | sh
27-
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
24+
- name: Install ajv-cli
25+
run: npm install -g ajv-cli ajv-formats
2826

2927
- name: Install Helm
3028
uses: azure/setup-helm@v4
3129
with:
3230
version: ${{ env.HELM_VERSION }}
3331

32+
- name: Setup Helm dependencies
33+
run: ./scripts/deploy.sh setup
34+
3435
- name: Run linters
35-
run: |
36-
export PATH="$HOME/.cargo/bin:$PATH"
37-
make lint
36+
run: make lint
37+
38+
- name: Validate Helm values schema
39+
run: make validate-schema

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ repos:
5353
files: ^charts/.+\.(yaml|yml)$
5454
pass_filenames: false
5555

56+
- id: helm-schema-validation
57+
name: Helm Schema Validation
58+
entry: make validate-schema
59+
language: system
60+
files: ^charts/.+\.(json|yaml|yml)$
61+
pass_filenames: false
62+
5663
# Exclude directories
5764
exclude: |
5865
(?x)^(

CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Enforcement of `CHANGELOG.md` entries for PRs and Conventional Commits for PR titles [#288](https://github.com/developmentseed/eoapi-k8s/pull/288)
1313
- Added code formatting and linting with pre-commit hooks [#283](https://github.com/developmentseed/eoapi-k8s/pull/283)
14-
- Adjusted Renovate Configuration to fit conventional commits [#295](https://github.com/developmentseed/eoapi-k8s/pull/295)
15-
16-
### Changed
17-
18-
- Excluded renovate.json from CHANGELOG.md edits [#301](https://github.com/developmentseed/eoapi-k8s/pull/301)
14+
- Added values.schema.json validation [#296](https://github.com/developmentseed/eoapi-k8s/pull/296)
1915

2016
## [0.7.8] - 2025-09-10
2117

Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ HELM_REPO_URL=https://devseed.com/eoapi-k8s/
55
HELM_CHART_NAME=eoapi/eoapi
66
PGO_CHART_VERSION=5.7.4
77

8-
.PHONY: all deploy minikube ingest tests integration lint help
8+
.PHONY: all deploy minikube ingest tests integration lint validate-schema help
99

1010
# Default target
1111
all: deploy
@@ -50,12 +50,38 @@ lint:
5050
fi
5151
@pre-commit run --all-files
5252

53+
validate-schema:
54+
@echo "Validating Helm values schemas..."
55+
@command -v helm >/dev/null 2>&1 || { echo "❌ helm is required but not installed"; exit 1; }
56+
@command -v ajv >/dev/null 2>&1 || { echo "❌ ajv-cli is required but not installed. Run: npm install -g ajv-cli ajv-formats"; exit 1; }
57+
@for chart_dir in charts/*/; do \
58+
chart_name=$$(basename "$$chart_dir"); \
59+
if [ -f "$${chart_dir}values.schema.json" ]; then \
60+
echo "🔍 Validating schema for $$chart_name..."; \
61+
if helm lint "$$chart_dir" --strict && \
62+
helm template test "$$chart_dir" >/dev/null && \
63+
ajv compile -s "$${chart_dir}values.schema.json" --spec=draft7 --strict=false && \
64+
python3 -c "import yaml,json; json.dump(yaml.safe_load(open('$${chart_dir}values.yaml')), open('/tmp/values-$${chart_name}.json','w'))" && \
65+
ajv validate -s "$${chart_dir}values.schema.json" -d "/tmp/values-$${chart_name}.json" --spec=draft7; then \
66+
rm -f "/tmp/values-$${chart_name}.json"; \
67+
echo "$$chart_name validation passed"; \
68+
else \
69+
rm -f "/tmp/values-$${chart_name}.json"; \
70+
echo "$$chart_name validation failed"; \
71+
exit 1; \
72+
fi; \
73+
else \
74+
echo "⚠️ $$chart_name: no values.schema.json found, skipping"; \
75+
fi; \
76+
done
77+
5378
help:
5479
@echo "Makefile commands:"
5580
@echo " make deploy - Deploy eoAPI to the configured Kubernetes cluster."
5681
@echo " make minikube - Install eoAPI on minikube."
5782
@echo " make ingest - Ingest STAC collections and items into the database."
5883
@echo " make integration - Run integration tests on connected Kubernetes cluster."
59-
@echo " make tests - Run lint + unit tests."
84+
@echo " make tests - Run unit tests."
6085
@echo " make lint - Run linting and code quality checks."
86+
@echo " make validate-schema - Validate Helm values schemas."
6187
@echo " make help - Show this help message."

0 commit comments

Comments
 (0)