Advertisement
Guest User

Untitled

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