This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push: new 198e3c8 [SPARK-52702] Verify generated CRD yaml with Helm chart `crds` content 198e3c8 is described below commit 198e3c8e49c6a52c9ed4e3c27993ed85703619cc Author: Zhou JIANG <jiang...@umich.edu> AuthorDate: Fri Jul 11 13:39:54 2025 -0700 [SPARK-52702] Verify generated CRD yaml with Helm chart `crds` content ### What changes were proposed in this pull request? This PR adds a gradle task to compare latest CRD version vs the one used by Helm charts ### Why are the changes needed? To avoid potential human error when updating spark-operator-api ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? CIs ### Was this patch authored or co-authored using generative AI tooling? No Closes #283 from jiangzho/crd_validator. Authored-by: Zhou JIANG <jiang...@umich.edu> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- spark-operator-api/build.gradle | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spark-operator-api/build.gradle b/spark-operator-api/build.gradle index e07a1ff..8fe8b7a 100644 --- a/spark-operator-api/build.gradle +++ b/spark-operator-api/build.gradle @@ -57,3 +57,43 @@ tasks.register('relocateGeneratedCRD', Copy) { into "../build-tools/helm/spark-kubernetes-operator/crds" rename '(.+).yml', '$1.yaml' } + +tasks.register("assertGeneratedCRDMatchesHelmChart") { + dependsOn 'finalizeGeneratedCRD' + description = 'Asserts that the generated CRD yaml matches the staged version in Helm Chart' + doLast { + def currentPath = projectDir.absolutePath + def generatedCRDFileBase = "$currentPath/build/classes/java/main/META-INF/fabric8/" + def stagedCRDFileBase = "$currentPath/../build-tools/helm/spark-kubernetes-operator/crds/" + def generatedAppCRD = [ + "yq", + "e", + ".spec.versions[0]", + "${generatedCRDFileBase}sparkapplications.spark.apache.org-v1.yml" + ].execute().text.trim() + def generatedClusterCRD = [ + "yq", + "e", + ".spec.versions[0]", + "${generatedCRDFileBase}sparkclusters.spark.apache.org-v1.yml" + ].execute().text.trim() + def stagedAppCRD = [ + "yq", + "e", + ".spec.versions[-1]", + "${stagedCRDFileBase}sparkapplications.spark.apache.org-v1.yaml" + ].execute().text.trim() + def stagedClusterCRD = [ + "yq", + "e", + ".spec.versions[-1]", + "${stagedCRDFileBase}sparkclusters.spark.apache.org-v1.yaml" + ].execute().text.trim() + if (generatedAppCRD != stagedAppCRD || generatedClusterCRD != stagedClusterCRD) { + throw new GradleException("Generated CRD yaml does not match the staged version in " + + "Helm Chart, please keep the chart updated.") + } + } +} + +test.finalizedBy('assertGeneratedCRDMatchesHelmChart') --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org