Remove more instances of GOPATH from Makefile and CI (#13450)

Automatic Merge
Этот коммит содержится в:
Agniva De Sarker
2020-01-21 18:19:49 +05:30
коммит произвёл mattermod
родитель f78ba00017
Коммит 5123fe0292
6 изменённых файлов: 84 добавлений и 61 удалений

Просмотреть файл

@@ -5,7 +5,7 @@ orbs:
executors:
ubuntu:
working_directory: ~/go/mattermost/
working_directory: ~/mattermost/
machine:
image: "ubuntu-1604:201903-01"
environment:
@@ -14,7 +14,7 @@ executors:
jobs:
setup:
working_directory: ~/go/mattermost/mattermost-server
working_directory: ~/mattermost/mattermost-server
docker:
- image: mattermost/mattermost-build-webapp:oct-2-2018
resource_class: xlarge
@@ -35,7 +35,7 @@ jobs:
npm ci && cd node_modules/mattermost-redux && npm install && npm run build && cd ../.. && make build
fi
- persist_to_workspace:
root: ~/go/mattermost
root: ~/mattermost
paths:
- mattermost-webapp
- mattermost-server
@@ -45,10 +45,10 @@ jobs:
# check-i18n:
# docker:
# - image: circleci/golang:1.12
# working_directory: ~/go/mattermost/
# working_directory: ~/mattermost/
# steps:
# - attach_workspace:
# at: ~/go/mattermost/
# at: ~/mattermost/
# - run:
# command: |
# cd mattermost-server
@@ -60,29 +60,31 @@ jobs:
docker:
- image: mattermost/mattermost-build-server:oct-18-2019
resource_class: xlarge
working_directory: ~/go/mattermost
working_directory: ~/mattermost
steps:
- attach_workspace:
at: ~/go/mattermost/
at: ~/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.23.0 # Keep this in sync with .golangci.yml and Jenkinsfile.pr
echo "Installing mattermost-govet"
export GOBIN=${PWD}/mattermost-server/bin
GO111MODULE=off go get -u github.com/mattermost/mattermost-govet
export PATH=$PATH:$GOBIN
cd mattermost-server
make config-reset
make check-style BUILD_NUMBER='${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}' MM_NO_ENTERPRISE_LINT=true
make build BUILD_NUMBER='${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}'
make package BUILD_NUMBER='${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}'
- store_artifacts:
path: ~/go/mattermost/mattermost-server/dist/mattermost-team-linux-amd64.tar.gz
path: ~/mattermost/mattermost-server/dist/mattermost-team-linux-amd64.tar.gz
- store_artifacts:
path: ~/go/mattermost/mattermost-server/dist/mattermost-team-osx-amd64.tar.gz
path: ~/mattermost/mattermost-server/dist/mattermost-team-osx-amd64.tar.gz
- store_artifacts:
path: ~/go/mattermost/mattermost-server/dist/mattermost-team-windows-amd64.zip
path: ~/mattermost/mattermost-server/dist/mattermost-team-windows-amd64.zip
- persist_to_workspace:
root: ~/go/mattermost
root: ~/mattermost
paths:
- mattermost-server
- mattermost-webapp
@@ -92,7 +94,7 @@ jobs:
name: ubuntu
steps:
- attach_workspace:
at: ~/go/mattermost
at: ~/mattermost
- run:
name: Run Docker compose
command: |
@@ -128,8 +130,8 @@ jobs:
--env MM_EMAILSETTINGS_SMTPSERVER=inbucket \
--env MM_EMAILSETTINGS_SMTPPORT=10025 \
--env MM_ELASTICSEARCHSETTINGS_CONNECTIONURL=http://elasticsearch:9200 \
-v ~/go/mattermost:/go/mattermost \
-w /go/mattermost/mattermost-server \
-v ~/mattermost:/mattermost \
-w /mattermost/mattermost-server \
mattermost/mattermost-build-server:oct-18-2019 \
bash -c 'ulimit -n 8096; make test-server BUILD_NUMBER="$CIRCLE_BRANCH-$CIRCLE_PREVIOUS_BUILD_NUM" TESTFLAGS= TESTFLAGSEE='
no_output_timeout: 1h
@@ -145,7 +147,7 @@ jobs:
docker stats -a --no-stream > logs/docker_stats
tar -czvf logs/docker_logs.tar.gz logs/docker-compose_logs logs/docker_ps logs/docker_stats
- store_artifacts:
path: ~/go/mattermost/mattermost-server/build/logs
path: ~/mattermost/mattermost-server/build/logs
- run:
when: always
command: |
@@ -153,16 +155,16 @@ jobs:
mkdir -p test-results
cp report.xml test-results
- store_test_results:
path: ~/go/mattermost/mattermost-server/test-results/
path: ~/mattermost/mattermost-server/test-results/
- store_artifacts:
path: ~/go/mattermost/mattermost-server/test-results/
path: ~/mattermost/mattermost-server/test-results/
test-schema:
executor:
name: ubuntu
steps:
- attach_workspace:
at: ~/go/mattermost
at: ~/mattermost
- run:
name: Run Docker compose
command: |
@@ -201,8 +203,8 @@ jobs:
--env MM_SQLSETTINGS_DRIVERNAME=postgres \
--env MM_EMAILSETTINGS_SMTPPORT=10025 \
--env MM_ELASTICSEARCHSETTINGS_CONNECTIONURL=http://elasticsearch:9200 \
-v ~/go/mattermost:/go/mattermost \
-w /go/mattermost/mattermost-server \
-v ~/mattermost:/mattermost \
-w /mattermost/mattermost-server \
mattermost/mattermost-build-server:oct-18-2019 \
bash -c 'ulimit -n 8096; make ARGS="version" run-cli && make MM_SQLSETTINGS_DATASOURCE="postgres://mmuser:mostest@postgres:5432/latest?sslmode=disable&connect_timeout=10" ARGS="version" run-cli'
echo "Generating dump"
@@ -237,8 +239,8 @@ jobs:
--env MM_SQLSETTINGS_DRIVERNAME=mysql \
--env MM_EMAILSETTINGS_SMTPPORT=10025 \
--env MM_ELASTICSEARCHSETTINGS_CONNECTIONURL=http://elasticsearch:9200 \
-v ~/go/mattermost:/go/mattermost \
-w /go/mattermost/mattermost-server \
-v ~/mattermost:/mattermost \
-w /mattermost/mattermost-server \
mattermost/mattermost-build-server:oct-18-2019 \
bash -c 'ulimit -n 8096; make ARGS="version" run-cli && make MM_SQLSETTINGS_DATASOURCE="mmuser:mostest@tcp(mysql:3306)/latest?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s" ARGS="version" run-cli'
@@ -260,32 +262,32 @@ jobs:
upload-s3-sha:
docker:
- image: 'circleci/python:2.7'
working_directory: ~/go/mattermost/enterprise
working_directory: ~/mattermost/enterprise
steps:
- attach_workspace:
at: ~/go/mattermost/
at: ~/mattermost/
- run:
command: |
cd ~/go/mattermost/mattermost-server/dist/
cd ~/mattermost/mattermost-server/dist/
rm -rf mattermost
- aws-s3/copy:
from: ~/go/mattermost/mattermost-server/dist/
from: ~/mattermost/mattermost-server/dist/
to: "s3://pr-builds.mattermost.com/mattermost-server/commit/${CIRCLE_SHA1}/"
arguments: --acl public-read --cache-control "no-cache" --recursive
upload-s3:
docker:
- image: 'circleci/python:2.7'
working_directory: ~/go/mattermost/enterprise
working_directory: ~/mattermost/enterprise
steps:
- attach_workspace:
at: ~/go/mattermost/
at: ~/mattermost/
- run:
command: |
cd ~/go/mattermost/mattermost-server/dist/
cd ~/mattermost/mattermost-server/dist/
rm -rf mattermost
- aws-s3/copy:
from: ~/go/mattermost/mattermost-server/dist/
from: ~/mattermost/mattermost-server/dist/
to: s3://pr-builds.mattermost.com/mattermost-server/$(echo "${CIRCLE_BRANCH}" | sed 's/pull\//PR-/g')/
arguments: --acl public-read --cache-control "no-cache" --recursive

1
.gitignore поставляемый
Просмотреть файл

@@ -3,6 +3,7 @@ logs
.DS_Store
node_modules
/dist
/bin
/webapp/dist
jobserver
npm-debug.log

Просмотреть файл

@@ -45,9 +45,9 @@ else
BUILD_CLIENT = false
endif
# Golang Flags
GOPATH ?= $(shell go env GOPATH)
# Go Flags
GOFLAGS ?= $(GOFLAGS:) -mod=vendor
GOBIN=$(PWD)/bin
GO=go
DELVE=dlv
LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildNumber=$(BUILD_NUMBER)"
@@ -168,32 +168,32 @@ endif
i18n-extract: ## Extract strings for translation from the source code
env GO111MODULE=off $(GO) get -u github.com/mattermost/mattermost-utilities/mmgotool
$(GOPATH)/bin/mmgotool i18n extract
$(GOBIN)/mmgotool i18n extract
store-mocks: ## Creates mock files.
env GO111MODULE=off $(GO) get -u github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.'
$(GOBIN)/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.'
store-layers: ## Generate layers for the store
$(GO) generate $(GOFLAGS) ./store
filesstore-mocks: ## Creates mock files.
env GO111MODULE=off $(GO) get -u github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir services/filesstore -all -output services/filesstore/mocks -note 'Regenerate this file using `make filesstore-mocks`.'
$(GOBIN)/mockery -dir services/filesstore -all -output services/filesstore/mocks -note 'Regenerate this file using `make filesstore-mocks`.'
ldap-mocks: ## Creates mock files for ldap.
env GO111MODULE=off $(GO) get -u github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir enterprise/ldap -all -output enterprise/ldap/mocks -note 'Regenerate this file using `make ldap-mocks`.'
$(GOBIN)/mockery -dir enterprise/ldap -all -output enterprise/ldap/mocks -note 'Regenerate this file using `make ldap-mocks`.'
plugin-mocks: ## Creates mock files for plugins.
env GO111MODULE=off $(GO) get -u github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir plugin -name API -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOPATH)/bin/mockery -dir plugin -name Hooks -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOPATH)/bin/mockery -dir plugin -name Helpers -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOBIN)/mockery -dir plugin -name API -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOBIN)/mockery -dir plugin -name Hooks -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
$(GOBIN)/mockery -dir plugin -name Helpers -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
einterfaces-mocks: ## Creates mock files for einterfaces.
env GO111MODULE=off $(GO) get -u github.com/vektra/mockery/...
$(GOPATH)/bin/mockery -dir einterfaces -all -output einterfaces/mocks -note 'Regenerate this file using `make einterfaces-mocks`.'
$(GOBIN)/mockery -dir einterfaces -all -output einterfaces/mocks -note 'Regenerate this file using `make einterfaces-mocks`.'
pluginapi: ## Generates api and hooks glue code for plugins
$(GO) generate $(GOFLAGS) ./plugin
@@ -259,7 +259,7 @@ ifeq ($(BUILD_ENTERPRISE_READY),true)
else
@echo Running only TE tests
endif
./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)"
./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)"
internal-test-web-client: ## Runs web client tests.
$(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests
@@ -451,15 +451,15 @@ update-dependencies: ## Uses go get -u to update all the dependencies while hold
$(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\""; \
@if ! [ -x "$$(command -v $(GOBIN)/mattermost-govet)" ]; then \
echo "mattermost-govet is not installed. Please install it executing \"GO111MODULE=off GOBIN=$(PWD)/bin go get -u github.com/mattermost/mattermost-govet\""; \
exit 1; \
fi; \
$(GO) vet -vettool=$(GOPATH)/bin/mattermost-govet -license -structuredLogging -inconsistentReceiverName ./...
$(GO) vet -vettool=$(GOBIN)/mattermost-govet -license -structuredLogging -inconsistentReceiverName ./...
ifeq ($(BUILD_ENTERPRISE_READY),true)
ifneq ($(MM_NO_ENTERPRISE_LINT),true)
$(GO) vet -vettool=$(GOPATH)/bin/mattermost-govet -enterpriseLicense -structuredLogging ./enterprise/...
$(GO) vet -vettool=$(GOBIN)/mattermost-govet -enterpriseLicense -structuredLogging ./enterprise/...
endif
endif

Просмотреть файл

@@ -74,6 +74,7 @@ pipeline {
stage('Check i18n') {
environment {
GOPATH = "/go"
GOBIN = "/go/src/github.com/mattermost/mattermost-server/bin"
}
steps {
@@ -93,6 +94,7 @@ pipeline {
stage('Build') {
environment {
GOPATH = "/go"
GOBIN = "/go/src/github.com/mattermost/mattermost-server/bin"
}
steps {
@@ -104,6 +106,7 @@ pipeline {
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/local/bin v1.23.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
export PATH=$PATH:$GOBIN
make config-reset
make check-style BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}' MM_NO_ENTERPRISE_LINT=true
make build BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}'
@@ -237,6 +240,7 @@ pipeline {
stage('Test') {
environment {
GOPATH = "/go"
GOBIN = "/go/src/github.com/mattermost/mattermost-server/bin"
TEST_DATABASE_MYSQL_DSN = "mmuser:mostest@tcp(mysql:3306)/mattermost_test?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"
TEST_DATABASE_POSTGRESQL_DSN = "postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable&connect_timeout=10"
TEST_DATABASE_MYSQL_ROOT_PASSWD = "mostest"

Просмотреть файл

@@ -3,15 +3,30 @@ dist: | check-style test package
build-linux:
@echo Build Linux amd64
env GOOS=linux GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64")
env GOOS=linux GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
else
mkdir -p $(GOBIN)/linux_amd64
env GOOS=linux GOARCH=amd64 $(GO) build -o $(GOBIN)/linux_amd64 $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
endif
build-osx:
@echo Build OSX amd64
env GOOS=darwin GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
env GOOS=darwin GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
else
mkdir -p $(GOBIN)/darwin_amd64
env GOOS=darwin GOARCH=amd64 $(GO) build -o $(GOBIN)/darwin_amd64 $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
endif
build-windows:
@echo Build Windows amd64
env GOOS=windows GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN) $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
else
mkdir -p $(GOBIN)/windows_amd64
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN)/windows_amd64 $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
endif
build: build-linux build-windows build-osx
@@ -75,11 +90,11 @@ endif
@# Make osx package
@# Copy binary
ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
cp $(GOPATH)/bin/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOPATH)/bin/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
else
cp $(GOPATH)/bin/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOPATH)/bin/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
endif
@# Strip and prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
@@ -96,11 +111,11 @@ endif
@# Make windows package
@# Copy binary
ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
cp $(GOPATH)/bin/mattermost.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOPATH)/bin/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/mattermost.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
else
cp $(GOPATH)/bin/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOPATH)/bin/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
endif
@# Strip and prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
@@ -117,11 +132,11 @@ endif
@# Make linux package
@# Copy binary
ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64")
cp $(GOPATH)/bin/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOPATH)/bin/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
else
cp $(GOPATH)/bin/linux_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOPATH)/bin/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/linux_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
endif
@# Strip and prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \

Просмотреть файл

@@ -8,6 +8,7 @@ GOFLAGS=$2
PACKAGES=$3
TESTS=$4
TESTFLAGS=$5
GOBIN=$6
PACKAGES_COMMA=$(echo $PACKAGES | tr ' ' ',')
@@ -18,7 +19,7 @@ find . -type d -name data -not -path './vendor/*' | xargs rm -rf
$GO test $GOFLAGS -run=$TESTS $TESTFLAGS -v -timeout=2000s -covermode=count -coverpkg=$PACKAGES_COMMA -exec $DIR/test-xprog.sh $PACKAGES 2>&1 > >( tee output )
EXIT_STATUS=$?
cat output | $GOPATH/bin/go-junit-report > report.xml
cat output | $GOBIN/go-junit-report > report.xml
rm output
find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 "{}" >> cover.out ; rm "{}"' \;
rm -f config/*.crt