Conversation
khaines
left a comment
There was a problem hiding this comment.
I've seen the golangci tools used in other projects, so if it improves our build process in this project, i'm all for it!
| go vet -stdmethods=false ./pkg/... | ||
| go vet -tags netgo -stdmethods=false ./pkg/... | ||
| misspell -error docs | ||
| golangci-lint run --new-from-rev ed7c302fd968 --build-tags netgo --timeout=5m --enable golint --enable misspell --enable gofmt |
There was a problem hiding this comment.
This is particularly slow when running on OSX (with Docker for Mac) due to the shared volumes performances. Do you see any problem adding :delegated to the 3 related volumes, switching
@$(SUDO) time docker run $(RM) $(TTY) -i \
-v $(shell pwd)/.cache:/go/cache \
-v $(shell pwd)/.pkg:/go/pkg \
-v $(shell pwd):/go/src/github.com/cortexproject/cortex \
$(BUILD_IMAGE) $@;
to
@$(SUDO) time docker run $(RM) $(TTY) -i \
-v $(shell pwd)/.cache:/go/cache:delegated \
-v $(shell pwd)/.pkg:/go/pkg:delegated \
-v $(shell pwd):/go/src/github.com/cortexproject/cortex:delegated \
$(BUILD_IMAGE) $@;
In my case, the execution time difference is:
- Current:
8m8.369s - With delegated:
1m38.258s
There was a problem hiding this comment.
What does :delegated do?
Would we want it on all similar lines?
There was a problem hiding this comment.
What does :delegated do?
The :delegated tells Docker for Mac that the container’s view is authoritative (permit delays before updates on the container appear in the host). Details here: https://docs.docker.com/docker-for-mac/osxfs-caching/
I don't have a Linux box right now to play with, but it should just be ignored on Linux.
Would we want it on all similar lines?
I would say yes.
There was a problem hiding this comment.
Have you considered adding :delegated to volume mounts?
There was a problem hiding this comment.
Have done this now.
Makefile
Outdated
| # -stdmethods=false disables checks for non-standard signatures for methods with familiar names. | ||
| # This is needed because the Prometheus storage interface requires a non-standard Seek() method. | ||
| go vet -stdmethods=false ./pkg/... | ||
| go vet -tags netgo -stdmethods=false ./pkg/... |
There was a problem hiding this comment.
I think go vet is on by default. We use it on Loki.
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
There was a problem hiding this comment.
I did this test: change a printf format string to invalid, e.g. %i.
I get a warning from go vet but not from golangci-lint.
So I am un-convinced.
There was a problem hiding this comment.
Interesting I have the same issue in loki but if I ran it for the specific package it works. Tried to clean my cache also using golangci-lint cache clean.
There was a problem hiding this comment.
This is failing golangci-lint run -v ./pkg/querier/queryrange
but not
golangci-lint run -v ./...
There was a problem hiding this comment.
Found the issue on Loki side, one file was producing warning.
WARN [runner] Can't run linter goanalysis_metalinter: misspell: can't get file /Users/ctovena/go/src/github.com/grafana/loki/pkg/logql/pkg/logql/expr.y contents: can't read file /Users/ctovena/go/src/github.com/grafana/loki/pkg/logql/pkg/logql/expr.y: open /Users/ctovena/go/src/github.com/grafana/loki/pkg/logql/pkg/logql/expr.y: no such file or directory
This was caused by a comment //line expr.y, I cleanup the file and it now catches %i in fmt.
There was a problem hiding this comment.
FYI it was also causing some linter to be skipped.
There was a problem hiding this comment.
You have the same kind of warning.
WARN [runner] Can't run linter goanalysis_metalinter: fact_purity: failed prerequisites: [email protected]/cortexproject/cortex/pkg/chunk [github.com/cortexproject/cortex/pkg/chunk/cache.test]
Not sure why the exit code is not 1.
There was a problem hiding this comment.
I found various issues relating to this - golangci/golangci-lint#866, golangci/golangci-lint#827
beb54f1 to
96b633d
Compare
|
I'm now running Once I do that I am reassured that it does indeed run |
96b633d to
3940048
Compare
|
Rebased and we have a bunch of lint failures from code added since I started this PR! I wonder if we should disable the return value check on log calls (or everywhere)? |
My personal take:
|
e3843d5 to
15a2856
Compare
This is faster and does more checks. * Remove home-grown `lint` script. * Install the `golangci-lint` binary in the build container. * Remove individual tools `gocyclo`, `golint`, `errcheck` which are included in `golangci-lint`. * golangci-lint also runs go vet so we don't need to. Run in `--new-from-rev` mode so it doesn't fail the build on a bunch of warnings that were pre-existing. Also run `misspell` specifically on the docs because `golangci-lint` only does `*.go`. Signed-off-by: Bryan Boreham <[email protected]>
Go caches builds for different tags now, so we don't need to pre-build them. We don't use `dep` any more. Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
15a2856 to
efcec7e
Compare
Signed-off-by: Bryan Boreham <[email protected]>
efcec7e to
62d1042
Compare
|
I figured out how to disable errcheck on individual methods. |
|
@bboreham What's the state of this PR? Is there anything missing? |
|
Ideally it would get an approval after the latest set of changes. |
This is faster and does more checks.
lintscript.golangci-lintbinary in the build container.gocyclo,golint,errcheckwhich are included ingolangci-lint.Run in
--new-from-revmode so it doesn't fail the build on a bunch of warnings that were pre-existing.Still running
go vetseparately because I couldn't see that thevettool insidegolangci-lintis the same thing.Also run
misspellspecifically on the docs becausegolangci-lintonly does*.go.Also remove a couple of unnecessary steps from the build image.