Skip to content

Commit

Permalink
add checker for deepcopy generated code
Browse files Browse the repository at this point in the history
To avoid code from being merged without being regenerated, this commit
adds a checker, that will only run in the CI, to verify if there is code
ungenerated.

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm authored and gandro committed Apr 27, 2020
1 parent ac4874a commit 98728bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -32,6 +32,7 @@ BENCHFLAGS ?= $(BENCHFLAGS_EVAL)
LOGLEVEL ?= "error"
SKIP_VET ?= "false"
SKIP_KVSTORES ?= "false"
SKIP_K8S_CODE_GEN_CHECK ?= "true"

JOB_BASE_NAME ?= cilium_test

Expand Down Expand Up @@ -424,6 +425,10 @@ microk8s: check-microk8s
@echo " microk8s.kubectl -n kube-system delete pod -l k8s-app=cilium"

precheck: ineffassign logging-subsys-field
ifeq ($(SKIP_K8S_CODE_GEN_CHECK),"false")
@$(ECHO_CHECK) contrib/scripts/check-k8s-code-gen.sh
$(QUIET) contrib/scripts/check-k8s-code-gen.sh
endif
@$(ECHO_CHECK) contrib/scripts/check-fmt.sh
$(QUIET) contrib/scripts/check-fmt.sh
@$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh
Expand Down
22 changes: 22 additions & 0 deletions contrib/scripts/check-k8s-code-gen.sh
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e
set -o pipefail

# Delete all zz_generated.deepcopy.go files
find . -not -path "./vendor/*" -iname "*zz_generated.deepcopy.go" -exec rm {} \;

# Generate all files
make generate-k8s-api

# Check for diff
diff="$(git diff)"

if [ -n "$diff" ]; then
echo "Ungenerated deepcopy source code:"
echo "$diff"
echo "Please run make generate-k8s-api and submit your changes"
exit 1
fi

exit 0
2 changes: 1 addition & 1 deletion test/provision/compile.sh
Expand Up @@ -72,7 +72,7 @@ then
fi
else
echo "compiling cilium..."
sudo -u vagrant -H -E make LOCKDEBUG=1 SKIP_DOCS=true
sudo -u vagrant -H -E make LOCKDEBUG=1 SKIP_K8S_CODE_GEN_CHECK=false SKIP_DOCS=true
echo "installing cilium..."
make install
mkdir -p /etc/sysconfig/
Expand Down

0 comments on commit 98728bb

Please sign in to comment.