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