Skip to content
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

ci: Use golangci-lint for linting #7440

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@ jobs:
- checkout
- run: go get -u github.com/hashicorp/lint-consul-retry && lint-consul-retry

# Runs go fmt and go vet
go-fmt-and-vet:
# Runs Go linters
lint:
docker:
- image: *GOLANG_IMAGE
steps:
- checkout
- run:
command: go mod download
- run:
name: check go fmt
name: Install golangci-lint
command: |
files="$(go fmt ./... ; (cd api && go fmt ./... | sed 's@^@api/@') ; (cd sdk && go fmt ./... | sed 's@^@sdk/@'))"
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
wget -O- -q $download | sh -s -- -b /go/bin/ v1.23.6
- run: go mod download
- run:
command: |
go vet ./... && \
(cd api && go vet ./...) && \
(cd sdk && go vet ./...)
environment:
<<: *ENVIRONMENT
name: lint
command: &lintcmd |
golangci-lint run -v --concurrency 2
- run:
name: lint api
working_directory: api
command: *lintcmd
- run:
name: lint sdk
working_directory: sdk
command: *lintcmd

# checks vendor directory is correct
check-vendor:
Expand Down Expand Up @@ -619,15 +619,13 @@ workflows:
- stable-website
- /^docs\/.*/
- /^ui\/.*/
- go-fmt-and-vet:
requires:
- check-vendor
- dev-build:
requires:
- go-fmt-and-vet
- lint
- dev-build
- go-test: &go-test
requires:
- dev-build
- lint
- check-vendor
- go-test-api: *go-test
- go-test-sdk: *go-test
- coverage-merge:
Expand Down
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
linters:
disable-all: true
enable:
- gofmt
- govet

issues:
# Disable the default exclude list so that all excludes are explicitly
# defined in this file.
exclude-use-default: false

linters-settings:
gofmt:
simplify: false
3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ GOTOOLS = \
golang.org/x/tools/cmd/stringer \
github.com/gogo/protobuf/protoc-gen-gofast@$(GOGOVERSION) \
github.com/hashicorp/protoc-gen-go-binary \
github.com/vektra/mockery/cmd/mockery
github.com/vektra/mockery/cmd/mockery \
github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.6

GOTAGS ?=
GOOS?=$(shell go env GOOS)
Expand Down
1 change: 1 addition & 0 deletions api/.golangci.yml
1 change: 1 addition & 0 deletions sdk/.golangci.yml