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