From dc441ca9261c9fd5cfa899c380c65ef4707a8383 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 16 Jun 2021 11:32:03 +0200 Subject: [PATCH 1/3] add linters Signed-off-by: Mark Sagi-Kazar --- .gitignore | 1 + Makefile | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Makefile 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 From 23f780f23f986b81736603c065afd4e92e7528a2 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 16 Jun 2021 11:32:43 +0200 Subject: [PATCH 2/3] add lint step to build Signed-off-by: Mark Sagi-Kazar --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) 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: From e48ff39a35667a427bc812008e41b22a20943bd7 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 16 Jun 2021 11:36:32 +0200 Subject: [PATCH 3/3] drop old lint script Signed-off-by: Mark Sagi-Kazar --- lint | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100755 lint 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 \ - ./...