From 569ee94116980ba731c2185e46d585aaa073daf1 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Mon, 7 Feb 2022 23:37:04 +0530 Subject: [PATCH] Pin GolangCI to a specific version (#19505) * Pin GolangCI to a specific version Go 1.16+ allows installing a tool directly from a specific version. Therefore, we don't need to rely on the tool being pre-installed and can directly install it using standard method. This keeps the same version of the tool for a repo and limits the binary placement to the GOBIN of the repo. ```release-note NONE ``` --- .circleci/config.yml | 3 ++- Makefile | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23a410e940..c13f2e64e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -202,10 +202,11 @@ jobs: make gen-serialized if [[ -n $(git status --porcelain) ]]; then echo "Please update the serialized files using 'make gen-serialized'"; exit 1; fi - # Dedicate job for golangci-lint it does not need anything only the server code for that + # Dedicated job for golangci-lint it does not need anything only the server code for that # and to make more clear when the job fails check-golangci-lint: docker: + # Keep the version in sync with the command in Makefile - image: golangci/golangci-lint:v1.39.0 steps: - checkout diff --git a/Makefile b/Makefile index 7eaeaf0c5d..a98cf9496f 100644 --- a/Makefile +++ b/Makefile @@ -243,17 +243,14 @@ else endif golangci-lint: ## Run golangci-lint on codebase -# https://stackoverflow.com/a/677212/1027058 (check if a command exists or not) - @if ! [ -x "$$(command -v golangci-lint)" ]; then \ - echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions."; \ - exit 1; \ - fi; \ + @# Keep the version in sync with the command in .circleci/config.yml + $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0 @echo Running golangci-lint - golangci-lint run ./... + $(GOBIN)/golangci-lint run ./... ifeq ($(BUILD_ENTERPRISE_READY),true) ifneq ($(MM_NO_ENTERPRISE_LINT),true) - golangci-lint run ./enterprise/... + $(GOBIN)/golangci-lint run ./enterprise/... endif endif