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
Improve code checking #131
Conversation
f62f265
to
6c9fc87
Compare
3fa39f7
to
fbdcdc5
Compare
22fdf59
to
37b5e21
Compare
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.
overall looks good just two small nits
37b5e21
to
6763c47
Compare
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!
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.
To be sure to run static code checks and code generations tools before calling docker build we can track source files with
c4d88c4
to
c632efe
Compare
8c2db6e
to
0203acf
Compare
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, we have to be careful with deletes though.
fe7bb97
to
de041b2
Compare
de041b2
to
f44d913
Compare
Signed-off-by: Petr Horacek <phoracek@redhat.com>
db0341a
to
d33880f
Compare
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.
my comments are largely nits / nice to haves so not blocking the merge here.
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.
Found how to fix rebuild on deletes, let's just add that and merge.
@qinqon sorry man, but I also need all_sources (exluding vendor/), and I'm not able to pull that off using beautiful Makefile tools. Tried following, but it doesn't filter-out anything:
We can reiterate on that part. |
d33880f
to
6690002
Compare
6690002
to
9df0636
Compare
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.
Finding all files is loaded everytime we call make... maybe is time to move to pre-commit.
Also you have to replace find by the rwildcard
Makefile
Outdated
|
||
# Gather needed source files and directories to create target dependencies | ||
all_sources := $(shell git ls-files -- ':!vendor/') | ||
cmd_sources := $(shell find ./cmd/ -type f -name '*.go') |
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.
You have to use the rwildcard make function we just created and also add the directory to detect deletes.
# Gather needed source files and directories to create target dependencies
cmd_sources := $(call rwildcard,cmd/,*.go) cmd/
pkg_sources := $(call rwildcard,pkg/,*.go) pkg/
apis_sources := $(call rwildcard,pkg/apis/,*.go) pkg/apis/
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.
Makefile
Outdated
pkg_sources := $(shell find ./pkg/ -type f -name '*.go') | ||
apis_sources := $(shell find ./pkg/apis/ -type f -name '*.go') | ||
|
||
petr: |
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.
Have to be good to be a make target :-)
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.
:(
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.
Petr deserves it
Makefile
Outdated
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) | ||
|
||
# Gather needed source files and directories to create target dependencies | ||
all_sources := $(shell git ls-files -- ':!vendor/') |
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.
We have to be careful making this depend on git, if we use at build we are not going to be able to build from tarball for example.
This sanity check stuff is starting to blow out of proportion, at openstack we use pre-commit and there some pre-commit hooks for golang
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.
make whitespace-check 0.09s user 0.02s system 97% cpu 0.114 total
793e629
to
ef922a0
Compare
Use goimports to check code: goimports checks what gofmt does plus it keeps imports in specific order. In this patch we: - replace gofmt with goimports - add code format checking to travis - reorganize Makefile a little bit - remove make generate-manifests from README.md since it is not needed during the development process - add Makefile target for operator-sdk build k8s Add whitespace check and auto-formatting: I hate trailing whitespaces. This patch adds automated check detecting any and Makefile target removing them. Add codegen validation: Add a check validating that generated code is up to date. This would fail on travis in case a contributor forget to run `make generate-api`. ship and goimports operator-sdk in vendor/: In order to make sure everyone uses the same version of operator-sdk producing the same code, let's keep operator-sdk in vendoring. The same for goimports. Signed-off-by: Petr Horacek <phoracek@redhat.com>
ef922a0
to
a6a1107
Compare
ci test please |
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 love approving PRs with 1.5 mln LOC.
Feels good, thanks guys |
Let's automate more code validation. And reorganize Makefile targets a little.