2018-03-28 14:54:58 -07: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 setup -mac 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
2015-06-14 23:53:32 -08:00
2017-10-12 08:35:19 -07:00
ROOT := $( dir $( abspath $( lastword $( MAKEFILE_LIST) ) ) )
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
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
2016-05-12 23:56:07 -04:00
GOPATH ?= $( GOPATH:) :./vendor
2016-03-18 12:46:57 -04:00
GOFLAGS ?= $( GOFLAGS:)
2016-05-12 23:56:07 -04:00
GO = go
2016-03-18 12:46:57 -04:00
GO_LINKER_FLAGS ?= -ldflags \
2017-09-07 14:58:12 -07:00
" -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) "
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-03-07 20:04:18 +00:00
PLATFORM_FILES = "./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
2017-11-14 13:13:31 -06:00
TE_PACKAGES = $( shell go list ./...)
2017-03-16 17:00:00 -04:00
TE_PACKAGES_COMMA = $( shell echo $( TE_PACKAGES) | tr ' ' ',' )
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)
e n d i f
2017-11-14 13:13:31 -06:00
EE_PACKAGES = $( shell go list ./enterprise/...)
EE_PACKAGES_COMMA = $( shell echo $( EE_PACKAGES) | tr ' ' ',' )
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
ALL_PACKAGES_COMMA = $( TE_PACKAGES_COMMA) ,$( EE_PACKAGES_COMMA)
e l s e
ALL_PACKAGES_COMMA = $( TE_PACKAGES_COMMA)
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.
2015-11-22 20:39:03 -05:00
@echo Starting docker containers
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 0 ] ; then \
echo starting mattermost-mysql; \
docker run --name mattermost-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD = mostest \
-e MYSQL_USER = mmuser -e MYSQL_PASSWORD = mostest -e MYSQL_DATABASE = mattermost_test -d mysql:5.7 > /dev/null; \
elif [ $( shell docker ps | grep -ci mattermost-mysql) -eq 0 ] ; then \
echo restarting mattermost-mysql; \
docker start mattermost-mysql > /dev/null; \
2015-09-17 16:27:25 -04:00
fi
2015-11-22 20:39:03 -05:00
@if [ $( shell docker ps -a | grep -ci mattermost-postgres) -eq 0 ] ; then \
echo starting mattermost-postgres; \
2017-11-30 16:41:03 -05:00
docker run --name mattermost-postgres -p 5432:5432 -e POSTGRES_USER = mmuser -e POSTGRES_PASSWORD = mostest -e POSTGRES_DB = mattermost_test \
2015-11-22 20:39:03 -05:00
-d postgres:9.4 > /dev/null; \
elif [ $( shell docker ps | grep -ci mattermost-postgres) -eq 0 ] ; then \
echo restarting mattermost-postgres; \
docker start mattermost-postgres > /dev/null; \
2016-04-21 22:37:01 -07:00
fi
2017-01-17 15:01:41 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-inbucket) -eq 0 ] ; then \
echo starting mattermost-inbucket; \
2018-03-12 12:39:06 +01:00
docker run --name mattermost-inbucket -p 9000:10080 -p 2500:10025 -d jhillyerd/inbucket:release-1.2.0 > /dev/null; \
2017-01-17 15:01:41 +01:00
elif [ $( shell docker ps | grep -ci mattermost-inbucket) -eq 0 ] ; then \
echo restarting mattermost-inbucket; \
docker start mattermost-inbucket > /dev/null; \
fi
2017-09-22 19:38:46 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-minio) -eq 0 ] ; then \
echo starting mattermost-minio; \
docker run --name mattermost-minio -p 9001:9000 -e "MINIO_ACCESS_KEY=minioaccesskey" \
-e "MINIO_SECRET_KEY=miniosecretkey" -d minio/minio:latest server /data > /dev/null; \
2017-09-25 13:27:11 +01:00
docker exec -it mattermost-minio /bin/sh -c "mkdir -p /data/mattermost-test" > /dev/null; \
2017-09-22 19:38:46 +01:00
elif [ $( shell docker ps | grep -ci mattermost-minio) -eq 0 ] ; then \
echo restarting mattermost-minio; \
docker start mattermost-minio > /dev/null; \
fi
2016-10-13 15:04:46 -03:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2016-04-21 22:37:01 -07:00
@echo Ldap test user test.one
@if [ $( shell docker ps -a | grep -ci mattermost-openldap) -eq 0 ] ; then \
echo starting mattermost-openldap; \
docker run --name mattermost-openldap -p 389:389 -p 636:636 \
-e LDAP_TLS_VERIFY_CLIENT = "never" \
-e LDAP_ORGANISATION = "Mattermost Test" \
-e LDAP_DOMAIN = "mm.test.com" \
-e LDAP_ADMIN_PASSWORD = "mostest" \
2016-09-08 16:38:48 -04:00
-d osixia/openldap:1.1.6 > /dev/null; \
2016-04-21 22:37:01 -07:00
sleep 10; \
docker exec -ti mattermost-openldap bash -c 'echo -e "dn: ou=testusers,dc=mm,dc=test,dc=com\nobjectclass: organizationalunit" | ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest' ; \
docker exec -ti mattermost-openldap bash -c 'echo -e "dn: uid=test.one,ou=testusers,dc=mm,dc=test,dc=com\nobjectclass: iNetOrgPerson\nsn: User\ncn: Test1\nmail: success+testone@simulator.amazonses.com" | ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest' ; \
docker exec -ti mattermost-openldap bash -c 'ldappasswd -s Password1 -D "cn=admin,dc=mm,dc=test,dc=com" -x "uid=test.one,ou=testusers,dc=mm,dc=test,dc=com" -w mostest' ; \
docker exec -ti mattermost-openldap bash -c 'echo -e "dn: uid=test.two,ou=testusers,dc=mm,dc=test,dc=com\nobjectclass: iNetOrgPerson\nsn: User\ncn: Test2\nmail: success+testtwo@simulator.amazonses.com" | ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest' ; \
docker exec -ti mattermost-openldap bash -c 'ldappasswd -s Password1 -D "cn=admin,dc=mm,dc=test,dc=com" -x "uid=test.two,ou=testusers,dc=mm,dc=test,dc=com" -w mostest' ; \
docker exec -ti mattermost-openldap bash -c 'echo -e "dn: cn=tgroup,ou=testusers,dc=mm,dc=test,dc=com\nobjectclass: groupOfUniqueNames\nuniqueMember: uid=test.one,ou=testusers,dc=mm,dc=test,dc=com" | ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest' ; \
elif [ $( shell docker ps | grep -ci mattermost-openldap) -eq 0 ] ; then \
echo restarting mattermost-openldap; \
docker start mattermost-openldap > /dev/null; \
2015-11-23 14:23:49 -05:00
sleep 10; \
2015-11-22 20:39:03 -05:00
fi
2017-07-07 15:36:17 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 0 ] ; then \
echo starting mattermost-elasticsearch; \
docker run --name mattermost-elasticsearch -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "ES_JAVA_OPTS=-Xms250m -Xmx250m" -d grundleborg/elasticsearch:latest > /dev/null; \
elif [ $( shell docker ps | grep -ci mattermost-elasticsearch) -eq 0 ] ; then \
echo restarting mattermost-elasticsearch; \
docker start mattermost-elasticsearch> /dev/null; \
fi
2017-07-31 08:15:23 -07:00
@if [ $( shell docker ps -a | grep -ci mattermost-redis) -eq 0 ] ; then \
echo starting mattermost-redis; \
docker run --name mattermost-redis -p 6379:6379 -d redis > /dev/null; \
elif [ $( shell docker ps | grep -ci mattermost-redis) -eq 0 ] ; then \
echo restarting mattermost-redis; \
docker start mattermost-redis > /dev/null; \
fi
2016-10-13 15:04:46 -03: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.
2015-11-22 20:39:03 -05:00
@echo Stopping docker containers
2015-06-14 23:53:32 -08:00
2015-11-22 20:39:03 -05:00
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ] ; then \
echo stopping mattermost-mysql; \
docker stop mattermost-mysql > /dev/null; \
fi
2015-06-14 23:53:32 -08:00
2015-11-22 20:39:03 -05:00
@if [ $( shell docker ps -a | grep -ci mattermost-postgres) -eq 1 ] ; then \
echo stopping mattermost-postgres; \
docker stop mattermost-postgres > /dev/null; \
fi
2016-10-17 09:52:47 -04:00
2016-04-21 22:37:01 -07:00
@if [ $( shell docker ps -a | grep -ci mattermost-openldap) -eq 1 ] ; then \
echo stopping mattermost-openldap; \
docker stop mattermost-openldap > /dev/null; \
fi
2015-06-14 23:53:32 -08:00
2017-01-17 15:01:41 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-inbucket) -eq 1 ] ; then \
echo stopping mattermost-inbucket; \
docker stop mattermost-inbucket > /dev/null; \
fi
2017-09-22 19:38:46 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-minio) -eq 1 ] ; then \
echo stopping mattermost-minio; \
docker stop mattermost-minio > /dev/null; \
fi
2017-07-07 15:36:17 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 1 ] ; then \
echo stopping mattermost-elasticsearch; \
docker stop mattermost-elasticsearch > /dev/null; \
fi
2017-12-20 14:49:45 -05:00
clean-docker : ## Deletes the docker containers for local development.
2015-11-22 20:39:03 -05:00
@echo Removing docker containers
2015-06-14 23:53:32 -08:00
@if [ $( shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ] ; then \
2016-04-21 22:37:01 -07:00
echo removing mattermost-mysql; \
2015-06-14 23:53:32 -08:00
docker stop mattermost-mysql > /dev/null; \
docker rm -v mattermost-mysql > /dev/null; \
fi
2015-11-22 20:39:03 -05:00
@if [ $( shell docker ps -a | grep -ci mattermost-postgres) -eq 1 ] ; then \
2016-04-21 22:37:01 -07:00
echo removing mattermost-postgres; \
2015-11-22 20:39:03 -05:00
docker stop mattermost-postgres > /dev/null; \
docker rm -v mattermost-postgres > /dev/null; \
fi
2016-04-21 22:37:01 -07:00
@if [ $( shell docker ps -a | grep -ci mattermost-openldap) -eq 1 ] ; then \
echo removing mattermost-openldap; \
docker stop mattermost-openldap > /dev/null; \
docker rm -v mattermost-openldap > /dev/null; \
fi
2017-01-17 15:01:41 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-inbucket) -eq 1 ] ; then \
echo removing mattermost-inbucket; \
docker stop mattermost-inbucket > /dev/null; \
docker rm -v mattermost-inbucket > /dev/null; \
fi
2017-09-22 19:38:46 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-minio) -eq 1 ] ; then \
echo removing mattermost-minio; \
docker stop mattermost-minio > /dev/null; \
docker rm -v mattermost-minio > /dev/null; \
fi
2017-07-07 15:36:17 +01:00
@if [ $( shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 1 ] ; then \
echo removing mattermost-elasticsearch; \
docker stop mattermost-elasticsearch > /dev/null; \
docker rm -v mattermost-elasticsearch > /dev/null; \
fi
2017-12-20 14:49:45 -05:00
govet : ## Runs govet against all packages.
2017-08-10 09:11:55 -07:00
@echo Running GOVET
$( GO) vet $( GOFLAGS) $( TE_PACKAGES) || exit 1
2016-05-13 16:17:07 -04:00
2017-08-10 09:11:55 -07:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
$( GO) vet $( GOFLAGS) $( EE_PACKAGES) || exit 1
e n d i f
2016-10-17 09:52:47 -04:00
2017-12-20 14:49:45 -05:00
gofmt : ## Runs gofmt against all packages.
2016-03-18 12:46:57 -04:00
@echo Running GOFMT
2017-08-09 15:35:49 -05:00
@for package in $( TE_PACKAGES) $( EE_PACKAGES) ; do \
echo "Checking " $$ package; \
files = $$ ( go list -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" ; \
2015-11-22 20:39:03 -05:00
2017-12-20 14:49:45 -05:00
store-mocks : ## Creates mock files.
2017-10-26 11:36:54 -05:00
go get github.com/vektra/mockery/...
2017-10-30 16:37:50 -04:00
GOPATH = $( shell go env GOPATH) $( shell go env 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
2017-12-20 14:49:45 -05:00
update-jira-plugin : ## Updates Jira plugin.
2018-02-08 18:43:27 -06:00
go get github.com/mattermost/go-bindata/...
2017-11-30 14:55:44 -06:00
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-jira/releases/latest | grep browser_download_url | grep darwin-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg jira -o app/plugin/jira/plugin_darwin_amd64.go plugin.tar.gz
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-jira/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg jira -o app/plugin/jira/plugin_linux_amd64.go plugin.tar.gz
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-jira/releases/latest | grep browser_download_url | grep windows-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg jira -o app/plugin/jira/plugin_windows_amd64.go plugin.tar.gz
rm plugin.tar.gz
gofmt -s -w ./app/plugin/jira
2017-12-20 14:49:45 -05:00
update-zoom-plugin : ## Updates Zoom plugin.
2018-02-08 18:43:27 -06:00
go get github.com/mattermost/go-bindata/...
2017-12-05 16:35:46 -05:00
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-zoom/releases/latest | grep browser_download_url | grep darwin-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_darwin_amd64.go plugin.tar.gz
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-zoom/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_linux_amd64.go plugin.tar.gz
curl -s https://api.github.com/repos/mattermost/mattermost-plugin-zoom/releases/latest | grep browser_download_url | grep windows-amd64 | cut -d '"' -f 4 | wget -qi - -O plugin.tar.gz
$( shell go env GOPATH) /bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_windows_amd64.go plugin.tar.gz
rm plugin.tar.gz
gofmt -s -w ./app/plugin/zoom
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
2017-12-20 14:49:45 -05:00
check-style : govet gofmt check -licenses ## Runs govet and gofmt against all packages.
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
2017-12-20 14:49:45 -05:00
test-te : do -cover -file ## Runs tests in the team edition.
2017-03-16 17:00:00 -04:00
@echo Testing TE
@echo "Packages to test: " $( TE_PACKAGES)
2017-11-13 13:59:51 -06:00
find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \;
2017-10-16 08:09:43 -07:00
$( GO) test $( GOFLAGS) -run= $( TESTS) $( TESTFLAGS) -v -timeout= 2000s -covermode= count -coverpkg= $( ALL_PACKAGES_COMMA) -exec $( ROOT) /scripts/test-xprog.sh $( TE_PACKAGES)
2017-11-13 13:59:51 -06:00
find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \;
2017-03-16 17:00:00 -04:00
2017-12-20 14:49:45 -05:00
test-ee : do -cover -file ## Runs tests in the enterprise edition.
2017-03-16 17:00:00 -04:00
@echo Testing EE
2016-05-20 09:40:52 -04:00
2016-04-21 22:37:01 -07:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2017-03-16 17:00:00 -04:00
@echo "Packages to test: " $( EE_PACKAGES)
2017-11-13 13:59:51 -06:00
find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \;
2017-10-12 08:35:19 -07:00
$( GO) test $( GOFLAGS) -run= $( TESTS) $( TESTFLAGSEE) -p 1 -v -timeout= 2000s -covermode= count -coverpkg= $( ALL_PACKAGES_COMMA) -exec $( ROOT) /scripts/test-xprog.sh $( EE_PACKAGES)
2017-11-13 13:59:51 -06:00
find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \;
2016-07-13 07:38:58 -04:00
rm -f config/*.crt
rm -f config/*.key
2016-04-21 22:37:01 -07:00
e n d i f
2017-12-20 14:49:45 -05:00
test-server : test -te test -ee ## Runs tests.
2018-04-03 12:41:02 -07:00
find . -type d -name data -not -path './vendor/*' | xargs rm -rf
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.
$( GO) run $( GOFLAGS) $( GO_LINKER_FLAGS) $( PLATFORM_FILES) sampledata -w 1
@echo You may need to restart the Mattermost server before using the following
2018-03-23 20:32:10 +01:00
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@echo Login with a system admin account username = sysadmin password = sysadmin
@echo Login with a regular account username = user-1 password = user-1
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2018-01-31 16:32:18 -08:00
2017-12-20 14:49:45 -05:00
run-server : 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
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( GO_LINKER_FLAGS) $( PLATFORM_FILES) --disableconfigwatch &
2016-03-18 12:46:57 -04:00
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
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( GO_LINKER_FLAGS) $( 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
2017-12-20 14:49:45 -05:00
run-client-fullmap : ## Runs the webapp with source code mapping (slower; better debugging).
2016-03-29 18:32:15 -04:00
@echo Running mattermost client for development with FULL SOURCE MAP
cd $( BUILD_WEBAPP_DIR) && $( MAKE) run-fullmap
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
2017-12-20 14:49:45 -05:00
run-fullmap : run -server run -client -fullmap ## Same as run but with a full sourcemap for client.
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
2016-03-18 12:46:57 -04:00
@for PID in $$ ( ps -ef | grep "[g]o run" | 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
2016-03-18 12:46:57 -04:00
@for PID in $$ ( ps -ef | grep "[g]o-build" | 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
2017-12-20 14:49:45 -05:00
stop : stop -server stop -client ## Stops server and client.
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
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( GO_LINKER_FLAGS) $( 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
@sed -i'' -e 's|"LdapServer": ".*"|"LdapServer": "dockerhost"|g' config/config.json
@sed -i'' -e 's|"BaseDN": ".*"|"BaseDN": "ou=testusers,dc=mm,dc=test,dc=com"|g' config/config.json
@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
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
cp config/default.json config/config.json
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
rm -f api/mattermost.log
2017-09-25 15:02:41 -04:00
rm -f api/mattermost.log.jsonl
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
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
nuke : clean clean -docker ## Clean plus removes persistant 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
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 :
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'