Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Fix golangci errors #1058

Merged
merged 5 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 34 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
command: |
mkdir -p $GOCACHE

make build-deps citest
make citest
if [ -n "$CC_TEST_REPORTER_ID" ]; then
make ci-upload-coverage
fi
Expand All @@ -192,6 +192,29 @@ jobs:
- /tmp/go/cache
key: ship-unit-test-build-cache-{{ epoch }}


lint:
docker:
- image: circleci/golang:1.12
environment:
GOCACHE: "/tmp/go/cache"
working_directory: /go/src/github.com/replicatedhq/ship
steps:
- checkout
- restore_cache:
keys:
- ship-lint-build-cache
- run:
name: make test
command: |
mkdir -p $GOCACHE

make cilint
- save_cache:
paths:
- /tmp/go/cache
key: ship-lint-build-cache-{{ epoch }}

pacts:
docker:
- image: circleci/golang:1.12
Expand Down Expand Up @@ -635,6 +658,7 @@ workflows:
- e2e_setup

- test
- lint
- pacts
- windows_build_test
- docs
Expand Down Expand Up @@ -671,6 +695,7 @@ workflows:
- e2e_setup
- e2e_init
- test
- lint
- pacts
- windows_build_test
- integration_base
Expand Down Expand Up @@ -740,6 +765,13 @@ workflows:
branches:
ignore: /.*/

- lint:
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)*(-.*)*/
branches:
ignore: /.*/

- pacts:
filters:
tags:
Expand Down Expand Up @@ -817,6 +849,7 @@ workflows:
- e2e_setup
- e2e_init
- test
- lint
- pacts
- windows_build_test
- integration_base
Expand Down
3 changes: 3 additions & 0 deletions .errcheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(*github.com/go-kit/kit/log.Logger).Log
(*github.com/replicatedhq/ship/pkg/testing/logger.TestLogger).Log
(*github.com/gin-gonic/gin.Context).AbortWithError
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
run:
deadline: 2m

linters-settings:
errcheck:
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude: ./.errcheck.txt

# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,github.com/go-kit/kit/log:.*
62 changes: 39 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.NOTPARALLEL:

.PHONY: build-deps dep-deps docker shell githooks dep e2e run citest ci-upload-coverage goreleaser integration-test build_ship_integration_test build-ui build-ui-dev mark-ui-gitignored fmt lint vet test build embed-ui clean-ship clean clean-integration
.PHONY: build-deps docker shell githooks dep e2e run citest ci-upload-coverage goreleaser integration-test build_ship_integration_test build-ui build-ui-dev mark-ui-gitignored fmt lint vet test build embed-ui clean-ship clean clean-integration

export GO111MODULE=on

SHELL := /bin/bash -o pipefail
SRC = $(shell find pkg -name "*.go" ! -name "ui.bindatafs.go")
Expand Down Expand Up @@ -46,14 +47,18 @@ define LDFLAGS
endef

.state/build-deps: hack/get_build_deps.sh
./hack/get_build_deps.sh
time ./hack/get_build_deps.sh
@mkdir -p .state/
@touch .state/build-deps

build-deps: .state/build-deps

dep-deps:
go get -u github.com/golang/dep/cmd/dep
.state/lint-deps: hack/get_lint_deps.sh
time ./hack/get_lint_deps.sh
@mkdir -p .state/
@touch .state/lint-deps

lint-deps: .state/lint-deps

docker:
docker build -t ship .
Expand All @@ -75,24 +80,24 @@ githooks:

.PHONY: pacts
pacts:
go test -v ./contracts/...
go test -v -mod vendor ./contracts/...

.PHONY: pacts-ci
pacts-ci:
docker build -t ship-contract-tests -f contracts/Dockerfile.testing .
docker run --rm --name ship-contract-tests \
ship-contract-tests \
bash -c 'go test -v ./contracts/...'
bash -c 'go test -v -mod vendor ./contracts/...'

.PHONY: pacts-ci-publish
pacts-ci-publish:
docker build -t ship-contract-tests -f contracts/Dockerfile.testing .
docker run --rm --name ship-contract-tests \
-e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD -e VERSION=$$CIRCLE_TAG \
ship-contract-tests \
bash -c 'go test -v ./contracts/... && ./contracts/publish.sh'
bash -c 'go test -v -mod vendor ./contracts/... && ./contracts/publish.sh'

_mockgen:
_mockgen: build-deps
rm -rf pkg/test-mocks
mkdir -p pkg/test-mocks/ui
mkdir -p pkg/test-mocks/config
Expand Down Expand Up @@ -243,43 +248,49 @@ deps:
@touch .state/fmt


fmt: .state/build-deps .state/fmt
fmt: .state/lint-deps .state/fmt

.state/vet: $(SRC)
go vet ./pkg/...
go vet ./cmd/...
go vet ./integration/...
go vet -mod vendor ./pkg/...
go vet -mod vendor ./cmd/...
go vet -mod vendor ./integration/...
@mkdir -p .state
@touch .state/vet

vet: .state/vet

