From 8cfbe6a0eb440777d42d8b54015ddf638b4c4a61 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 19 Jul 2024 15:56:56 +0200 Subject: [PATCH] ci: OpenAPI model generated files checked in pipeline Signed-off-by: Marc Nuri --- .github/workflows/{gobuild.yml => generate-model.yml} | 10 ++++++---- Makefile | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) rename .github/workflows/{gobuild.yml => generate-model.yml} (80%) diff --git a/.github/workflows/gobuild.yml b/.github/workflows/generate-model.yml similarity index 80% rename from .github/workflows/gobuild.yml rename to .github/workflows/generate-model.yml index 5f689ef437a..1977ba69d60 100644 --- a/.github/workflows/gobuild.yml +++ b/.github/workflows/generate-model.yml @@ -14,7 +14,7 @@ # limitations under the License. # -name: Go Generate Model +name: Generate Model on: push: @@ -55,11 +55,13 @@ jobs: - name: Check No Schema file modified run: | git add . - MODIFIED_KUBE_SCHEMA=`git status | grep -v 'validation-schema.json' | grep 'kube-schema.json\|src/generated/java' | wc -l` - if [ $MODIFIED_KUBE_SCHEMA -eq "0" ]; then + IGNORED_PATTERNS="validation-schema.json" + INCLUDE_PATTERNS="kube-schema.json\|src/generated/java\|openapi/schemas/" + MODIFIED_FILES_COUNT=$(git status | grep -v "$IGNORED_PATTERNS" | grep "$INCLUDE_PATTERNS" | wc -l) + if [ $MODIFIED_FILES_COUNT -eq "0" ]; then echo "No Schema files modified. Build Success."; else - git status | grep -v 'validation-schema.json' | grep 'kube-schema.json\|src/generated/java' + git status | grep -v "$IGNORED_PATTERNS" | grep "$INCLUDE_PATTERNS" echo "Schema files modified. Build Failure"; exit 1; fi; diff --git a/Makefile b/Makefile index 2e58b842174..2444feba0c8 100644 --- a/Makefile +++ b/Makefile @@ -29,10 +29,13 @@ generate-openapi: ./kubernetes-model-generator/openapi/generator/generator ./kubernetes-model-generator/openapi/schemas # Legacy generation of the model: TODO: remove -.PHONY: generate-model -generate-model: +.PHONY: generate-model-legacy +generate-model-legacy: cd kubernetes-model-generator && ./generateModel.sh +.PHONY: generate-model +generate-model: generate-openapi generate-model-legacy + .PHONY: sonar sonar: mvn $(MAVEN_OPTIONS) clean install sonar:sonar -Psonar