-
Notifications
You must be signed in to change notification settings - Fork 886
Check that generated protocol buffer code is up to date #2217
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
Conversation
|
@fcrisciani As discussed in #2193. I can hook this up to the main build target if you prefer. |
|
@euanh wondering if from a CI point of view, makes sense to separate the protobuf generation as a separate workflow and run it in parallel with the rest of them after the builder. what do you think? |
Makefile
Outdated
| dockerbuildargs ?= --target dev - < Dockerfile | ||
| dockerargs ?= --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork | ||
| dockerargs ?= --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork ${dockerargs_extra} | ||
| dockerargs_extra ?= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't see this as being used, is it still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as I said in the commit message it's there to make it easy to add extra arguments to the docker command line, for instance to bind mount an extra volume on a development machine.
.circleci/config.yml
Outdated
| working_directory: ~/go/src/github.com/docker/libnetwork | ||
| docker: | ||
| - image: 'circleci/golang:1.10' | ||
| - image: 'circleci/golang:1.10.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this image is irrelevant, everything is built within a container, we can probably take something smaller also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It would be better not to have Go in the base image at all, so there is no chance that a new build job accidentally uses it.
The image we use comes from here: https://github.com/circleci-public/circleci-dockerfiles. There isn't a minimal image in that repo. We could try https://hub.docker.com/r/circleci/slim-base/ but I don't know if it's actively maintained. CircleCI requires a few utilities in the image https://circleci.com/docs/2.0/custom-images so we could make an Alpine-based image, but then we would have to maintain it.
c252f7f to
b7413ec
Compare
|
@fcrisciani I can put it in a separate workflow if you prefer. However keeping it in |
|
@euanh it's ok to keep it then in the check, and the rename of the workflow makes sense. |
|
@fcrisciani Yes, I haven't pushed my fix for check yet. It's broken here because in CI we don't copy the |
|
we specifically made that change for circle2.0 (coping the source) for the same reason you mentioned above. If you want to copy other files (.git), you can make changes in .dockerignore file and remove .git from the file. that will help you. |
|
@selansen Yes, however adding .git to the build container means copying an ever-growing amount of extra data - currently 27MB. It would be better if we didn't have to do that. |
|
@euanh what if the CI will generate the protobuf in a tmp directory and then you do the diff from there? |
|
@fcrisciani That's what I have. :) It's currently just implemented with a rather ugly rule which I'm tidying up. |
|
@euanh no |
|
@fcrisciani Yes, I meant that's what I have at the moment on my machine, but I haven't pushed it yet. |
|
The top change overloads the .protoc -> .pb.go rule to have a 'check mode'. The command line is duplicated but that's easy to fix. Having an if statement in there at all is a bit ugly - I also had a version which built the .pb.go files to /tmp by overriding the GOGO_OUTDIR. After that I could just loop over them and compare. |
| %.pb.go: %.proto | ||
| @if [ ${PROTOC_CHECK} ]; then \ | ||
| protoc -I=. -I=/go/src -I=/go/src/github.com/gogo/protobuf -I=/go/src/github.com/gogo/protobuf/protobuf --gogo_out=/tmp $< ; \ | ||
| diff -q $@ /tmp/$@ >/dev/null || (echo "👹 $@ is out of date; please run 'make protobuf' and check in updates" && exit 1) ; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we pass the --gogo_out path directly as an ENV variable like we do for dockerbuildargs (https://github.com/docker/libnetwork/pull/2217/files#diff-1d37e48f9ceff6d8030570cd36286a61L9)
that way we don't need PROTOC_CHECK, locally you will always want to regenerate them eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you can also use the notion of the CIRCLE_CI env variable that is already passed and set at the top of the makefile the output path so no need to specify other env variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer for make check to work in the same way whether you run it in CircleCI or on your own machine, so I can't use the CIRCLE_CI variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tried passing --gogo_out path as a variable, but then you still have to decide whether or not to run diff so it doesn't help much.
Signed-off-by: Euan Harris <euan.harris@docker.com>
Add documentation and move protobuf target into Build section Signed-off-by: Euan Harris <euan.harris@docker.com>
Outside the build container, run: make protobuf Inside the build container, run: make protobuf-local Signed-off-by: Euan Harris <euan.harris@docker.com>
'make check' will now fail if the files produced by re-running protoc differ from those which are checked into the repository. Signed-off-by: Euan Harris <euan.harris@docker.com>
fcrisciani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
make checkwill now regenerate the.pb.gofiles and fail if the results are different from what is checked into the repository.