.state/ineffassign: .state/build-deps $(SRC)
ineffassign ./pkg
ineffassign ./cmd
ineffassign ./integration
.state/golangci-lint-ci: .state/lint-deps $(SRC)
golangci-lint run -j 1 ./cmd/...
for D in ./pkg/*; do echo $$D; golangci-lint run -j 1 $$D/...; done
@mkdir -p .state
@touch .state/ineffassign
@touch .state/golangci-lint-ci

ineffassign: .state/ineffassign
.state/golangci-lint: .state/lint-deps $(SRC)
golangci-lint run ./pkg/...
golangci-lint run ./cmd/...
golangci-lint run ./integration/...
@mkdir -p .state
@touch .state/golangci-lint

golangci-lint: .state/golangci-lint

.state/lint: $(SRC)
golint ./pkg/... | grep -vE '_mock|e2e' | grep -v "should have comment" | grep -v "comment on exported" | grep -v "package comment should be of the form" | grep -v bindatafs || :
golint ./cmd/... | grep -vE '_mock|e2e' | grep -v "should have comment" | grep -v "comment on exported" | grep -v "package comment should be of the form" | grep -v bindatafs || :
@mkdir -p .state
@touch .state/lint

lint: vet ineffassign .state/lint
lint: vet golangci-lint .state/lint

.state/test: $(SRC)
go test ./pkg/... ./integration | grep -v '?'
go test -mod vendor ./pkg/... ./integration | grep -v '?'
@mkdir -p .state
@touch .state/test

test: lint .state/test

.state/race: $(SRC)
go test --race ./pkg/...
go test --race -mod vendor ./pkg/...
@mkdir -p .state
@touch .state/race

Expand All @@ -288,9 +299,12 @@ race: lint .state/race
.state/coverage.out: $(SRC)
@mkdir -p .state/
#the reduced parallelism here is to avoid hitting the memory limits - we consistently did so with two threads on a 4gb instance
go test -parallel 1 -p 1 -coverprofile=.state/coverage.out ./pkg/... ./integration
go test -parallel 1 -p 1 -coverprofile=.state/coverage.out -mod vendor ./pkg/... ./integration

citest: .state/coverage.out

citest: .state/vet .state/ineffassign .state/lint .state/coverage.out
.PHONY: cilint
cilint: .state/vet .state/golangci-lint-ci .state/lint

.state/cc-test-reporter:
@mkdir -p .state/
Expand All @@ -311,6 +325,7 @@ build-minimal: build-ui pkg/lifecycle/daemon/ui.bindatafs.go bin/ship

bin/ship: $(FULLSRC)
go build \
-mod vendor \
${LDFLAGS} \
-i \
-o bin/ship \
Expand All @@ -319,6 +334,7 @@ bin/ship: $(FULLSRC)

bin/ship.exe: $(SRC)
GOOS=windows go build \
-mod vendor \
${LDFLAGS} \
-i \
-o bin/ship.exe \
Expand Down
1 change: 1 addition & 0 deletions contracts/Dockerfile.testing
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM golang:1.12

RUN cd /opt && curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/v1.66.0/install.sh | bash
ENV PATH="/opt/pact/bin:${PATH}"
ENV GO111MODULE=on

WORKDIR /go/src/github.com/replicatedhq/ship

Expand Down
18 changes: 12 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ require (
github.com/go-stack/stack v1.8.0
github.com/go-test/deep v1.0.1
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/mock v1.2.0
github.com/golang/mock v1.3.1
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/golangci/golangci-lint v1.17.1 // indirect
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-github/v18 v18.0.0
github.com/google/go-querystring v1.0.0
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/google/uuid v1.1.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 // indirect
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001
Expand All @@ -72,10 +73,10 @@ require (
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da
github.com/jmoiron/sqlx v1.2.0 // indirect
github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be // indirect
github.com/jteeuwen/go-bindata v3.0.7+incompatible // indirect
github.com/lib/pq v1.1.1 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.0.0-20180723221831-d5012789d665 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mattn/go-runewidth v0.0.3 // indirect
github.com/mcuadros/go-jsonschema-generator v0.0.0-20171001215842-821f57ef6082
github.com/mholt/archiver v0.0.0-20180417220235-e4ef56d48eb0
Expand All @@ -87,8 +88,8 @@ require (
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
github.com/mozilla-services/yaml v0.0.0-20180922153656-28ffe5d0cafb // indirect
github.com/nwaples/rardecode v0.0.0-20171029023500-e06696f847ae // indirect
github.com/onsi/ginkgo v1.5.0
github.com/onsi/gomega v1.4.0
github.com/onsi/ginkgo v1.6.0
github.com/onsi/gomega v1.4.2
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pact-foundation/pact-go v1.0.0-beta.5
Expand All @@ -110,8 +111,13 @@ require (
github.com/zclconf/go-cty v0.0.0-20181017232614-01c5aba823a6 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
go.uber.org/dig v1.3.0
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190827205025-b29f5f60c37a // indirect
google.golang.org/appengine v1.3.0 // indirect
google.golang.org/grpc v1.21.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
Expand Down
Loading