Skip to content

Commit

Permalink
Update Verify CI job to check CRD generation
Browse files Browse the repository at this point in the history
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 shipwright-io#943

Add hack/verify-controller-gen.sh to check CRD generation
Update hack/verify-generate.sh to check for deep copy generation
Update deep copy generation file not in sync
  • Loading branch information
Shahul authored and Shahul committed Nov 22, 2021
1 parent b959360 commit 7f159f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ jobs:
run: |
make -C $GOPATH/src/github.com/shipwright-io/build \
sanity-check \
verify-codegen
verify-codegen \
verify-controller-gen
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ generate:
verify-codegen: generate
@hack/verify-generate.sh

.PHONY: verify-controller-gen
verify-controller-gen: generate-crds
@hack/verify-controller-gen.sh

ginkgo:
ifeq (, $(shell which ginkgo))
@{ \
Expand Down
1 change: 1 addition & 0 deletions hack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-controller-gen.sh` Verifies if a developer has forgot to run the `make generate-crds`
17 changes: 17 additions & 0 deletions hack/verify-controller-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Copyright The Shipwright Contributors
#
# SPDX-License-Identifier: Apache-2.0

# Verifies if a developer has forgot to run the
# `make generate-crds` so that all the changes in the
# CRD (deploy/crds) should also be pushed

if [[ -n "$(git status --porcelain -- deploy/crds)" ]]; then
echo "The deploy/crds contains changes:"
git --no-pager diff --name-only -- deploy/crds
echo
echo "Run make generate-crds to those commit changes!"
exit 1
fi
6 changes: 3 additions & 3 deletions hack/verify-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# `make generate` so that all the changes in the
# clientset 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)" ]]; then
echo "The pkg/client or pkg/apis package contains changes:"
git --no-pager diff --name-only -- pkg/client pkg/apis
echo
echo "Run make generate to those commit changes!"
exit 1
Expand Down

0 comments on commit 7f159f7

Please sign in to comment.