diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77a35da73..8ea152deb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,9 @@ jobs: EUREKA_ADDR: http://localhost:${{ job.services.eureka.ports[8761] }}/eureka run: go test -v -race -coverprofile=coverage.coverprofile -covermode=atomic -tags integration ./... + - name: Run linters + run: make -k lint + - name: Upload coverage uses: codecov/codecov-action@v1 with: diff --git a/.gitignore b/.gitignore index 6062401c1..ebc509d62 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ Session.vim # auto-generated tag files tags +/bin/ diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..ac3303cae --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +OS = $(shell uname | tr A-Z a-z) + +REVIVE_VERSION = 1.0.7 +STATICCHECK_VERSION = 2021.1 + +bin/revive: bin/revive-${REVIVE_VERSION} + @ln -sf revive-${REVIVE_VERSION} bin/revive +bin/revive-${REVIVE_VERSION}: + @mkdir -p bin + curl -L https://github.com/mgechev/revive/releases/download/v${REVIVE_VERSION}/revive_${REVIVE_VERSION}_$(shell uname)_x86_64.tar.gz | tar -zOxf - revive > ./bin/revive-${REVIVE_VERSION} && chmod +x ./bin/revive-${REVIVE_VERSION} + +bin/staticcheck: bin/staticcheck-${STATICCHECK_VERSION} + @ln -sf staticcheck-${STATICCHECK_VERSION} bin/staticcheck +bin/staticcheck-${STATICCHECK_VERSION}: + @mkdir -p bin + curl -L https://github.com/dominikh/go-tools/releases/download/${STATICCHECK_VERSION}/staticcheck_${OS}_amd64.tar.gz | tar -zOxf - staticcheck > ./bin/staticcheck-${STATICCHECK_VERSION} && chmod +x ./bin/staticcheck-${STATICCHECK_VERSION} + +.PHONY: lint +lint: bin/revive bin/staticcheck + go vet ./... + bin/revive ./... + bin/staticcheck ./... + gofmt -l -s -e . | grep .go && exit 1 diff --git a/lint b/lint deleted file mode 100755 index 12e307273..000000000 --- a/lint +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -if [ ! $(command -v gometalinter) ] -then - go get github.com/alecthomas/gometalinter - gometalinter --update --install -fi - -time gometalinter \ - --exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \ - --exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \ - --exclude='/thrift/' \ - --exclude='/pb/' \ - --exclude='no args in Log call \(vet\)' \ - --disable=dupl \ - --disable=aligncheck \ - --disable=gotype \ - --cyclo-over=20 \ - --tests \ - --concurrency=2 \ - --deadline=300s \ - ./...