Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify generated mocks are up to date #690

Closed
0xmichalis opened this issue Nov 5, 2018 · 6 comments
Closed

verify generated mocks are up to date #690

0xmichalis opened this issue Nov 5, 2018 · 6 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@0xmichalis
Copy link
Contributor

If I go generate ./... in the current HEAD, I get a diff in the mocking clients. We probably need to verify these in hack/validate-generated.sh to avoid drifting.

/assign @asalkeld
/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 5, 2018
@0xmichalis 0xmichalis changed the title verify mocking generated code is up to date verify generated mocks are up to date Nov 5, 2018
@asalkeld
Copy link
Contributor

asalkeld commented Nov 6, 2018

@Kargakis this code should check it: https://github.com/openshift/openshift-azure/blob/master/hack/validate-generated.sh#L23

if you run "make verify" does it not catch the diff?

  1. what version of go do you have?
  2. what is the diff that you get?

for me:

[angus] ~/.../openshift/openshift-azure  (master)$ git pull
Already up to date.
[angus] ~/.../openshift/openshift-azure  (master)$ go generate ./...
bindata.go
bindata.go
[angus] ~/.../openshift/openshift-azure  (master)$ git diff
[angus] ~/.../openshift/openshift-azure  (master)$ 

Also my verify does check the mocks


[angus] ~/.../openshift/openshift-azure  (master)$ make verify 
./hack/validate-generated.sh
++ mktemp -d
+ T=/tmp/tmp.NwRUY7Jds5
+ trap 'rm -rf /tmp/tmp.NwRUY7Jds5' EXIT
+ cp -a /home/angus/go/src/github.com/openshift/openshift-azure/hack/.. /tmp/tmp.NwRUY7Jds5/
+ cd /tmp/tmp.NwRUY7Jds5/
+ go generate ./...
bindata.go
bindata.go
++ git grep --name-only 'Code generated by .* DO NOT EDIT.*' -- ':^vendor' ':^hack'
+ GENERATED_FILES='pkg/addons/bindata.go
pkg/arm/bindata.go
pkg/jsonpath/parser.go
pkg/util/mocks/mock_arm/arm.go
pkg/util/mocks/mock_azureclient/azureclient.go
pkg/util/mocks/mock_azureclient/mock_storage/storage.go
pkg/util/mocks/mock_upgrade/types.go
pkg/util/mocks/mock_wait/wait.go'
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/addons/bindata.go /tmp/tmp.NwRUY7Jds5/pkg/addons/bindata.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/arm/bindata.go /tmp/tmp.NwRUY7Jds5/pkg/arm/bindata.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/jsonpath/parser.go /tmp/tmp.NwRUY7Jds5/pkg/jsonpath/parser.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/util/mocks/mock_arm/arm.go /tmp/tmp.NwRUY7Jds5/pkg/util/mocks/mock_arm/arm.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/util/mocks/mock_azureclient/azureclient.go /tmp/tmp.NwRUY7Jds5/pkg/util/mocks/mock_azureclient/azureclient.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/util/mocks/mock_azureclient/mock_storage/storage.go /tmp/tmp.NwRUY7Jds5/pkg/util/mocks/mock_azureclient/mock_storage/storage.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/util/mocks/mock_upgrade/types.go /tmp/tmp.NwRUY7Jds5/pkg/util/mocks/mock_upgrade/types.go
+ for file in ${GENERATED_FILES}
+ diff -r /home/angus/go/src/github.com/openshift/openshift-azure/hack/../pkg/util/mocks/mock_wait/wait.go /tmp/tmp.NwRUY7Jds5/pkg/util/mocks/mock_wait/wait.go
+ echo 'Generated assets have no material difference than what is committed.'
Generated assets have no material difference than what is committed.
+ rm -rf /tmp/tmp.NwRUY7Jds5
go vet ./...
./hack/verify-code-format.sh

@asalkeld
Copy link
Contributor

asalkeld commented Nov 6, 2018

if you have go 1.11 beware of this: golang/go#25161
I upgraded to fedora 29 and had to install 1.10 to not get gofmt diffs.

@0xmichalis
Copy link
Contributor Author

0xmichalis commented Nov 6, 2018 via email

@asalkeld
Copy link
Contributor

@Kargakis it is still not clear what needs to be done here, can you be more specific please?

@0xmichalis
Copy link
Contributor Author

@asalkeld in d8a538d I submitted generated code about one of the azure clients w/o touching that client. Seems that the generated files are not compared correctly in CI. I just run the command from validate-generated.sh locally and I get no output (no files returned from grep). The same thing seems to happen in CI, eg. see https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_openshift-azure/683/pull-ci-openshift-openshift-azure-master-verify/513/build-log.txt where GENERATED_FILES is empty.

@0xmichalis
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants