2019-08-29 22:44:13 +02:00
.PHONY : build package run stop run -client run -server stop -client stop -server restart restart -server restart -client start -docker clean -dist clean nuke check -style check -client -style check -server -style check -unit -tests test dist prepare -enteprise run -client -tests setup -run -client -tests cleanup -run -client -tests test -client build -linux build -osx build -windows internal -test -web -client vet run -server -for -web -client -tests diff -config
2015-06-14 23:53:32 -08:00
2017-10-12 08:35:19 -07:00
ROOT := $( dir $( abspath $( lastword $( MAKEFILE_LIST) ) ) )
2018-12-10 11:58:09 -05:00
IS_CI ?= false
2019-09-30 20:50:56 +02:00
MM_NO_DOCKER ?= false
2016-03-18 12:46:57 -04:00
# Build Flags
2015-06-14 23:53:32 -08:00
BUILD_NUMBER ?= $( BUILD_NUMBER:)
2015-09-16 17:45:00 -07:00
BUILD_DATE = $( shell date -u)
2015-09-17 13:01:40 -07:00
BUILD_HASH = $( shell git rev-parse HEAD)
2016-03-18 12:46:57 -04:00
# If we don't set the build number it defaults to dev
2015-06-14 23:53:32 -08:00
i f e q ( $( BUILD_NUMBER ) , )
BUILD_NUMBER := dev
e n d i f
2016-03-18 12:46:57 -04:00
BUILD_ENTERPRISE_DIR ?= ../enterprise
BUILD_ENTERPRISE ?= true
BUILD_ENTERPRISE_READY = false
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = team
2016-05-20 10:41:47 -04:00
BUILD_HASH_ENTERPRISE = none
2019-04-02 09:22:50 -04:00
LDAP_DATA ?= test
2016-03-18 12:46:57 -04:00
i f n e q ( $( wildcard $ ( BUILD_ENTERPRISE_DIR ) /.) , )
ifeq ( $( BUILD_ENTERPRISE) ,true)
BUILD_ENTERPRISE_READY = true
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = enterprise
2016-05-20 10:41:47 -04:00
BUILD_HASH_ENTERPRISE = $( shell cd $( BUILD_ENTERPRISE_DIR) && git rev-parse HEAD)
2016-03-18 12:46:57 -04:00
else
BUILD_ENTERPRISE_READY = false
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = team
2016-03-18 12:46:57 -04:00
endif
2015-07-29 23:55:45 -08:00
e l s e
2016-03-18 12:46:57 -04:00
BUILD_ENTERPRISE_READY = false
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = team
2015-07-29 23:55:45 -08:00
e n d i f
2017-09-06 23:05:10 -07:00
BUILD_WEBAPP_DIR ?= ../mattermost-webapp
2017-08-10 09:11:55 -07:00
BUILD_CLIENT = false
BUILD_HASH_CLIENT = independant
i f n e q ( $( wildcard $ ( BUILD_WEBAPP_DIR ) /.) , )
ifeq ( $( BUILD_CLIENT) ,true)
BUILD_CLIENT = true
BUILD_HASH_CLIENT = $( shell cd $( BUILD_WEBAPP_DIR) && git rev-parse HEAD)
else
BUILD_CLIENT = false
endif
e l s e
BUILD_CLIENT = false
e n d i f
2015-07-29 23:55:45 -08:00
2016-03-18 12:46:57 -04:00
# Golang Flags
2018-05-07 16:04:09 +02:00
GOPATH ?= $( shell go env GOPATH)
2019-09-24 13:01:53 -07:00
GOFLAGS ?= $( GOFLAGS:) -mod= vendor
2016-05-12 23:56:07 -04:00
GO = go
2018-08-27 13:56:31 +02:00
DELVE = dlv
2019-03-26 23:19:12 +01:00
LDFLAGS += -X " github.com/mattermost/mattermost-server/model.BuildNumber= $( BUILD_NUMBER) "
LDFLAGS += -X " github.com/mattermost/mattermost-server/model.BuildDate= $( BUILD_DATE) "
LDFLAGS += -X " github.com/mattermost/mattermost-server/model.BuildHash= $( BUILD_HASH) "
LDFLAGS += -X " github.com/mattermost/mattermost-server/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) "
LDFLAGS += -X " github.com/mattermost/mattermost-server/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) "
2019-07-16 16:08:31 +03:00
GO_MAJOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
2019-11-06 12:04:50 -03:00
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 13
2019-07-16 16:08:31 +03:00
GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to at least $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) .$( MINIMUM_SUPPORTED_GO_MINOR_VERSION)
2016-03-18 12:46:57 -04:00
2016-09-21 04:59:11 -07:00
# GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not
BUILDER_GOOS_GOARCH = " $( shell $( GO) env GOOS) _ $( shell $( GO) env GOARCH) "
2018-05-17 22:24:49 -04:00
PLATFORM_FILES = "./cmd/mattermost/main.go"
2017-10-12 12:24:54 -07:00
2016-03-18 12:46:57 -04:00
# Output paths
2015-06-14 23:53:32 -08:00
DIST_ROOT = dist
DIST_PATH = $( DIST_ROOT) /mattermost
2016-03-18 12:46:57 -04:00
# Tests
2015-06-14 23:53:32 -08:00
TESTS = .
2017-05-25 11:01:53 -04:00
TESTFLAGS ?= -short
2017-10-12 08:35:19 -07:00
TESTFLAGSEE ?= -short
2017-05-25 11:01:53 -04:00
2017-03-16 17:00:00 -04:00
# Packages lists
2019-10-17 22:08:21 +05:30
TE_PACKAGES = $( shell $( GO) list ./...)
2017-03-16 17:00:00 -04:00
2018-07-16 17:02:13 +02:00
# Plugins Packages
2019-11-06 13:25:52 -08:00
PLUGIN_PACKAGES = mattermost-plugin-zoom-v1.1.2
2019-10-02 15:34:21 -07:00
PLUGIN_PACKAGES += mattermost-plugin-autolink-v1.1.1
2019-07-19 02:55:40 -04:00
PLUGIN_PACKAGES += mattermost-plugin-nps-v1.0.3
2019-10-02 09:35:01 -07:00
PLUGIN_PACKAGES += mattermost-plugin-custom-attributes-v1.0.2
2019-10-04 07:46:37 -07:00
PLUGIN_PACKAGES += mattermost-plugin-github-v0.11.0
2019-10-02 10:09:22 -07:00
PLUGIN_PACKAGES += mattermost-plugin-welcomebot-v1.1.1
2019-07-19 07:33:58 -07:00
PLUGIN_PACKAGES += mattermost-plugin-aws-SNS-v1.0.2
2019-08-09 13:32:37 -07:00
PLUGIN_PACKAGES += mattermost-plugin-antivirus-v0.1.1
2019-10-14 20:36:56 -07:00
PLUGIN_PACKAGES += mattermost-plugin-jira-v2.2.2
2019-10-11 06:09:38 -07:00
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.0.1
2019-08-15 14:44:12 -04:00
PLUGIN_PACKAGES += mattermost-plugin-jenkins-v1.0.0
2018-07-16 17:02:13 +02:00
2017-08-10 09:11:55 -07:00
# Prepares the enterprise build if exists. The IGNORE stuff is a hack to get the Makefile to execute the commands outside a target
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
IGNORE:= $( shell echo Enterprise build selected, preparing)
2017-09-29 12:46:30 -07:00
IGNORE:= $( shell rm -f imports/imports.go)
2017-08-10 09:11:55 -07:00
IGNORE:= $( shell cp $( BUILD_ENTERPRISE_DIR) /imports/imports.go imports/)
IGNORE:= $( shell rm -f enterprise)
IGNORE:= $( shell ln -s $( BUILD_ENTERPRISE_DIR) enterprise)
2018-12-06 13:19:32 -05:00
e l s e
IGNORE:= $( shell rm -f imports/imports.go)
2017-08-10 09:11:55 -07:00
e n d i f
2019-10-17 22:08:21 +05:30
EE_PACKAGES = $( shell $( GO) list ./enterprise/...)
2017-11-14 13:13:31 -06:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2018-12-06 13:19:32 -05:00
ALL_PACKAGES = $( TE_PACKAGES) $( EE_PACKAGES)
2017-11-14 13:13:31 -06:00
e l s e
2018-12-06 13:19:32 -05:00
ALL_PACKAGES = $( TE_PACKAGES)
2017-11-14 13:13:31 -06:00
e n d i f
2017-08-10 09:11:55 -07:00
2017-12-20 14:49:45 -05:00
all : run ## Alias for 'run'.
2015-11-27 16:36:57 -05:00
2017-08-10 09:11:55 -07:00
i n c l u d e b u i l d / * . m k
2015-11-22 20:39:03 -05:00
2017-12-20 14:49:45 -05:00
start-docker : ## Starts the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f n e q ( $( IS_CI ) , f a l s e )
@echo CI Build: skipping docker start
e l s e i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker start
e l s e
2015-11-22 20:39:03 -05:00
@echo Starting docker containers
2019-08-14 10:33:49 -04:00
docker-compose run --rm start_dependencies
cat tests/${ LDAP_DATA } -data.ldif | docker-compose exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest || true' ;
2018-12-10 11:58:09 -05:00
e n d i f
2016-09-15 09:35:44 -03:00
2017-12-20 14:49:45 -05:00
stop-docker : ## Stops the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker stop
e l s e
2015-11-22 20:39:03 -05:00
@echo Stopping docker containers
2015-06-14 23:53:32 -08:00
2019-08-14 10:33:49 -04:00
docker-compose stop
2019-09-30 20:50:56 +02:00
e n d i f
2018-12-10 11:58:09 -05:00
2017-12-20 14:49:45 -05:00
clean-docker : ## Deletes the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker clean
e l s e
2015-11-22 20:39:03 -05:00
@echo Removing docker containers
2015-06-14 23:53:32 -08:00
2019-08-14 10:33:49 -04:00
docker-compose down -v
docker-compose rm -v
2019-09-30 20:50:56 +02:00
e n d i f
2016-04-21 22:37:01 -07:00
2017-07-07 15:36:17 +01:00
2019-11-18 16:38:13 +05:30
plugin-checker :
2019-10-30 03:34:29 -04:00
$( GO) run $( GOFLAGS) ./plugin/checker
2016-10-17 09:52:47 -04:00
2019-11-18 16:38:13 +05:30
golangci-lint : ## Run golangci-lint on codebase
2019-10-26 12:42:07 +05:30
# https://stackoverflow.com/a/677212/1027058 (check if a command exists or not)
2019-10-31 21:53:40 +01:00
@if ! [ -x " $$ (command -v golangci-lint) " ] ; then \
2019-10-30 12:48:51 +01:00
echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions." ; \
2019-10-26 12:42:07 +05:30
exit 1; \
fi ; \
@echo Running golangci-lint
2019-10-30 12:48:51 +01:00
golangci-lint run
2019-10-26 12:42:07 +05:30
2018-11-29 17:19:26 +01:00
i18n-extract : ## Extract strings for translation from the source code
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/mattermost/mattermost-utilities/mmgotool
2018-11-29 17:19:26 +01:00
$( GOPATH) /bin/mmgotool i18n extract
2017-12-20 14:49:45 -05:00
store-mocks : ## Creates mock files.
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/vektra/mockery/...
2018-05-07 16:04:09 +02:00
$( GOPATH) /bin/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.'
2017-10-26 11:36:54 -05:00
2019-08-01 22:10:58 +02:00
store-layers : ## Generate layers for the store
2019-09-24 13:01:53 -07:00
$( GO) generate $( GOFLAGS) ./store
2019-08-01 22:10:58 +02:00
2018-09-20 19:07:03 +02:00
filesstore-mocks : ## Creates mock files.
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/vektra/mockery/...
2018-09-20 19:07:03 +02:00
$( GOPATH) /bin/mockery -dir services/filesstore -all -output services/filesstore/mocks -note 'Regenerate this file using `make filesstore-mocks`.'
2018-05-10 09:46:09 -07:00
ldap-mocks : ## Creates mock files for ldap.
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/vektra/mockery/...
2018-05-15 13:33:47 -07:00
$( GOPATH) /bin/mockery -dir enterprise/ldap -all -output enterprise/ldap/mocks -note 'Regenerate this file using `make ldap-mocks`.'
plugin-mocks : ## Creates mock files for plugins.
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/vektra/mockery/...
2018-05-15 13:33:47 -07:00
$( 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`.'
2019-05-06 12:44:38 -07:00
$( GOPATH) /bin/mockery -dir plugin -name Helpers -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.'
2018-06-25 12:33:13 -07:00
2019-07-08 11:32:29 -04:00
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`.'
2018-06-25 12:33:13 -07:00
pluginapi : ## Generates api and hooks glue code for plugins
2019-09-24 13:01:53 -07:00
$( GO) generate $( GOFLAGS) ./plugin
2017-12-05 16:35:46 -05:00
2017-12-20 14:49:45 -05:00
check-licenses : ## Checks license status.
2017-10-25 11:33:19 -05:00
./scripts/license-check.sh $( TE_PACKAGES) $( EE_PACKAGES)
2018-01-25 08:40:29 -05:00
check-prereqs : ## Checks prerequisite software status.
./scripts/prereq-check.sh
2018-09-26 20:49:22 +00:00
2019-11-18 16:38:13 +05:30
check-style : golangci -lint plugin -checker check -licenses check -plugin -golint ## Runs golangci against all packages and also ensures plugin package golint compliant
2019-11-11 21:29:21 -08:00
check-plugin-golint : # Checks if golint returns any uncompliant code for any file that starts with plugin/helpers
@! golint ./plugin/ | grep plugin/helpers
2016-05-13 16:17:07 -04:00
2017-12-20 14:49:45 -05:00
test-te-race : ## Checks for race conditions in the team edition.
2017-04-04 11:42:07 -07:00
@echo Testing TE race conditions
@echo "Packages to test: " $( TE_PACKAGES)
@for package in $( TE_PACKAGES) ; do \
echo "Testing " $$ package; \
2017-04-05 18:32:04 -04:00
$( GO) test $( GOFLAGS) -race -run= $( TESTS) -test.timeout= 4000s $$ package || exit 1; \
2017-04-04 11:42:07 -07:00
done
2017-12-20 14:49:45 -05:00
test-ee-race : ## Checks for race conditions in the enterprise edition.
2017-04-04 11:42:07 -07:00
@echo Testing EE race conditions
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
@echo "Packages to test: " $( EE_PACKAGES)
for package in $( EE_PACKAGES) ; do \
echo "Testing " $$ package; \
$( GO) test $( GOFLAGS) -race -run= $( TESTS) -c $$ package; \
if [ -f $$ ( basename $$ package) .test ] ; then \
echo "Testing " $$ package; \
2017-04-05 11:20:44 -04:00
./$$ ( basename $$ package) .test -test.timeout= 2000s || exit 1; \
2017-04-04 11:42:07 -07:00
rm -r $$ ( basename $$ package) .test; \
fi ; \
done
rm -f config/*.crt
rm -f config/*.key
e n d i f
2017-12-20 14:49:45 -05:00
test-server-race : test -te -race test -ee -race ## Checks for race conditions.
2018-04-03 12:41:02 -07:00
find . -type d -name data -not -path './vendor/*' | xargs rm -rf
2017-04-04 11:42:07 -07:00
2017-12-20 14:49:45 -05:00
do-cover-file : ## Creates the test coverage report file.
2017-04-05 08:15:58 -04:00
@echo "mode: count" > cover.out
2018-11-28 09:05:39 -05:00
go-junit-report :
2019-06-20 18:09:05 +02:00
env GO111MODULE = off go get -u github.com/jstemmer/go-junit-report
2018-11-28 09:05:39 -05:00
2019-08-16 02:45:42 -04:00
test-compile : ## Compile tests.
2018-11-28 10:56:21 -08:00
@echo COMPILE TESTS
for package in $( TE_PACKAGES) $( EE_PACKAGES) ; do \
$( GO) test $( GOFLAGS) -c $$ package; \
done
2019-08-16 02:45:42 -04:00
test-db-migration : start -docker ## Gets diff of upgrade vs new instance schemas.
2019-03-20 00:35:15 +05:30
./scripts/mysql-migration-test.sh
./scripts/psql-migration-test.sh
2018-12-06 13:19:32 -05:00
test-server : start -docker go -junit -report do -cover -file ## Runs tests.
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
@echo Running all tests
e l s e
@echo Running only TE tests
e n d i f
./scripts/test.sh " $( GO) " " $( GOFLAGS) " " $( ALL_PACKAGES) " " $( TESTS) " " $( TESTFLAGS) "
2017-03-16 17:00:00 -04:00
2017-12-20 14:49:45 -05:00
internal-test-web-client : ## Runs web client tests.
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( PLATFORM_FILES) test web_client_tests
2016-04-21 22:37:01 -07:00
2017-12-20 14:49:45 -05:00
run-server-for-web-client-tests : ## Tests the server for web client.
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( PLATFORM_FILES) test web_client_tests_server
2017-03-23 18:05:36 +00:00
2017-12-20 14:49:45 -05:00
test-client : ## Test client app.
2016-05-13 16:17:07 -04:00
@echo Running client tests
2016-04-21 22:37:01 -07:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) test
2017-12-20 14:49:45 -05:00
test : test -server test -client ## Runs all checks and tests below (except race detection and postgres).
2015-06-14 23:53:32 -08:00
2017-12-20 14:49:45 -05:00
cover : ## Runs the golang coverage tool. You must run the unit tests first.
2016-05-20 09:40:52 -04:00
@echo Opening coverage info in browser. If this failed run make test first
$( GO) tool cover -html= cover.out
$( GO) tool cover -html= ecover.out
2018-01-31 16:32:18 -08:00
test-data : start -docker ## Add test data to the local instance.
2019-06-25 07:06:44 -05:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) config set TeamSettings.MaxUsersPerTeam 100
2019-07-03 09:16:57 -04:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) sampledata -w 4 -u 60
2018-01-31 16:32:18 -08:00
@echo You may need to restart the Mattermost server before using the following
2018-03-23 20:32:10 +01:00
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2019-08-02 19:42:25 +02:00
@echo Login with a system admin account username = sysadmin password = Sys@dmin-sample1
@echo Login with a regular account username = user-1 password = SampleUs@r-1
2018-03-23 20:32:10 +01:00
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2018-01-31 16:32:18 -08:00
2019-07-16 16:08:31 +03:00
validate-go-version : ## Validates the installed version of go against Mattermost's minimum requirement.
@if [ $( GO_MAJOR_VERSION) -gt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
exit 0 ; \
elif [ $( GO_MAJOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
elif [ $( GO_MINOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
fi
run-server : validate -go -version start -docker ## Starts the server.
2016-03-18 12:46:57 -04:00
@echo Running mattermost for development
mkdir -p $( BUILD_WEBAPP_DIR) /dist/files
2019-10-02 13:23:25 -04:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) --disableconfigwatch 2>& 1 | \
2019-03-26 23:19:12 +01:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) logs --logrus &
2016-03-18 12:46:57 -04:00
2019-08-16 02:45:42 -04:00
debug-server : start -docker ## Compile and start server using delve.
2018-08-27 13:56:31 +02:00
mkdir -p $( BUILD_WEBAPP_DIR) /dist/files
$( DELVE) debug $( PLATFORM_FILES) --build-flags= " -ldflags '\
-X github.com/mattermost/mattermost-server/model.BuildNumber= $( BUILD_NUMBER) \
-X \" github.com/mattermost/mattermost-server/model.BuildDate= $( BUILD_DATE) \" \
-X github.com/mattermost/mattermost-server/model.BuildHash= $( BUILD_HASH) \
-X github.com/mattermost/mattermost-server/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) \
-X github.com/mattermost/mattermost-server/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) ' "
2019-08-16 02:45:42 -04:00
debug-server-headless : start -docker ## Debug server from within an IDE like VSCode or IntelliJ.
2019-07-17 14:36:58 +03:00
mkdir -p $( BUILD_WEBAPP_DIR) /dist/files
$( DELVE) debug --headless --listen= :2345 --api-version= 2 --accept-multiclient $( PLATFORM_FILES) --build-flags= " -ldflags '\
-X github.com/mattermost/mattermost-server/model.BuildNumber= $( BUILD_NUMBER) \
-X \" github.com/mattermost/mattermost-server/model.BuildDate= $( BUILD_DATE) \" \
-X github.com/mattermost/mattermost-server/model.BuildHash= $( BUILD_HASH) \
-X github.com/mattermost/mattermost-server/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) \
-X github.com/mattermost/mattermost-server/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) ' "
2017-12-20 14:49:45 -05:00
run-cli : start -docker ## Runs CLI.
2016-07-06 10:11:21 -08:00
@echo Running mattermost for development
2016-10-19 14:49:25 -04:00
@echo Example should be like 'make ARGS="-version" run-cli'
2016-07-06 10:11:21 -08:00
2019-03-26 23:19:12 +01:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) ${ ARGS }
2016-07-06 10:11:21 -08:00
2017-12-20 14:49:45 -05:00
run-client : ## Runs the webapp.
2016-03-18 12:46:57 -04:00
@echo Running mattermost client for development
2017-11-10 15:25:05 -05:00
ln -nfs $( BUILD_WEBAPP_DIR) /dist client
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) run
2016-03-18 12:46:57 -04:00
2018-12-05 19:13:00 +01:00
run-client-fullmap : ## Legacy alias to run-client
@echo Running mattermost client for development
2016-03-29 18:32:15 -04:00
2018-12-05 19:13:00 +01:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) run
2016-03-29 18:32:15 -04:00
2018-01-25 08:40:29 -05:00
run : check -prereqs run -server run -client ## Runs the server and webapp.
2016-02-17 10:14:29 -05:00
2018-12-05 19:13:00 +01:00
run-fullmap : run -server run -client ## Legacy alias to run
2016-03-29 18:32:15 -04:00
2017-12-20 14:49:45 -05:00
stop-server : ## Stops the server.
2016-03-18 12:46:57 -04:00
@echo Stopping mattermost
2016-10-04 08:56:01 -04:00
i f e q ( $( BUILDER_GOOS_GOARCH ) , "windows_amd64" )
wmic process where "Caption='go.exe' and CommandLine like '%go.exe run%'" call terminate
wmic process where "Caption='mattermost.exe' and CommandLine like '%go-build%'" call terminate
e l s e
2019-09-06 10:08:39 -07:00
@for PID in $$ ( ps -ef | grep "[g]o run" | grep "disableconfigwatch" | awk '{ print $$2 }' ) ; do \
2016-02-17 10:14:29 -05:00
echo stopping go $$ PID; \
2015-06-14 23:53:32 -08:00
kill $$ PID; \
done
2019-09-06 10:08:39 -07:00
@for PID in $$ ( ps -ef | grep "[g]o-build" | grep "disableconfigwatch" | awk '{ print $$2 }' ) ; do \
2016-02-17 10:14:29 -05:00
echo stopping mattermost $$ PID; \
kill $$ PID; \
done
2017-01-12 21:17:29 +05:30
e n d i f
2015-07-27 09:48:35 -04:00
2017-12-20 14:49:45 -05:00
stop-client : ## Stops the webapp.
2016-03-18 12:46:57 -04:00
@echo Stopping mattermost client
2016-03-18 08:48:26 -04:00
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) stop
2015-12-08 13:38:43 -05:00
2019-11-12 08:32:06 +01:00
stop : stop -server stop -client stop -docker ## Stops server, client and the docker compose.
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
restart : restart -server restart -client ## Restarts the server and webapp.
2016-07-05 11:10:28 -04:00
2017-12-20 14:49:45 -05:00
restart-server : | stop -server run -server ## Restarts the mattermost server to pick up development change.
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
restart-client : | stop -client run -client ## Restarts the webapp.
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
run-job-server : ## Runs the background job server.
2017-05-18 15:05:57 -04:00
@echo Running job server for development
2019-03-26 23:19:12 +01:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' $( PLATFORM_FILES) jobserver --disableconfigwatch &
2017-05-18 15:05:57 -04:00
2017-12-20 14:49:45 -05:00
config-ldap : ## Configures LDAP.
2017-11-03 08:45:19 -07:00
@echo Setting up configuration for local LDAP
2019-08-02 10:53:00 -04:00
@sed -i'' -e 's|"LdapServer": ".*"|"LdapServer": "localhost"|g' config/config.json
2019-01-10 15:17:31 -05:00
@sed -i'' -e 's|"BaseDN": ".*"|"BaseDN": "dc=mm,dc=test,dc=com"|g' config/config.json
2017-11-03 08:45:19 -07:00
@sed -i'' -e 's|"BindUsername": ".*"|"BindUsername": "cn=admin,dc=mm,dc=test,dc=com"|g' config/config.json
@sed -i'' -e 's|"BindPassword": ".*"|"BindPassword": "mostest"|g' config/config.json
@sed -i'' -e 's|"FirstNameAttribute": ".*"|"FirstNameAttribute": "cn"|g' config/config.json
@sed -i'' -e 's|"LastNameAttribute": ".*"|"LastNameAttribute": "sn"|g' config/config.json
@sed -i'' -e 's|"NicknameAttribute": ".*"|"NicknameAttribute": "cn"|g' config/config.json
@sed -i'' -e 's|"EmailAttribute": ".*"|"EmailAttribute": "mail"|g' config/config.json
@sed -i'' -e 's|"UsernameAttribute": ".*"|"UsernameAttribute": "uid"|g' config/config.json
@sed -i'' -e 's|"IdAttribute": ".*"|"IdAttribute": "uid"|g' config/config.json
2019-01-10 15:17:31 -05:00
@sed -i'' -e 's|"LoginIdAttribute": ".*"|"LoginIdAttribute": "uid"|g' config/config.json
@sed -i'' -e 's|"GroupDisplayNameAttribute": ".*"|"GroupDisplayNameAttribute": "cn"|g' config/config.json
@sed -i'' -e 's|"GroupIdAttribute": ".*"|"GroupIdAttribute": "entryUUID"|g' config/config.json
2017-11-03 08:45:19 -07:00
2017-12-20 14:49:45 -05:00
config-reset : ## Resets the config/config.json file to the default.
2017-11-03 08:45:19 -07:00
@echo Resetting configuration to default
rm -f config/config.json
2019-09-24 13:01:53 -07:00
OUTPUT_CONFIG = $( PWD) /config/config.json $( GO) generate $( GOFLAGS) ./config
2017-11-03 08:45:19 -07:00
2019-08-29 22:44:13 +02:00
diff-config : ## Compares default configuration between two mattermost versions
@./scripts/diff-config.sh
2017-12-20 14:49:45 -05:00
clean : stop -docker ## Clean up everything except persistant server data.
2016-03-18 12:46:57 -04:00
@echo Cleaning
rm -Rf $( DIST_ROOT)
go clean $( GOFLAGS) -i ./...
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) clean
2015-07-27 09:48:35 -04:00
2018-04-03 12:41:02 -07:00
find . -type d -name data -not -path './vendor/*' | xargs rm -rf
2016-03-18 12:46:57 -04:00
rm -rf logs
rm -f mattermost.log
2017-09-25 15:02:41 -04:00
rm -f mattermost.log.jsonl
2016-05-13 16:17:07 -04:00
rm -f npm-debug.log
2016-03-18 12:46:57 -04:00
rm -f .prepare-go
2016-05-12 23:56:07 -04:00
rm -f enterprise
2016-05-20 09:40:52 -04:00
rm -f cover.out
rm -f ecover.out
rm -f *.out
rm -f *.test
2017-09-29 12:46:30 -07:00
rm -f imports/imports.go
2017-12-05 11:03:19 -05:00
rm -f cmd/platform/cprofile*.out
2018-05-17 22:24:49 -04:00
rm -f cmd/mattermost/cprofile*.out
2016-03-18 12:46:57 -04:00
2019-07-01 06:44:26 -05:00
nuke : clean clean -docker ## Clean plus removes persistent server data.
2016-03-18 12:46:57 -04:00
@echo BOOM
2015-07-27 09:48:35 -04:00
2016-03-18 12:46:57 -04:00
rm -rf data
2015-07-27 09:48:35 -04:00
2017-12-20 14:49:45 -05:00
setup-mac : ## Adds macOS hosts entries for Docker.
2016-03-18 12:46:57 -04:00
echo $$ ( boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
2017-01-02 20:24:03 -05:00
2019-06-03 17:10:08 -04:00
update-dependencies : ## Uses go get -u to update all the dependencies while holding back any that require it.
2019-04-10 07:56:17 -07:00
@echo Updating Dependencies
# Update all dependencies (does not update across major versions)
go get -u
# Tidy up
go mod tidy
# Copy everything to vendor directory
go mod vendor
2017-02-09 13:39:15 -08:00
2017-12-20 14:49:45 -05:00
todo : ## Display TODO and FIXME items in the source code.
2017-09-06 23:05:10 -07:00
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME"
2017-01-02 20:24:03 -05:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2017-09-06 23:05:10 -07:00
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO enterprise/
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX enterprise/
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME enterprise/
@! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME" enterprise/
2017-01-02 20:24:03 -05:00
e n d i f
2017-12-20 14:49:45 -05:00
## Help documentatin à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help :
2019-08-09 10:22:33 -04:00
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'