From 41230b176de80663c71c23327e51a87b82a1b5ff Mon Sep 17 00:00:00 2001 From: Kim Bao Long Date: Thu, 27 Feb 2020 17:26:06 +0700 Subject: [PATCH] Install golangci-lint if needed Currently, `golangci-lint` is using in `make test-style` step, but there is no installation step for this tool. It will raise an error in the case of `golangci-lint` is not installed in the local env. This PR aim to install it if needed. Signed-off-by: Kim Bao Long --- .circleci/config.yml | 2 +- Makefile | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef19b8ee7..5f646ceff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: - checkout - run: name: install test dependencies - command: .circleci/bootstrap.sh + command: make lint - run: name: test style command: make test-style diff --git a/Makefile b/Makefile index 27404bca8..2174888ed 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ GOX = $(GOPATH)/bin/gox GOIMPORTS = $(GOPATH)/bin/goimports ARCH = $(shell uname -p) +GOLANGCI_LINT_VERSION = "1.21.0" + ACCEPTANCE_DIR:=../acceptance-testing # To specify the subset of acceptance tests to run. '.' means all tests ACCEPTANCE_RUN_TESTS=. @@ -89,10 +91,19 @@ test-coverage: @ ./scripts/coverage.sh .PHONY: test-style -test-style: +test-style: lint GO111MODULE=on golangci-lint run @scripts/validate-license.sh +.PHONY: lint +lint: + set -euo pipefail + cd / + GO111MODULE=on + curl -sSL https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz | tar xz + sudo mv golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /usr/local/bin/golangci-lint + rm -rf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64 + .PHONY: test-acceptance test-acceptance: TARGETS = linux/amd64 test-acceptance: build build-cross