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