github.com/adacta-ru/mattermost-server/v6@v6.0.0/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 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 prepackaged-plugins prepackaged-binaries test-server test-server-ee test-server-quick test-server-race start-docker-check 2 3 ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 4 5 ifeq ($(OS),Windows_NT) 6 PLATFORM := Windows 7 else 8 PLATFORM := $(shell uname) 9 endif 10 11 IS_CI ?= false 12 # Build Flags 13 BUILD_NUMBER ?= $(BUILD_NUMBER:) 14 BUILD_DATE = $(shell date -u) 15 BUILD_HASH = $(shell git rev-parse HEAD) 16 # If we don't set the build number it defaults to dev 17 ifeq ($(BUILD_NUMBER),) 18 BUILD_NUMBER := dev 19 endif 20 BUILD_ENTERPRISE_DIR ?= ../enterprise 21 BUILD_ENTERPRISE ?= true 22 BUILD_ENTERPRISE_READY = false 23 BUILD_TYPE_NAME = team 24 BUILD_HASH_ENTERPRISE = none 25 ifneq ($(wildcard $(BUILD_ENTERPRISE_DIR)/.),) 26 ifeq ($(BUILD_ENTERPRISE),true) 27 BUILD_ENTERPRISE_READY = true 28 BUILD_TYPE_NAME = enterprise 29 BUILD_HASH_ENTERPRISE = $(shell cd $(BUILD_ENTERPRISE_DIR) && git rev-parse HEAD) 30 else 31 BUILD_ENTERPRISE_READY = false 32 BUILD_TYPE_NAME = team 33 endif 34 else 35 BUILD_ENTERPRISE_READY = false 36 BUILD_TYPE_NAME = team 37 endif 38 BUILD_WEBAPP_DIR ?= ../mattermost-webapp 39 BUILD_CLIENT = false 40 BUILD_HASH_CLIENT = independant 41 ifneq ($(wildcard $(BUILD_WEBAPP_DIR)/.),) 42 ifeq ($(BUILD_CLIENT),true) 43 BUILD_CLIENT = true 44 BUILD_HASH_CLIENT = $(shell cd $(BUILD_WEBAPP_DIR) && git rev-parse HEAD) 45 else 46 BUILD_CLIENT = false 47 endif 48 else 49 BUILD_CLIENT = false 50 endif 51 52 # Go Flags 53 GOFLAGS ?= $(GOFLAGS:) 54 # We need to export GOBIN to allow it to be set 55 # for processes spawned from the Makefile 56 export GOBIN ?= $(PWD)/bin 57 GO=go 58 DELVE=dlv 59 LDFLAGS += -X "github.com/adacta-ru/mattermost-server/v6/model.BuildNumber=$(BUILD_NUMBER)" 60 LDFLAGS += -X "github.com/adacta-ru/mattermost-server/v6/model.BuildDate=$(BUILD_DATE)" 61 LDFLAGS += -X "github.com/adacta-ru/mattermost-server/v6/model.BuildHash=$(BUILD_HASH)" 62 LDFLAGS += -X "github.com/adacta-ru/mattermost-server/v6/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)" 63 LDFLAGS += -X "github.com/adacta-ru/mattermost-server/v6/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)" 64 65 GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1) 66 GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2) 67 MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1 68 MINIMUM_SUPPORTED_GO_MINOR_VERSION = 13 69 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) 70 71 # GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not 72 BUILDER_GOOS_GOARCH="$(shell $(GO) env GOOS)_$(shell $(GO) env GOARCH)" 73 74 PLATFORM_FILES="./cmd/mattermost/main.go" 75 76 # Output paths 77 DIST_ROOT=dist 78 DIST_PATH=$(DIST_ROOT)/mattermost 79 80 # Tests 81 TESTS=. 82 83 # Packages lists 84 TE_PACKAGES=$(shell $(GO) list ./... | grep -v ./data) 85 86 # Plugins Packages 87 PLUGIN_PACKAGES?=mattermost-plugin-zoom-v1.3.1 88 PLUGIN_PACKAGES += mattermost-plugin-autolink-v1.1.2 89 PLUGIN_PACKAGES += mattermost-plugin-nps-v1.1.0 90 PLUGIN_PACKAGES += mattermost-plugin-custom-attributes-v1.2.0 91 PLUGIN_PACKAGES += mattermost-plugin-github-v0.14.0 92 PLUGIN_PACKAGES += mattermost-plugin-welcomebot-v1.1.1 93 PLUGIN_PACKAGES += mattermost-plugin-aws-SNS-v1.0.2 94 PLUGIN_PACKAGES += mattermost-plugin-antivirus-v0.1.2 95 PLUGIN_PACKAGES += mattermost-plugin-jira-v2.3.2 96 PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.1.0 97 PLUGIN_PACKAGES += mattermost-plugin-jenkins-v1.0.0 98 PLUGIN_PACKAGES += mattermost-plugin-incident-management-v1.2.0 99 PLUGIN_PACKAGES += mattermost-plugin-channel-export-v0.2.2 100 101 # Prepares the enterprise build if exists. The IGNORE stuff is a hack to get the Makefile to execute the commands outside a target 102 ifeq ($(BUILD_ENTERPRISE_READY),true) 103 IGNORE:=$(shell echo Enterprise build selected, preparing) 104 IGNORE:=$(shell rm -f imports/imports.go) 105 IGNORE:=$(shell cp $(BUILD_ENTERPRISE_DIR)/imports/imports.go imports/) 106 IGNORE:=$(shell rm -f enterprise) 107 IGNORE:=$(shell ln -s $(BUILD_ENTERPRISE_DIR) enterprise) 108 else 109 IGNORE:=$(shell rm -f imports/imports.go) 110 endif 111 112 EE_PACKAGES=$(shell $(GO) list ./enterprise/...) 113 114 ifeq ($(BUILD_ENTERPRISE_READY),true) 115 ALL_PACKAGES=$(TE_PACKAGES) $(EE_PACKAGES) 116 else 117 ALL_PACKAGES=$(TE_PACKAGES) 118 endif 119 120 all: run ## Alias for 'run'. 121 122 -include config.override.mk 123 include config.mk 124 include build/*.mk 125 126 RUN_IN_BACKGROUND ?= 127 ifeq ($(RUN_SERVER_IN_BACKGROUND),true) 128 RUN_IN_BACKGROUND := & 129 endif 130 131 start-docker-check: 132 ifeq (,$(findstring minio,$(ENABLED_DOCKER_SERVICES))) 133 TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) minio 134 endif 135 ifeq ($(BUILD_ENTERPRISE_READY),true) 136 ifeq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) 137 TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) openldap 138 endif 139 ifeq (,$(findstring elasticsearch,$(ENABLED_DOCKER_SERVICES))) 140 TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) elasticsearch 141 endif 142 endif 143 ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) $(TEMP_DOCKER_SERVICES) 144 145 start-docker: ## Starts the docker containers for local development. 146 ifneq ($(IS_CI),false) 147 @echo CI Build: skipping docker start 148 else ifeq ($(MM_NO_DOCKER),true) 149 @echo No Docker Enabled: skipping docker start 150 else 151 @echo Starting docker containers 152 153 $(GO) run ./build/docker-compose-generator/main.go $(ENABLED_DOCKER_SERVICES) | docker-compose -f docker-compose.makefile.yml -f /dev/stdin run --rm start_dependencies 154 ifneq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) 155 cat tests/${LDAP_DATA}-data.ldif | docker-compose -f docker-compose.makefile.yml exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest || true'; 156 endif 157 endif 158 159 stop-docker: ## Stops the docker containers for local development. 160 ifeq ($(MM_NO_DOCKER),true) 161 @echo No Docker Enabled: skipping docker stop 162 else 163 @echo Stopping docker containers 164 165 docker-compose stop 166 endif 167 168 clean-docker: ## Deletes the docker containers for local development. 169 ifeq ($(MM_NO_DOCKER),true) 170 @echo No Docker Enabled: skipping docker clean 171 else 172 @echo Removing docker containers 173 174 docker-compose down -v 175 docker-compose rm -v 176 endif 177 178 179 plugin-checker: 180 $(GO) run $(GOFLAGS) ./plugin/checker 181 182 prepackaged-plugins: ## Populate the prepackaged-plugins directory 183 @echo Downloading prepackaged plugins 184 mkdir -p prepackaged_plugins 185 @cd prepackaged_plugins && for plugin_package in $(PLUGIN_PACKAGES) ; do \ 186 curl -f -O -L https://plugins-store.test.mattermost.com/release/$$plugin_package.tar.gz; \ 187 curl -f -O -L https://plugins-store.test.mattermost.com/release/$$plugin_package.tar.gz.sig; \ 188 done 189 190 prepackaged-binaries: ## Populate the prepackaged-binaries to the bin directory 191 ifeq ($(shell test -f bin/mmctl && printf "yes"),yes) 192 @echo "MMCTL already exists in bin/mmctl not downloading a new version." 193 else 194 @scripts/download_mmctl_release.sh 195 endif 196 197 golangci-lint: ## Run golangci-lint on codebase 198 # https://stackoverflow.com/a/677212/1027058 (check if a command exists or not) 199 @if ! [ -x "$$(command -v golangci-lint)" ]; then \ 200 echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions."; \ 201 exit 1; \ 202 fi; \ 203 204 @echo Running golangci-lint 205 golangci-lint run ./... 206 ifeq ($(BUILD_ENTERPRISE_READY),true) 207 ifneq ($(MM_NO_ENTERPRISE_LINT),true) 208 golangci-lint run ./enterprise/... 209 endif 210 endif 211 212 app-layers: ## Extract interface from App struct 213 $(GO) get -modfile=go.tools.mod github.com/reflog/struct2interface 214 $(GOBIN)/struct2interface -f "app" -o "app/app_iface.go" -p "app" -s "App" -i "AppIface" -t ./app/layer_generators/app_iface.go.tmpl 215 $(GO) run ./app/layer_generators -in ./app/app_iface.go -out ./app/opentracing/opentracing_layer.go -template ./app/layer_generators/opentracing_layer.go.tmpl 216 217 i18n-extract: ## Extract strings for translation from the source code 218 $(GO) get -modfile=go.tools.mod github.com/mattermost/mattermost-utilities/mmgotool 219 $(GOBIN)/mmgotool i18n extract --portal-dir="" 220 221 i18n-check: ## Exit on empty translation strings except in english base file 222 $(GO) get -modfile=go.tools.mod github.com/mattermost/mattermost-utilities/mmgotool 223 $(GOBIN)/mmgotool i18n clean-empty --portal-dir="" --check 224 225 store-mocks: ## Creates mock files. 226 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 227 $(GOBIN)/mockery -dir store -all -output store/storetest/mocks -note 'Regenerate this file using `make store-mocks`.' 228 229 telemetry-mocks: ## Creates mock files. 230 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 231 $(GOBIN)/mockery -dir services/telemetry -all -output services/telemetry/mocks -note 'Regenerate this file using `make telemetry-mocks`.' 232 233 store-layers: ## Generate layers for the store 234 $(GO) generate $(GOFLAGS) ./store 235 236 filesstore-mocks: ## Creates mock files. 237 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 238 $(GOBIN)/mockery -dir services/filesstore -all -output services/filesstore/mocks -note 'Regenerate this file using `make filesstore-mocks`.' 239 240 ldap-mocks: ## Creates mock files for ldap. 241 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 242 $(GOBIN)/mockery -dir enterprise/ldap -all -output enterprise/ldap/mocks -note 'Regenerate this file using `make ldap-mocks`.' 243 244 plugin-mocks: ## Creates mock files for plugins. 245 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 246 $(GOBIN)/mockery -dir plugin -name API -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 247 $(GOBIN)/mockery -dir plugin -name Hooks -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 248 $(GOBIN)/mockery -dir plugin -name Helpers -output plugin/plugintest -outpkg plugintest -case underscore -note 'Regenerate this file using `make plugin-mocks`.' 249 250 einterfaces-mocks: ## Creates mock files for einterfaces. 251 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 252 $(GOBIN)/mockery -dir einterfaces -all -output einterfaces/mocks -note 'Regenerate this file using `make einterfaces-mocks`.' 253 254 searchengine-mocks: ## Creates mock files for searchengines. 255 $(GO) get -modfile=go.tools.mod github.com/vektra/mockery/... 256 $(GOBIN)/mockery -dir services/searchengine -all -output services/searchengine/mocks -note 'Regenerate this file using `make searchengine-mocks`.' 257 258 pluginapi: ## Generates api and hooks glue code for plugins 259 $(GO) generate $(GOFLAGS) ./plugin 260 261 check-prereqs: ## Checks prerequisite software status. 262 ./scripts/prereq-check.sh 263 264 check-prereqs-enterprise: ## Checks prerequisite software status for enterprise. 265 ifeq ($(BUILD_ENTERPRISE_READY),true) 266 ./scripts/prereq-check-enterprise.sh 267 endif 268 269 check-style: golangci-lint plugin-checker vet ## Runs golangci against all packages 270 271 test-te-race: ## Checks for race conditions in the team edition. 272 @echo Testing TE race conditions 273 274 @echo "Packages to test: "$(TE_PACKAGES) 275 276 @for package in $(TE_PACKAGES); do \ 277 echo "Testing "$$package; \ 278 $(GO) test $(GOFLAGS) -race -run=$(TESTS) -test.timeout=4000s $$package || exit 1; \ 279 done 280 281 test-ee-race: check-prereqs-enterprise ## Checks for race conditions in the enterprise edition. 282 @echo Testing EE race conditions 283 284 ifeq ($(BUILD_ENTERPRISE_READY),true) 285 @echo "Packages to test: "$(EE_PACKAGES) 286 287 for package in $(EE_PACKAGES); do \ 288 echo "Testing "$$package; \ 289 $(GO) test $(GOFLAGS) -race -run=$(TESTS) -c $$package; \ 290 if [ -f $$(basename $$package).test ]; then \ 291 echo "Testing "$$package; \ 292 ./$$(basename $$package).test -test.timeout=2000s || exit 1; \ 293 rm -r $$(basename $$package).test; \ 294 fi; \ 295 done 296 297 rm -f config/*.crt 298 rm -f config/*.key 299 endif 300 301 test-server-race: test-te-race test-ee-race ## Checks for race conditions. 302 find . -type d -name data -not -path './vendor/*' | xargs rm -rf 303 304 do-cover-file: ## Creates the test coverage report file. 305 @echo "mode: count" > cover.out 306 307 go-junit-report: 308 $(GO) get -modfile=go.tools.mod github.com/jstemmer/go-junit-report 309 310 test-compile: ## Compile tests. 311 @echo COMPILE TESTS 312 313 for package in $(TE_PACKAGES) $(EE_PACKAGES); do \ 314 $(GO) test $(GOFLAGS) -c $$package; \ 315 done 316 317 test-db-migration: start-docker ## Gets diff of upgrade vs new instance schemas. 318 ./scripts/mysql-migration-test.sh 319 ./scripts/psql-migration-test.sh 320 321 gomodtidy: 322 @cp go.mod go.mod.orig 323 @cp go.sum go.sum.orig 324 $(GO) mod tidy 325 @if [ "$$(diff go.mod go.mod.orig)" != "" -o "$$(diff go.sum go.sum.orig)" != "" ]; then \ 326 echo "go.mod/go.sum was modified. \ndiff- $$(diff go.mod go.mod.orig) \n$$(diff go.sum go.sum.orig) \nRun \"go mod tidy\"."; \ 327 rm go.*.orig; \ 328 exit 1; \ 329 fi; 330 @rm go.*.orig; 331 332 test-server: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs tests. 333 ifeq ($(BUILD_ENTERPRISE_READY),true) 334 @echo Running all tests 335 else 336 @echo Running only TE tests 337 endif 338 ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" 339 ifneq ($(IS_CI),true) 340 ifneq ($(MM_NO_DOCKER),true) 341 ifneq ($(TEMP_DOCKER_SERVICES),) 342 @echo Stopping temporary docker services 343 docker-compose stop $(TEMP_DOCKER_SERVICES) 344 endif 345 endif 346 endif 347 348 test-server-ee: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs EE tests. 349 @echo Running only EE tests 350 ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" 351 352 test-server-quick: check-prereqs-enterprise ## Runs only quick tests. 353 ifeq ($(BUILD_ENTERPRISE_READY),true) 354 @echo Running all tests 355 $(GO) test $(GOFLAGS) -short $(ALL_PACKAGES) 356 else 357 @echo Running only TE tests 358 $(GO) test $(GOFLAGS) -short $(TE_PACKAGES) 359 endif 360 361 internal-test-web-client: ## Runs web client tests. 362 $(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests 363 364 run-server-for-web-client-tests: ## Tests the server for web client. 365 $(GO) run $(GOFLAGS) $(PLATFORM_FILES) test web_client_tests_server 366 367 test-client: ## Test client app. 368 @echo Running client tests 369 370 cd $(BUILD_WEBAPP_DIR) && $(MAKE) test 371 372 test: test-server test-client ## Runs all checks and tests below (except race detection and postgres). 373 374 cover: ## Runs the golang coverage tool. You must run the unit tests first. 375 @echo Opening coverage info in browser. If this failed run make test first 376 377 $(GO) tool cover -html=cover.out 378 $(GO) tool cover -html=ecover.out 379 380 test-data: start-docker ## Add test data to the local instance. 381 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) config set TeamSettings.MaxUsersPerTeam 100 382 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) sampledata -w 4 -u 60 383 384 @echo You may need to restart the Mattermost server before using the following 385 @echo ======================================================================== 386 @echo Login with a system admin account username=sysadmin password=Sys@dmin-sample1 387 @echo Login with a regular account username=user-1 password=SampleUs@r-1 388 @echo ======================================================================== 389 390 validate-go-version: ## Validates the installed version of go against Mattermost's minimum requirement. 391 @if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \ 392 exit 0 ;\ 393 elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \ 394 echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ 395 exit 1; \ 396 elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \ 397 echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ 398 exit 1; \ 399 fi 400 401 run-server: prepackaged-binaries validate-go-version start-docker ## Starts the server. 402 @echo Running mattermost for development 403 404 mkdir -p $(BUILD_WEBAPP_DIR)/dist/files 405 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) --disableconfigwatch 2>&1 | \ 406 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) logs --logrus $(RUN_IN_BACKGROUND) 407 408 debug-server: start-docker ## Compile and start server using delve. 409 mkdir -p $(BUILD_WEBAPP_DIR)/dist/files 410 $(DELVE) debug $(PLATFORM_FILES) --build-flags="-ldflags '\ 411 -X github.com/adacta-ru/mattermost-server/v6/model.BuildNumber=$(BUILD_NUMBER)\ 412 -X \"github.com/adacta-ru/mattermost-server/v6/model.BuildDate=$(BUILD_DATE)\"\ 413 -X github.com/adacta-ru/mattermost-server/v6/model.BuildHash=$(BUILD_HASH)\ 414 -X github.com/adacta-ru/mattermost-server/v6/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)\ 415 -X github.com/adacta-ru/mattermost-server/v6/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)'" 416 417 debug-server-headless: start-docker ## Debug server from within an IDE like VSCode or IntelliJ. 418 mkdir -p $(BUILD_WEBAPP_DIR)/dist/files 419 $(DELVE) debug --headless --listen=:2345 --api-version=2 --accept-multiclient $(PLATFORM_FILES) --build-flags="-ldflags '\ 420 -X github.com/adacta-ru/mattermost-server/v6/model.BuildNumber=$(BUILD_NUMBER)\ 421 -X \"github.com/adacta-ru/mattermost-server/v6/model.BuildDate=$(BUILD_DATE)\"\ 422 -X github.com/adacta-ru/mattermost-server/v6/model.BuildHash=$(BUILD_HASH)\ 423 -X github.com/adacta-ru/mattermost-server/v6/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)\ 424 -X github.com/adacta-ru/mattermost-server/v6/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)'" 425 426 run-cli: start-docker ## Runs CLI. 427 @echo Running mattermost for development 428 @echo Example should be like 'make ARGS="-version" run-cli' 429 430 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) ${ARGS} 431 432 run-client: ## Runs the webapp. 433 @echo Running mattermost client for development 434 435 ln -nfs $(BUILD_WEBAPP_DIR)/dist client 436 cd $(BUILD_WEBAPP_DIR) && $(MAKE) run 437 438 run-client-fullmap: ## Legacy alias to run-client 439 @echo Running mattermost client for development 440 441 cd $(BUILD_WEBAPP_DIR) && $(MAKE) run 442 443 run: check-prereqs run-server run-client ## Runs the server and webapp. 444 445 run-fullmap: run-server run-client ## Legacy alias to run 446 447 stop-server: ## Stops the server. 448 @echo Stopping mattermost 449 450 ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64") 451 wmic process where "Caption='go.exe' and CommandLine like '%go.exe run%'" call terminate 452 wmic process where "Caption='mattermost.exe' and CommandLine like '%go-build%'" call terminate 453 else 454 @for PID in $$(ps -ef | grep "[g]o run" | grep "disableconfigwatch" | awk '{ print $$2 }'); do \ 455 echo stopping go $$PID; \ 456 kill $$PID; \ 457 done 458 @for PID in $$(ps -ef | grep "[g]o-build" | grep "disableconfigwatch" | awk '{ print $$2 }'); do \ 459 echo stopping mattermost $$PID; \ 460 kill $$PID; \ 461 done 462 endif 463 464 stop-client: ## Stops the webapp. 465 @echo Stopping mattermost client 466 467 cd $(BUILD_WEBAPP_DIR) && $(MAKE) stop 468 469 stop: stop-server stop-client stop-docker ## Stops server, client and the docker compose. 470 471 restart: restart-server restart-client ## Restarts the server and webapp. 472 473 restart-server: | stop-server run-server ## Restarts the mattermost server to pick up development change. 474 475 restart-client: | stop-client run-client ## Restarts the webapp. 476 477 run-job-server: ## Runs the background job server. 478 @echo Running job server for development 479 $(GO) run $(GOFLAGS) -ldflags '$(LDFLAGS)' $(PLATFORM_FILES) jobserver --disableconfigwatch & 480 481 config-ldap: ## Configures LDAP. 482 @echo Setting up configuration for local LDAP 483 484 @sed -i'' -e 's|"LdapServer": ".*"|"LdapServer": "localhost"|g' config/config.json 485 @sed -i'' -e 's|"BaseDN": ".*"|"BaseDN": "dc=mm,dc=test,dc=com"|g' config/config.json 486 @sed -i'' -e 's|"BindUsername": ".*"|"BindUsername": "cn=admin,dc=mm,dc=test,dc=com"|g' config/config.json 487 @sed -i'' -e 's|"BindPassword": ".*"|"BindPassword": "mostest"|g' config/config.json 488 @sed -i'' -e 's|"FirstNameAttribute": ".*"|"FirstNameAttribute": "cn"|g' config/config.json 489 @sed -i'' -e 's|"LastNameAttribute": ".*"|"LastNameAttribute": "sn"|g' config/config.json 490 @sed -i'' -e 's|"NicknameAttribute": ".*"|"NicknameAttribute": "cn"|g' config/config.json 491 @sed -i'' -e 's|"EmailAttribute": ".*"|"EmailAttribute": "mail"|g' config/config.json 492 @sed -i'' -e 's|"UsernameAttribute": ".*"|"UsernameAttribute": "uid"|g' config/config.json 493 @sed -i'' -e 's|"IdAttribute": ".*"|"IdAttribute": "uid"|g' config/config.json 494 @sed -i'' -e 's|"LoginIdAttribute": ".*"|"LoginIdAttribute": "uid"|g' config/config.json 495 @sed -i'' -e 's|"GroupDisplayNameAttribute": ".*"|"GroupDisplayNameAttribute": "cn"|g' config/config.json 496 @sed -i'' -e 's|"GroupIdAttribute": ".*"|"GroupIdAttribute": "entryUUID"|g' config/config.json 497 498 config-reset: ## Resets the config/config.json file to the default. 499 @echo Resetting configuration to default 500 rm -f config/config.json 501 OUTPUT_CONFIG=$(PWD)/config/config.json $(GO) generate $(GOFLAGS) ./config 502 503 diff-config: ## Compares default configuration between two mattermost versions 504 @./scripts/diff-config.sh 505 506 clean: stop-docker ## Clean up everything except persistant server data. 507 @echo Cleaning 508 509 rm -Rf $(DIST_ROOT) 510 $(GO) clean $(GOFLAGS) -i ./... 511 512 cd $(BUILD_WEBAPP_DIR) && $(MAKE) clean 513 514 find . -type d -name data -not -path './vendor/*' | xargs rm -rf 515 rm -rf logs 516 517 rm -f mattermost.log 518 rm -f mattermost.log.jsonl 519 rm -f npm-debug.log 520 rm -f .prepare-go 521 rm -f enterprise 522 rm -f cover.out 523 rm -f ecover.out 524 rm -f *.out 525 rm -f *.test 526 rm -f imports/imports.go 527 rm -f cmd/platform/cprofile*.out 528 rm -f cmd/mattermost/cprofile*.out 529 530 nuke: clean clean-docker ## Clean plus removes persistent server data. 531 @echo BOOM 532 533 rm -rf data 534 535 setup-mac: ## Adds macOS hosts entries for Docker. 536 echo $$(boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts 537 538 update-dependencies: ## Uses go get -u to update all the dependencies while holding back any that require it. 539 @echo Updating Dependencies 540 541 # Update all dependencies (does not update across major versions) 542 $(GO) get -u ./... 543 544 # Tidy up 545 $(GO) mod tidy 546 547 # Copy everything to vendor directory 548 $(GO) mod vendor 549 550 vet: ## Run mattermost go vet specific checks 551 @if ! [ -x "$$(command -v $(GOBIN)/mattermost-govet)" ]; then \ 552 echo "mattermost-govet is not installed. Please install it executing \"GO111MODULE=off GOBIN=$(PWD)/bin go get -u github.com/mattermost/mattermost-govet\""; \ 553 exit 1; \ 554 fi; 555 @VET_CMD="-license -structuredLogging -inconsistentReceiverName -inconsistentReceiverName.ignore=serialized_gen.go -tFatal"; \ 556 if ! [ -z "${MM_VET_OPENSPEC_PATH}" ] && [ -f "${MM_VET_OPENSPEC_PATH}" ]; then \ 557 VET_CMD="$$VET_CMD -openApiSync -openApiSync.spec=$$MM_VET_OPENSPEC_PATH"; \ 558 else \ 559 echo "MM_VET_OPENSPEC_PATH not set or spec yaml path in it is incorrect. Skipping API check"; \ 560 fi; \ 561 $(GO) vet -vettool=$(GOBIN)/mattermost-govet $$VET_CMD ./... 562 ifeq ($(BUILD_ENTERPRISE_READY),true) 563 ifneq ($(MM_NO_ENTERPRISE_LINT),true) 564 $(GO) vet -vettool=$(GOBIN)/mattermost-govet -enterpriseLicense -structuredLogging -tFatal ./enterprise/... 565 endif 566 endif 567 568 gen-serialized: ## Generates serialization methods for hot structs 569 # This tool only works at a file level, not at a package level. 570 # So you would need to move the structs that need to be serialized temporarily 571 # to session.go and run the tool. 572 $(GO) get -modfile=go.tools.mod github.com/tinylib/msgp 573 $(GOBIN)/msgp -file=./model/session.go -tests=false -o=./model/serialized_gen.go 574 575 todo: ## Display TODO and FIXME items in the source code. 576 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO 577 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX 578 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME 579 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME" 580 ifeq ($(BUILD_ENTERPRISE_READY),true) 581 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime TODO enterprise/ 582 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime XXX enterprise/ 583 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime FIXME enterprise/ 584 @! ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime "FIX ME" enterprise/ 585 endif 586 587 ## Help documentatin à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html 588 help: 589 @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 590 @echo 591 @echo You can modify the default settings for this Makefile creating a file config.mk based on the default-config.mk 592 @echo