From 3f072159e394290470a49f6706b3d45656053591 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Mon, 18 Nov 2019 16:38:13 +0530 Subject: [PATCH] Remove fmt and vet checks from CI (#13063) * Remove fmt and vet checks from CI - golangci-lint already does the vet and fmt checks. Remove those as it is redundant now. - Also start running golangci-lint as part of the CI pipeline now just as an extra layer of reliability. * Incorporate review comments * Adding golangci install to Jenkinsfile.pr too * dummy commit to test jenkins * Trying after cd to directory * Fix ineffective assign --- .circleci/config.yml | 2 ++ Makefile | 28 +++------------------------- build/Jenkinsfile.pr | 2 ++ model/config_test.go | 1 - 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fc344c5fce..04b56c4bdd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,8 @@ jobs: at: /go/src/github.com/mattermost/ - run: command: | + echo "Installing golangci-lint" + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/local/bin v1.21.0 cd mattermost-server make config-reset make check-style BUILD_NUMBER='${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}' diff --git a/Makefile b/Makefile index 8f83b2b516..6b67448b4c 100644 --- a/Makefile +++ b/Makefile @@ -149,31 +149,10 @@ else endif -govet: ## Runs govet against all packages. - @echo Running GOVET - env GO111MODULE=off $(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow - $(GO) vet $(GOFLAGS) $(ALL_PACKAGES) || exit 1 - $(GO) vet -vettool=$(GOPATH)/bin/shadow $(GOFLAGS) $(ALL_PACKAGES) || exit 1 +plugin-checker: $(GO) run $(GOFLAGS) ./plugin/checker -gofmt: ## Runs gofmt against all packages. - @echo Running GOFMT - - @for package in $(TE_PACKAGES) $(EE_PACKAGES); do \ - echo "Checking "$$package; \ - files=$$($(GO) list $(GOFLAGS) -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ - if [ "$$files" ]; then \ - gofmt_output=$$(gofmt -d -s $$files 2>&1); \ - if [ "$$gofmt_output" ]; then \ - echo "$$gofmt_output"; \ - echo "gofmt failure"; \ - exit 1; \ - fi; \ - fi; \ - done - @echo "gofmt success"; \ - -golangci-lint: ## Run golangci-lint on codebasis +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."; \ @@ -229,8 +208,7 @@ check-licenses: ## Checks license status. check-prereqs: ## Checks prerequisite software status. ./scripts/prereq-check.sh -# TODO: remove govet and gofmt checks once golangci-lint is being enforced. -check-style: govet gofmt check-licenses check-plugin-golint ## Runs govet and gofmt against all packages and also ensures plugin package golint compliant +check-style: golangci-lint plugin-checker check-licenses check-plugin-golint ## Runs golangci against all packages and also ensures plugin package golint compliant check-plugin-golint: # Checks if golint returns any uncompliant code for any file that starts with plugin/helpers @! golint ./plugin/ | grep plugin/helpers diff --git a/build/Jenkinsfile.pr b/build/Jenkinsfile.pr index 8a0fa14567..b18a91cba9 100644 --- a/build/Jenkinsfile.pr +++ b/build/Jenkinsfile.pr @@ -100,6 +100,8 @@ pipeline { ansiColor('xterm') { sh """ cd /go/src/github.com/mattermost/mattermost-server + echo "Installing golangci-lint" + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/local/bin v1.21.0 make config-reset make check-style BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}' make build BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}' diff --git a/model/config_test.go b/model/config_test.go index a63b17a8f2..79624f3591 100644 --- a/model/config_test.go +++ b/model/config_test.go @@ -170,7 +170,6 @@ func TestConfigIsValidFakeAlgorithm(t *testing.T) { require.Equal(t, "model.config.is_valid.saml_canonical_algorithm.app_error", err.Message) *c1.SamlSettings.CanonicalAlgorithm = temp - temp = *c1.SamlSettings.SignatureAlgorithm *c1.SamlSettings.SignatureAlgorithm = "Fake Algorithm" err = c1.SamlSettings.isValid() if err == nil {