From b6ea016f7a5dd80336eeadb5b3f1043416c6dab5 Mon Sep 17 00:00:00 2001 From: Shahul Date: Mon, 22 Nov 2021 18:16:04 +0530 Subject: [PATCH 1/2] Update Verify CI job to check CRD generation We have a Verify CI job that runs the basic static analysis, like code linting. This step should also ensure that CRD definitions for the Build APIs are aligned with what is in the golang code. Fixes #943 Update hack/verify-generate.sh to check CRDs and deep copy generation Update deep copy generation file not in sync --- .github/workflows/verify.yaml | 2 +- DEVELOPMENT.md | 2 +- Makefile | 9 ++++----- hack/README.md | 1 + hack/verify-generate.sh | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index c32f91d20e..6e1316dfab 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -40,4 +40,4 @@ jobs: run: | make -C $GOPATH/src/github.com/shipwright-io/build \ sanity-check \ - verify-codegen + verify-generate diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 268d423e6c..9db70938d2 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -147,7 +147,7 @@ As you make changes to the code, you can redeploy your controller with: ``` You may use the following command to re-generate CRDs of build and buildrun if you change their spec: ```sh - make generate-crds + make generate ``` ### Tear it down diff --git a/Makefile b/Makefile index a52cc94df4..1949304f05 100644 --- a/Makefile +++ b/Makefile @@ -107,9 +107,11 @@ generate: hack/update-codegen.sh hack/generate-fakes.sh hack/generate-copyright.sh + hack/install-controller-gen.sh + "$(CONTROLLER_GEN)" "$(CRD_OPTIONS)" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=deploy/crds -.PHONY: verify-codegen -verify-codegen: generate +.PHONY: verify-generate +verify-generate: generate @hack/verify-generate.sh ginkgo: @@ -299,6 +301,3 @@ kind: ./hack/install-kind.sh ./hack/install-registry.sh -generate-crds: - ./hack/install-controller-gen.sh - "$(CONTROLLER_GEN)" "$(CRD_OPTIONS)" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=deploy/crds diff --git a/hack/README.md b/hack/README.md index 7547a0e028..797fff7367 100644 --- a/hack/README.md +++ b/hack/README.md @@ -18,3 +18,4 @@ This directory contains several scripts useful in the development process of Shi - `release.sh` Creates a new release of Shipwright Build. - `update-codegen.sh` Updates auto-generated client libraries. - `verify-codegen.sh` Verifies that auto-generated client libraries are up-to-date. +- `verify-generate.sh` Check both uncommited/unstaged changes for CRDs and the client code. diff --git a/hack/verify-generate.sh b/hack/verify-generate.sh index 304dd342ba..b672e64ed1 100755 --- a/hack/verify-generate.sh +++ b/hack/verify-generate.sh @@ -6,11 +6,11 @@ # Verifies if a developer has forgot to run the # `make generate` so that all the changes in the -# clientset should also be pushed +# clientset and CRDs should also be pushed -if [[ -n "$(git status --porcelain -- pkg/client)" ]]; then - echo "The pkg/client package contains changes:" - git --no-pager diff --name-only -- pkg/client +if [[ -n "$(git status --porcelain -- pkg/client pkg/apis deploy/crds)" ]]; then + echo "The pkg/client, pkg/apis package or CRDs contains changes:" + git --no-pager diff --name-only -- pkg/client pkg/apis deploy/crds echo echo "Run make generate to those commit changes!" exit 1 From 9f1f57ad775c3063965be1556681ccbe586e8e66 Mon Sep 17 00:00:00 2001 From: Shahul Date: Tue, 23 Nov 2021 11:16:00 +0530 Subject: [PATCH 2/2] Generate files --- hack/README.md | 2 +- pkg/apis/build/v1alpha1/zz_generated.deepcopy.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/hack/README.md b/hack/README.md index 797fff7367..484c7044a9 100644 --- a/hack/README.md +++ b/hack/README.md @@ -18,4 +18,4 @@ This directory contains several scripts useful in the development process of Shi - `release.sh` Creates a new release of Shipwright Build. - `update-codegen.sh` Updates auto-generated client libraries. - `verify-codegen.sh` Verifies that auto-generated client libraries are up-to-date. -- `verify-generate.sh` Check both uncommited/unstaged changes for CRDs and the client code. +- `verify-generate.sh` Check both uncommitted/unstaged changes for CRDs and the client code. diff --git a/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go index a66bc797f7..9028a98f6c 100644 --- a/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/build/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,3 @@ -//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright The Shipwright Contributors