-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Generate CRD json schema separately in pre-commit (#2930)
- Loading branch information
1 parent
3e97888
commit f3ed172
Showing
4 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,6 @@ | |
|
||
# Any file with a .log extension | ||
**/*.log | ||
|
||
# Ignore generated CRD schema files | ||
schema/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
if [ ! -d "schema" ]; then | ||
mkdir schema | ||
fi | ||
|
||
convert_script=$(realpath scripts/openapi2jsonschema.py) | ||
crd_files=$(find ray-operator/config/crd/bases -name "*.yaml" -exec realpath {} \;) | ||
|
||
cd schema | ||
|
||
for crd_file in $crd_files; do | ||
$convert_script "$crd_file" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
export KUBERAY_HOME=$(git rev-parse --show-toplevel) | ||
SCRIPT_PATH="${KUBERAY_HOME}/scripts/openapi2jsonschema.py" | ||
RAYCLUSTER_CRD_PATH="$KUBERAY_HOME/ray-operator/config/crd/bases/ray.io_rayclusters.yaml" | ||
tmp=$(mktemp -d) | ||
trap 'rm -rf "$tmp"' EXIT | ||
|
||
# Convert CRD YAML to JSON Schema | ||
pushd "${tmp}" > /dev/null | ||
"$SCRIPT_PATH" "$RAYCLUSTER_CRD_PATH" | ||
popd > /dev/null | ||
RAYCLUSTER_CRD_SCHEMA="${tmp}/raycluster_v1.json" | ||
raycluster_crd_schema=./schema/raycluster_v1.json | ||
|
||
if [ ! -f "$raycluster_crd_schema" ]; then | ||
echo "CRD schema not found: $raycluster_crd_schema" | ||
echo 'Please run "pre-commit genearete-crd-schema --all-files" first' | ||
exit 1 | ||
fi | ||
|
||
charts=("kuberay-apiserver" "kuberay-operator" "ray-cluster") | ||
|
||
# Validate Helm charts with kubeconform | ||
echo "Validating Helm Charts with kubeconform..." | ||
helm template "$KUBERAY_HOME/helm-chart/kuberay-apiserver" | kubeconform --summary -schema-location default | ||
helm template "$KUBERAY_HOME/helm-chart/kuberay-operator" | kubeconform --summary -schema-location default | ||
helm template "$KUBERAY_HOME/helm-chart/ray-cluster" | kubeconform --summary -schema-location default -schema-location "$RAYCLUSTER_CRD_SCHEMA" | ||
for chart in "${charts[@]}"; do | ||
helm template ./helm-chart/"$chart" | kubeconform --summary -schema-location default -schema-location "$raycluster_crd_schema" | ||
done |