From fa4f936fcbbad1568209864c0756b249769caa63 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Mon, 6 May 2019 18:31:31 -0400 Subject: [PATCH] improves memory usage of golangci-linter --- .circleci/config.yml | 2 +- .golangci.yml | 8 -------- .gometalinter.json | 36 ------------------------------------ Makefile | 2 +- loki-build-image/Dockerfile | 10 ++++++---- pkg/ingester/flush_test.go | 1 + 6 files changed, 9 insertions(+), 50 deletions(-) delete mode 100644 .gometalinter.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 78e0d5b6c7d29..9f3c8e86c5126 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,7 +41,7 @@ workflows: # https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ defaults: &defaults docker: - - image: grafana/loki-build-image:0.2.0 + - image: grafana/loki-build-image:0.2.1 working_directory: /go/src/github.com/grafana/loki jobs: diff --git a/.golangci.yml b/.golangci.yml index 20358201e63be..2583383fdbcd2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,15 +24,11 @@ run: # from this option's value: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ skip-dirs: - # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is # no need to include all autogenerated files, we confidently recognize # autogenerated files. If it's not please let us know. skip-files: - - ".*\\.y$" - - ".*yaccpar$" - # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" @@ -64,11 +60,7 @@ linters: - unused # new from here. - interfacer - typecheck - - dupl - - gocyclo - - nakedret issues: - exclude-use-default: false exclude: - Error return value of .*log\.Logger\)\.Log\x60 is not checked \ No newline at end of file diff --git a/.gometalinter.json b/.gometalinter.json deleted file mode 100644 index 7ae7ffc20a860..0000000000000 --- a/.gometalinter.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Vendor": true, - "Deadline": "5m", - "Concurrency": 2, - "Linters": { - "gofmt": {"Command": "gofmt -l -s -w"}, - "goimports": {"Command": "goimports -l -w"} - }, - "Exclude": [ - "\\.pb\\.go", - "pkg/promtail/server/ui/assets_vfsdata.go", - "method Seek.*should have signature", - "error return value not checked \\(level\\.", - "\"err\" shadows declaration" - ], - - "Enable": [ - "deadcode", - "errcheck", - "goconst", - "gofmt", - "goimports", - "golint", - "gosimple", - "gotypex", - "ineffassign", - "megacheck", - "misspell", - "structcheck", - "unconvert", - "unparam", - "varcheck", - "vet", - "vetshadow" - ] -} diff --git a/Makefile b/Makefile index b5adeb5be5ec6..e40b0c0026a0d 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ $(EXES): loki-build-image/$(UPTODATE) goyacc -p $(basename $(notdir $<)) -o $@ $< lint: loki-build-image/$(UPTODATE) - golangci-lint run + GOGC=20 golangci-lint run check-generated-files: loki-build-image/$(UPTODATE) yacc protos @git diff-files || (echo "changed files; failing check" && exit 1) diff --git a/loki-build-image/Dockerfile b/loki-build-image/Dockerfile index 005b806710a87..cff510148c33d 100644 --- a/loki-build-image/Dockerfile +++ b/loki-build-image/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.11.2-stretch +FROM golang:1.11.4-stretch RUN apt-get update && apt-get install -y file jq unzip protobuf-compiler libprotobuf-dev && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ENV DOCKER_VER="17.03.0-ce" @@ -18,9 +18,11 @@ RUN go get \ github.com/go-delve/delve/cmd/dlv \ golang.org/x/tools/cmd/goyacc && \ rm -rf /go/pkg /go/src -ENV GOLANGCI_LINT_VER="1.16.0" -RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VER} && \ - golangci-lint --version +ENV GOLANGCI_LINT_COMMIT="692dacb773b703162c091c2d8c59f9cd2d6801db" +RUN mkdir -p $(go env GOPATH)/src/github.com/golangci/ && git clone https://github.com/golangci/golangci-lint.git $(go env GOPATH)/src/github.com/golangci/golangci-lint && \ + cd $(go env GOPATH)/src/github.com/golangci/golangci-lint && git checkout ${GOLANGCI_LINT_COMMIT} && cd cmd/golangci-lint/ &&\ + GO111MODULE=on go install && \ + golangci-lint help COPY build.sh / ENV GOCACHE=/go/cache ENTRYPOINT ["/build.sh"] diff --git a/pkg/ingester/flush_test.go b/pkg/ingester/flush_test.go index 9cfa8fbd5ff6d..f5c146803a35d 100644 --- a/pkg/ingester/flush_test.go +++ b/pkg/ingester/flush_test.go @@ -68,6 +68,7 @@ func newTestStore(t require.TestingT, cfg Config) (*testStore, *Ingester) { return store, ing } +// nolint func defaultIngesterTestConfig() Config { consul := ring.NewInMemoryKVClient() cfg := Config{}