diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e094d42a5..f99c9beabb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,8 @@ jobs: 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 # Keep this in sync with .golangci.yml and Jenkinsfile.pr + echo "Installing mattermost-govet" + GO111MODULE=off go get -u github.com/mattermost/mattermost-govet cd mattermost-server make config-reset make check-style BUILD_NUMBER='${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}' diff --git a/Makefile b/Makefile index d9af7106e8..62a4df5c0f 100644 --- a/Makefile +++ b/Makefile @@ -196,13 +196,10 @@ einterfaces-mocks: ## Creates mock files for einterfaces. pluginapi: ## Generates api and hooks glue code for plugins $(GO) generate $(GOFLAGS) ./plugin -check-licenses: ## Checks license status. - ./scripts/license-check.sh $(TE_PACKAGES) $(EE_PACKAGES) - check-prereqs: ## Checks prerequisite software status. ./scripts/prereq-check.sh -check-style: golangci-lint plugin-checker check-licenses ## Runs golangci against all packages +check-style: golangci-lint plugin-checker vet ## Runs golangci against all packages test-te-race: ## Checks for race conditions in the team edition. @echo Testing TE race conditions @@ -451,6 +448,16 @@ update-dependencies: ## Uses go get -u to update all the dependencies while hold # Copy everything to vendor directory $(GO) mod vendor +vet: ## Run mattermost go vet specific checks + @if ! [ -x "$$(command -v mattermost-govet)" ]; then \ + echo "mattermost-govet is not installed. Please install it executing \"GO111MODULE=off go get -u github.com/mattermost/mattermost-govet\""; \ + exit 1; \ + fi; \ + + $(GO) vet -vettool=$(GOPATH)/bin/mattermost-govet -license ./... +ifeq ($(BUILD_ENTERPRISE_READY),true) + $(GO) vet -vettool=$(GOPATH)/bin/mattermost-govet -enterpriseLicense ./enterprise/... +endif todo: ## Display TODO and FIXME items in the source code. @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO diff --git a/build/Jenkinsfile.pr b/build/Jenkinsfile.pr index cf35ccf6e6..2a1647c610 100644 --- a/build/Jenkinsfile.pr +++ b/build/Jenkinsfile.pr @@ -102,6 +102,8 @@ pipeline { 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 # Keep this in sync with .golangci.yml and .circleci/config.yml + echo "Installing mattermost-govet" + GO111MODULE=off go get -u github.com/mattermost/mattermost-govet make config-reset make check-style BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}' make build BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}' diff --git a/build/legacy.mk b/build/legacy.mk index 4ef04dfe96..d8f914db98 100644 --- a/build/legacy.mk +++ b/build/legacy.mk @@ -4,6 +4,9 @@ test-te: test-server # test-ee used to just run the enterprise edition tests, but now runs whatever is available test-ee: test-server +# check-licenses was used to check the license of the files, but now is done through mattermost-govet +check-licenses: vet + # clean old docker images clean-old-docker: @echo Removing docker containers diff --git a/scripts/license-check.sh b/scripts/license-check.sh deleted file mode 100755 index bffd03b49f..0000000000 --- a/scripts/license-check.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -e -IFS=$'\n' -count=0 -for fileType in GoFiles; do - for file in `go list -mod=vendor -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' "$@"`; do - case $file in - */utils/lru.go|*/utils/imgutils/gif.go|*/store/storetest/mocks/*|*/services/*/mocks/*|*/app/plugin/jira/plugin_*|*/plugin/plugintest/*|*/app/plugin/zoom/plugin_*|*/einterfaces/mocks/*) - # Third-party, doesn't require a header. - ;; - *) - if ! grep 'Mattermost, Inc. All Rights Reserved.' $file -q; then - >&2 echo "FAIL: $file is missing a license header." - ((count++)) - fi - esac - done -done -if [ $count -eq 0 ]; then - exit 0 -fi - -if [ $count -gt 1 ]; then - >&2 echo "$count files are missing license headers." -else - >&2 echo "$count file is missing a license header." -fi -exit 1 diff --git a/store/localcachelayer/team_layer.go b/store/localcachelayer/team_layer.go index e41a35989c..a39b040da4 100644 --- a/store/localcachelayer/team_layer.go +++ b/store/localcachelayer/team_layer.go @@ -1,5 +1,5 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. package localcachelayer diff --git a/store/localcachelayer/team_layer_test.go b/store/localcachelayer/team_layer_test.go index 5ccd4ad4c7..25a39d775c 100644 --- a/store/localcachelayer/team_layer_test.go +++ b/store/localcachelayer/team_layer_test.go @@ -1,5 +1,5 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. package localcachelayer