github.com/qichengzx/mattermost-server@v4.5.1-0.20180604164826-2c75247c97d0+incompatible/Makefile (about) 1 .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 2 3 ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 4 5 # Build Flags 6 BUILD_NUMBER ?= $(BUILD_NUMBER:) 7 BUILD_DATE = $(shell date -u) 8 BUILD_HASH = $(shell git rev-parse HEAD) 9 # If we don't set the build number it defaults to dev 10 ifeq ($(BUILD_NUMBER),) 11 BUILD_NUMBER := dev 12 endif 13 BUILD_ENTERPRISE_DIR ?= ../enterprise 14 BUILD_ENTERPRISE ?= true 15 BUILD_ENTERPRISE_READY = false 16 BUILD_TYPE_NAME = team 17 BUILD_HASH_ENTERPRISE = none 18 ifneq ($(wildcard $(BUILD_ENTERPRISE_DIR)/.),) 19 ifeq ($(BUILD_ENTERPRISE),true) 20 BUILD_ENTERPRISE_READY = true 21 BUILD_TYPE_NAME = enterprise 22 BUILD_HASH_ENTERPRISE = $(shell cd $(BUILD_ENTERPRISE_DIR) && git rev-parse HEAD) 23 else 24 BUILD_ENTERPRISE_READY = false 25 BUILD_TYPE_NAME = team 26 endif 27 else 28 BUILD_ENTERPRISE_READY = false 29 BUILD_TYPE_NAME = team 30 endif 31 BUILD_WEBAPP_DIR ?= ../mattermost-webapp 32 BUILD_CLIENT = false 33 BUILD_HASH_CLIENT = independant 34 ifneq ($(wildcard $(BUILD_WEBAPP_DIR)/.),) 35 ifeq ($(BUILD_CLIENT),true) 36 BUILD_CLIENT = true 37 BUILD_HASH_CLIENT = $(shell cd $(BUILD_WEBAPP_DIR) && git rev-parse HEAD) 38 else 39 BUILD_CLIENT = false 40 endif 41 else 42 BUILD_CLIENT = false 43 endif 44 45 # Golang Flags 46 GOPATH ?= $(shell go env GOPATH) 47 GOFLAGS ?= $(GOFLAGS:) 48 GO=go 49 GO_LINKER_FLAGS ?= -ldflags \ 50 "-X github.com/mattermost/mattermost-server/model.BuildNumber=$(BUILD_NUMBER)\ 51 -X 'github.com/mattermost/mattermost-server/model.BuildDate=$(BUILD_DATE)'\ 52 -X github.com/mattermost/mattermost-server/model.BuildHash=$(BUILD_HASH)\ 53 -X github.com/mattermost/mattermost-server/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)\ 54 -X github.com/mattermost/mattermost-server/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)" 55 56 # GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not 57 BUILDER_GOOS_GOARCH="$(shell $(GO) env GOOS)_$(shell $(GO) env GOARCH)" 58 59 PLATFORM_FILES="./cmd/mattermost/main.go" 60 61 # Output paths 62 DIST_ROOT=dist 63 DIST_PATH=$(DIST_ROOT)/mattermost 64 65 # Tests 66 TESTS=. 67 68 TESTFLAGS ?= -short 69 TESTFLAGSEE ?= -short 70 71 # Packages lists 72 TE_PACKAGES=$(shell go list ./...) 73 TE_PACKAGES_COMMA=$(shell echo $(TE_PACKAGES) | tr ' ' ',') 74 75 # Prepares the enterprise build if exists. The IGNORE stuff is a hack to get the Makefile to execute the commands outside a target 76 ifeq ($(BUILD_ENTERPRISE_READY),true) 77 IGNORE:=$(shell echo Enterprise build selected, preparing) 78 IGNORE:=$(shell rm -f imports/imports.go) 79 IGNORE:=$(shell cp $(BUILD_ENTERPRISE_DIR)/imports/imports.go imports/) 80 IGNORE:=$(shell rm -f enterprise) 81 IGNORE:=$(shell ln -s $(BUILD_ENTERPRISE_DIR) enterprise) 82 endif 83 84 EE_PACKAGES=$(shell go list ./enterprise/...) 85 EE_PACKAGES_COMMA=$(shell echo $(EE_PACKAGES) | tr ' ' ',') 86 87 ifeq ($(BUILD_ENTERPRISE_READY),true) 88 ALL_PACKAGES_COMMA=$(TE_PACKAGES_COMMA),$(EE_PACKAGES_COMMA) 89 else 90 ALL_PACKAGES_COMMA=$(TE_PACKAGES_COMMA) 91 endif 92 93 94 all: run ## Alias for 'run'. 95 96 include build/*.mk 97 98 start-docker: ## Starts the docker containers for local development. 99 @echo Starting docker containers 100 101 @if [ $(shell docker ps -a | grep -ci mattermost-mysql) -eq 0 ]; then \ 102 echo starting mattermost-mysql; \ 103 docker run --name mattermost-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mostest \ 104 -e MYSQL_USER=mmuser -e MYSQL_PASSWORD=mostest -e MYSQL_DATABASE=mattermost_test -d mysql:5.7 > /dev/null; \ 105 elif [ $(shell docker ps | grep -ci mattermost-mysql) -eq 0 ]; then \ 106 echo restarting mattermost-mysql; \ 107 docker start mattermost-mysql > /dev/null; \ 108 fi 109 110 @if [ $(shell docker ps -a | grep -ci mattermost-postgres) -eq 0 ]; then \ 111 echo starting mattermost-postgres; \ 112 docker run --name mattermost-postgres -p 5432:5432 -e POSTGRES_USER=mmuser -e POSTGRES_PASSWORD=mostest -e POSTGRES_DB=mattermost_test \ 113 -d postgres:9.4 > /dev/null; \ 114 elif [ $(shell docker ps | grep -ci mattermost-postgres) -eq 0 ]; then \ 115 echo restarting mattermost-postgres; \ 116 docker start mattermost-postgres > /dev/null; \ 117 fi 118 119 @if [ $(shell docker ps -a | grep -ci mattermost-inbucket) -eq 0 ]; then \ 120 echo starting mattermost-inbucket; \ 121 docker run --name mattermost-inbucket -p 9000:10080 -p 2500:10025 -d jhillyerd/inbucket:release-1.2.0 > /dev/null; \ 122 elif [ $(shell docker ps | grep -ci mattermost-inbucket) -eq 0 ]; then \ 123 echo restarting mattermost-inbucket; \ 124 docker start mattermost-inbucket > /dev/null; \ 125 fi 126 127 @if [ $(shell docker ps -a | grep -ci mattermost-minio) -eq 0 ]; then \ 128 echo starting mattermost-minio; \ 129 docker run --name mattermost-minio -p 9001:9000 -e "MINIO_ACCESS_KEY=minioaccesskey" \ 130 -e "MINIO_SECRET_KEY=miniosecretkey" -d minio/minio:latest server /data > /dev/null; \ 131 docker exec -it mattermost-minio /bin/sh -c "mkdir -p /data/mattermost-test" > /dev/null; \ 132 elif [ $(shell docker ps | grep -ci mattermost-minio) -eq 0 ]; then \ 133 echo restarting mattermost-minio; \ 134 docker start mattermost-minio > /dev/null; \ 135 fi 136 137 ifeq ($(BUILD_ENTERPRISE_READY),true) 138 @echo Ldap test user test.one 139 @if [ $(shell docker ps -a | grep -ci mattermost-openldap) -eq 0 ]; then \ 140 echo starting mattermost-openldap; \ 141 docker run --name mattermost-openldap -p 389:389 -p 636:636 \ 142 -e LDAP_TLS_VERIFY_CLIENT="never" \ 143 -e LDAP_ORGANISATION="Mattermost Test" \ 144 -e LDAP_DOMAIN="mm.test.com" \ 145 -e LDAP_ADMIN_PASSWORD="mostest" \ 146 -d osixia/openldap:1.1.6 > /dev/null;\ 147 sleep 10; \ 148 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';\ 149 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';\ 150 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';\ 151 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';\ 152 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';\ 153 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';\ 154 elif [ $(shell docker ps | grep -ci mattermost-openldap) -eq 0 ]; then \ 155 echo restarting mattermost-openldap; \ 156 docker start mattermost-openldap > /dev/null; \ 157 sleep 10; \ 158 fi 159 160 @if [ $(shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 0 ]; then \ 161 echo starting mattermost-elasticsearch; \ 162 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; \ 163 elif [ $(shell docker ps | grep -ci mattermost-elasticsearch) -eq 0 ]; then \ 164 echo restarting mattermost-elasticsearch; \ 165 docker start mattermost-elasticsearch> /dev/null; \ 166 fi 167 168 @if [ $(shell docker ps -a | grep -ci mattermost-redis) -eq 0 ]; then \ 169 echo starting mattermost-redis; \ 170 docker run --name mattermost-redis -p 6379:6379 -d redis > /dev/null; \ 171 elif [ $(shell docker ps | grep -ci mattermost-redis) -eq 0 ]; then \ 172 echo restarting mattermost-redis; \ 173 docker start mattermost-redis > /dev/null; \ 174 fi 175 endif 176 177 stop-docker: ## Stops the docker containers for local development. 178 @echo Stopping docker containers 179 180 @if [ $(shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ]; then \ 181 echo stopping mattermost-mysql; \ 182 docker stop mattermost-mysql > /dev/null; \ 183 fi 184 185 @if [ $(shell docker ps -a | grep -ci mattermost-postgres) -eq 1 ]; then \ 186 echo stopping mattermost-postgres; \ 187 docker stop mattermost-postgres > /dev/null; \ 188 fi 189 190 @if [ $(shell docker ps -a | grep -ci mattermost-openldap) -eq 1 ]; then \ 191 echo stopping mattermost-openldap; \ 192 docker stop mattermost-openldap > /dev/null; \ 193 fi 194 195 @if [ $(shell docker ps -a | grep -ci mattermost-inbucket) -eq 1 ]; then \ 196 echo stopping mattermost-inbucket; \ 197 docker stop mattermost-inbucket > /dev/null; \ 198 fi 199 200 @if [ $(shell docker ps -a | grep -ci mattermost-minio) -eq 1 ]; then \ 201 echo stopping mattermost-minio; \ 202 docker stop mattermost-minio > /dev/null; \ 203 fi 204 205 @if [ $(shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 1 ]; then \ 206 echo stopping mattermost-elasticsearch; \ 207 docker stop mattermost-elasticsearch > /dev/null; \ 208 fi 209 210 clean-docker: ## Deletes the docker containers for local development. 211 @echo Removing docker containers 212 213 @if [ $(shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ]; then \ 214 echo removing mattermost-mysql; \ 215 docker stop mattermost-mysql > /dev/null; \ 216 docker rm -v mattermost-mysql > /dev/null; \ 217 fi 218 219 @if [ $(shell docker ps -a | grep -ci mattermost-postgres) -eq 1 ]; then \ 220 echo removing mattermost-postgres; \ 221 docker stop mattermost-postgres > /dev/null; \ 222 docker rm -v mattermost-postgres > /dev/null; \ 223 fi 224 225 @if [ $(shell docker ps -a | grep -ci mattermost-openldap) -eq 1 ]; then \ 226 echo removing mattermost-openldap; \ 227 docker stop mattermost-openldap > /dev/null; \ 228 docker rm -v mattermost-openldap > /dev/null; \ 229 fi 230 231 @if [ $(shell docker ps -a | grep -ci mattermost-inbucket) -eq 1 ]; then \ 232 echo removing mattermost-inbucket; \ 233 docker stop mattermost-inbucket > /dev/null; \ 234 docker rm -v mattermost-inbucket > /dev/null; \ 235 fi 236 237 @if [ $(shell docker ps -a | grep -ci mattermost-minio) -eq 1 ]; then \ 238 echo removing mattermost-minio; \ 239 docker stop mattermost-minio > /dev/null; \ 240 docker rm -v mattermost-minio > /dev/null; \ 241 fi 242 243 @if [ $(shell docker ps -a | grep -ci mattermost-elasticsearch) -eq 1 ]; then \ 244 echo removing mattermost-elasticsearch; \ 245 docker stop mattermost-elasticsearch > /dev/null; \ 246 docker rm -v mattermost-elasticsearch > /dev/null; \ 247 fi 248 249 govet: ## Runs govet against all packages. 250 @echo Running GOVET 251 $(GO) vet $(GOFLAGS) $(TE_PACKAGES) || exit 1 252 253 ifeq ($(BUILD_ENTERPRISE_READY),true) 254 $(GO) vet $(GOFLAGS) $(EE_PACKAGES) || exit 1 255 endif 256 257 gofmt: ## Runs gofmt against all packages. 258 @echo Running GOFMT 259 260 @for package in $(TE_PACKAGES) $(EE_PACKAGES); do \ 261 echo "Checking "$$package; \ 262 files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ 263 if [ "$$files" ]; then \ 264 gofmt_output=$$(gofmt -d -s $$files 2>&1); \ 265 if [ "$$gofmt_output" ]; then \ 266 echo "$$gofmt_output"; \ 267 echo "gofmt failure"; \ 268 exit 1; \ 269 fi; \ 270 fi; \ 271 done 272 @echo "gofmt success"; \ 273 274 store-mocks: ## Creates mock files. 275 go get github.com/vektra/mockery/... 276 $(GOPATH)/bin/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.' 277 278 ldap-mocks: ## Creates mock files for ldap. 279 go get github.com/vektra/mockery/... 280 $(GOPATH)/bin/mockery -dir enterprise/ldap -all -output enterprise/ldap/mocks -note 'Regenerate this file using `make ldap-mocks`.' 281 282 plugin-mocks: ## Creates mock files for plugins. 283 go get github.com/vektra/mockery/... 284 $(GOPATH)/bin/mockery -dir plugin -name API -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 285 $(GOPATH)/bin/mockery -dir plugin -name KeyValueStore -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 286 $(GOPATH)/bin/mockery -dir plugin -name Hooks -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 287 @sed -i'' -e 's|API|APIMOCKINTERNAL|g' plugin/plugintest/api.go 288 289 update-jira-plugin: ## Updates Jira plugin. 290 go get github.com/mattermost/go-bindata/... 291 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 292 $(shell go env GOPATH)/bin/go-bindata -pkg jira -o app/plugin/jira/plugin_darwin_amd64.go plugin.tar.gz 293 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 294 $(shell go env GOPATH)/bin/go-bindata -pkg jira -o app/plugin/jira/plugin_linux_amd64.go plugin.tar.gz 295 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 296 $(shell go env GOPATH)/bin/go-bindata -pkg jira -o app/plugin/jira/plugin_windows_amd64.go plugin.tar.gz 297 rm plugin.tar.gz 298 gofmt -s -w ./app/plugin/jira 299 300 update-zoom-plugin: ## Updates Zoom plugin. 301 go get github.com/mattermost/go-bindata/... 302 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 303 $(shell go env GOPATH)/bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_darwin_amd64.go plugin.tar.gz 304 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 305 $(shell go env GOPATH)/bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_linux_amd64.go plugin.tar.gz 306 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 307 $(shell go env GOPATH)/bin/go-bindata -pkg zoom -o app/plugin/zoom/plugin_windows_amd64.go plugin.tar.gz 308 rm plugin.tar.gz 309 gofmt -s -w ./app/plugin/zoom 310 311 check-licenses: ## Checks license status. 312 ./scripts/license-check.sh $(TE_PACKAGES) $(EE_PACKAGES) 313 314 check-prereqs: ## Checks prerequisite software status. 315 ./scripts/prereq-check.sh 316 317 check-style: govet gofmt check-licenses ## Runs govet and gofmt against all packages. 318 319 test-te-race: ## Checks for race conditions in the team edition. 320 @echo Testing TE race conditions 321 322 @echo "Packages to test: "$(TE_PACKAGES) 323 324 @for package in $(TE_PACKAGES); do \ 325 echo "Testing "$$package; \ 326 $(GO) test $(GOFLAGS) -race -run=$(TESTS) -test.timeout=4000s $$package || exit 1; \ 327 done 328 329 test-ee-race: ## Checks for race conditions in the enterprise edition. 330 @echo Testing EE race conditions 331 332 ifeq ($(BUILD_ENTERPRISE_READY),true) 333 @echo "Packages to test: "$(EE_PACKAGES) 334 335 for package in $(EE_PACKAGES); do \ 336 echo "Testing "$$package; \ 337 $(GO) test $(GOFLAGS) -race -run=$(TESTS) -c $$package; \ 338 if [ -f $$(basename $$package).test ]; then \ 339 echo "Testing "$$package; \ 340 ./$$(basename $$package).test -test.timeout=2000s || exit 1; \ 341 rm -r $$(basename $$package).test; \ 342 fi; \ 343 done 344 345 rm -f config/*.crt 346 rm -f config/*.key 347 endif 348 349 test-server-race: test-te-race test-ee-race ## Checks for race conditions. 350 find . -type d -name data -not -path './vendor/*' | xargs rm -rf 351 352 do-cover-file: ## Creates the test coverage report file. 353 @echo "mode: count" > cover.out 354 355 test-te: do-cover-file ## Runs tests in the team edition. 356 @echo Testing TE 357 @echo "Packages to test: "$(TE_PACKAGES) 358 find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \; 359 $(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGS) -v -timeout=2000s -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -exec $(ROOT)/scripts/test-xprog.sh $(TE_PACKAGES) 360 find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \; 361 362 test-ee: do-cover-file ## Runs tests in the enterprise edition. 363 @echo Testing EE 364 365 ifeq ($(BUILD_ENTERPRISE_READY),true) 366 @echo "Packages to test: "$(EE_PACKAGES) 367 find . -name 'cprofile*.out' -exec sh -c 'rm "{}"' \; 368 $(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) 369 find . -name 'cprofile*.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \; 370 rm -f config/*.crt 371 rm -f config/*.key 372 endif 373 374 test-server: test-te test-ee ## Runs tests. 375 find . -type d -name data -not -path './vendor/*' | xargs rm -rf 376 377 internal-test-web-client: ## Runs web client tests. 378 $(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests 379 380 run-server-for-web-client-tests: ## Tests the server for web client. 381 $(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests_server 382 383 test-client: ## Test client app. 384 @echo Running client tests 385 386 cd $(BUILD_WEBAPP_DIR) && $(MAKE) test 387 388 test: test-server test-client ## Runs all checks and tests below (except race detection and postgres). 389 390 cover: ## Runs the golang coverage tool. You must run the unit tests first. 391 @echo Opening coverage info in browser. If this failed run make test first 392 393 $(GO) tool cover -html=cover.out 394 $(GO) tool cover -html=ecover.out 395 396 test-data: start-docker ## Add test data to the local instance. 397 $(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) $(PLATFORM_FILES) sampledata -w 1 398 399 @echo You may need to restart the Mattermost server before using the following 400 @echo ======================================================================== 401 @echo Login with a system admin account username=sysadmin password=sysadmin 402 @echo Login with a regular account username=user-1 password=user-1 403 @echo ======================================================================== 404 405 run-server: start-docker ## Starts the server. 406 @echo Running mattermost for development 407 408 mkdir -p $(BUILD_WEBAPP_DIR)/dist/files 409 $(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) $(PLATFORM_FILES) --disableconfigwatch & 410 411 run-cli: start-docker ## Runs CLI. 412 @echo Running mattermost for development 413 @echo Example should be like 'make ARGS="-version" run-cli' 414 415 $(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) $(PLATFORM_FILES) ${ARGS} 416 417 run-client: ## Runs the webapp. 418 @echo Running mattermost client for development 419 420 ln -nfs $(BUILD_WEBAPP_DIR)/dist client 421 cd $(BUILD_WEBAPP_DIR) && $(MAKE) run 422 423 run-client-fullmap: ## Runs the webapp with source code mapping (slower; better debugging). 424 @echo Running mattermost client for development with FULL SOURCE MAP 425 426 cd $(BUILD_WEBAPP_DIR) && $(MAKE) run-fullmap 427 428 run: check-prereqs run-server run-client ## Runs the server and webapp. 429 430 run-fullmap: run-server run-client-fullmap ## Same as run but with a full sourcemap for client. 431 432 stop-server: ## Stops the server. 433 @echo Stopping mattermost 434 435 ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64") 436 wmic process where "Caption='go.exe' and CommandLine like '%go.exe run%'" call terminate 437 wmic process where "Caption='mattermost.exe' and CommandLine like '%go-build%'" call terminate 438 else 439 @for PID in $$(ps -ef | grep "[g]o run" | awk '{ print $$2 }'); do \ 440 echo stopping go $$PID; \ 441 kill $$PID; \ 442 done 443 @for PID in $$(ps -ef | grep "[g]o-build" | awk '{ print $$2 }'); do \ 444 echo stopping mattermost $$PID; \ 445 kill $$PID; \ 446 done 447 endif 448 449 stop-client: ## Stops the webapp. 450 @echo Stopping mattermost client 451 452 cd $(BUILD_WEBAPP_DIR) && $(MAKE) stop 453 454 stop: stop-server stop-client ## Stops server and client. 455 456 restart: restart-server restart-client ## Restarts the server and webapp. 457 458 restart-server: | stop-server run-server ## Restarts the mattermost server to pick up development change. 459 460 restart-client: | stop-client run-client ## Restarts the webapp. 461 462 run-job-server: ## Runs the background job server. 463 @echo Running job server for development 464 $(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) $(PLATFORM_FILES) jobserver --disableconfigwatch & 465 466 config-ldap: ## Configures LDAP. 467 @echo Setting up configuration for local LDAP 468 469 @sed -i'' -e 's|"LdapServer": ".*"|"LdapServer": "dockerhost"|g' config/config.json 470 @sed -i'' -e 's|"BaseDN": ".*"|"BaseDN": "ou=testusers,dc=mm,dc=test,dc=com"|g' config/config.json 471 @sed -i'' -e 's|"BindUsername": ".*"|"BindUsername": "cn=admin,dc=mm,dc=test,dc=com"|g' config/config.json 472 @sed -i'' -e 's|"BindPassword": ".*"|"BindPassword": "mostest"|g' config/config.json 473 @sed -i'' -e 's|"FirstNameAttribute": ".*"|"FirstNameAttribute": "cn"|g' config/config.json 474 @sed -i'' -e 's|"LastNameAttribute": ".*"|"LastNameAttribute": "sn"|g' config/config.json 475 @sed -i'' -e 's|"NicknameAttribute": ".*"|"NicknameAttribute": "cn"|g' config/config.json 476 @sed -i'' -e 's|"EmailAttribute": ".*"|"EmailAttribute": "mail"|g' config/config.json 477 @sed -i'' -e 's|"UsernameAttribute": ".*"|"UsernameAttribute": "uid"|g' config/config.json 478 @sed -i'' -e 's|"IdAttribute": ".*"|"IdAttribute": "uid"|g' config/config.json 479 480 config-reset: ## Resets the config/config.json file to the default. 481 @echo Resetting configuration to default 482 rm -f config/config.json 483 cp config/default.json config/config.json 484 485 clean: stop-docker ## Clean up everything except persistant server data. 486 @echo Cleaning 487 488 rm -Rf $(DIST_ROOT) 489 go clean $(GOFLAGS) -i ./... 490 491 cd $(BUILD_WEBAPP_DIR) && $(MAKE) clean 492 493 find . -type d -name data -not -path './vendor/*' | xargs rm -rf 494 rm -rf logs 495 496 rm -f mattermost.log 497 rm -f mattermost.log.jsonl 498 rm -f npm-debug.log 499 rm -f .prepare-go 500 rm -f enterprise 501 rm -f cover.out 502 rm -f ecover.out 503 rm -f *.out 504 rm -f *.test 505 rm -f imports/imports.go 506 rm -f cmd/platform/cprofile*.out 507 rm -f cmd/mattermost/cprofile*.out 508 509 nuke: clean clean-docker ## Clean plus removes persistant server data. 510 @echo BOOM 511 512 rm -rf data 513 514 setup-mac: ## Adds macOS hosts entries for Docker. 515 echo $$(boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts 516 517 518 todo: ## Display TODO and FIXME items in the source code. 519 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO 520 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX 521 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME 522 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME" 523 ifeq ($(BUILD_ENTERPRISE_READY),true) 524 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO enterprise/ 525 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX enterprise/ 526 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME enterprise/ 527 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME" enterprise/ 528 endif 529 530 ## Help documentatin à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html 531 help: 532 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'