2023-08-21 09:50:30 +02:00
.PHONY : build package run stop run -client run -server run -haserver stop -haserver stop -client stop -server restart restart -server restart -client restart -haserver start -docker update -docker clean -dist clean nuke check -style check -client -style check -server -style check -unit -tests test dist run -client -tests setup -run -client -tests cleanup -run -client -tests test -client build -linux build -osx build -windows package -prep package -linux package -osx package -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 test -mmctl -unit test -mmctl -e 2e test -mmctl test -mmctl -coverage mmctl -build mmctl -docs new -migration migrations -extract test -public mocks -public
2015-06-14 23:53:32 -08:00
2017-10-12 08:35:19 -07:00
ROOT := $( dir $( abspath $( lastword $( MAKEFILE_LIST) ) ) )
2020-02-03 16:58:15 -05:00
i f e q ( $( OS ) , W i n d o w s _ N T )
PLATFORM := Windows
e l s e
PLATFORM := $( shell uname)
e n d i f
2021-01-19 22:28:22 -04:00
# Set an environment variable on Linux used to resolve `docker.host.internal` inconsistencies with
# docker. This can be reworked once https://github.com/docker/for-linux/issues/264 is resolved
# satisfactorily.
i f e q ( $( PLATFORM ) , L i n u x )
export IS_LINUX = -linux
e l s e
export IS_LINUX =
e n d i f
2023-12-02 17:50:15 +05:30
# Detect Apple Silicon and set a flag.
2022-06-17 13:42:56 +02:00
i f e q ( $( shell uname ) / $( shell uname -m ) , D a r w i n / a r m 6 4 )
2023-12-02 17:50:15 +05:30
ARM_BASED_MAC = true
2022-06-17 13:42:56 +02:00
e n d i f
2022-01-07 20:02:54 +05:30
d e f i n e L I C E N S E _ H E A D E R
/ / C o p y r i g h t ( c ) 2 0 1 5 - p r e s e n t M a t t e r m o s t , I n c . A l l R i g h t s R e s e r v e d .
/ / S e e L I C E N S E . t x t f o r l i c e n s e i n f o r m a t i o n .
e n d e f
2018-12-10 11:58:09 -05:00
IS_CI ?= false
2016-03-18 12:46:57 -04:00
# Build Flags
2015-06-14 23:53:32 -08:00
BUILD_NUMBER ?= $( BUILD_NUMBER:)
2015-09-16 17:45:00 -07:00
BUILD_DATE = $( shell date -u)
2015-09-17 13:01:40 -07:00
BUILD_HASH = $( shell git rev-parse HEAD)
2024-01-08 10:47:24 -04:00
BUILD_TAGS =
2023-03-08 09:14:14 -06:00
2023-06-05 12:42:55 +02:00
2023-03-22 17:22:27 -04:00
# Docker
export COMPOSE_PROJECT_NAME = mattermost-server
2016-03-18 12:46:57 -04:00
# If we don't set the build number it defaults to dev
2015-06-14 23:53:32 -08:00
i f e q ( $( BUILD_NUMBER ) , )
2021-09-15 10:16:20 +02:00
BUILD_DATE := n/a
2015-06-14 23:53:32 -08:00
BUILD_NUMBER := dev
e n d i f
2022-06-23 07:55:50 -04:00
2023-06-15 15:27:52 -03:00
# Go test sum configuration
GOTESTSUM_FORMAT ?= testname
GOTESTSUM_JUNITFILE ?= report.xml
GOTESTSUM_JSONFILE ?= gotestsum.json
2023-06-05 12:42:55 +02:00
# mmctl
MMCTL_BUILD_TAGS =
2023-10-06 19:13:06 +05:30
MMCTL_TESTFLAGS ?= -timeout 30m
2023-06-11 10:54:35 +05:30
MMCTL_PKG = github.com/mattermost/mattermost/server/v8/cmd/mmctl/commands
2023-10-20 11:23:05 +02:00
MMCTL_BUILD_DATE = $( shell date -u +'%Y-%m-%dT%H:%M:%SZ' )
MMCTL_LDFLAGS += -X " $( MMCTL_PKG) .buildDate= $( MMCTL_BUILD_DATE) "
2023-06-05 12:42:55 +02:00
2022-06-23 07:55:50 -04:00
# Enterprise
2023-03-22 17:22:27 -04:00
BUILD_ENTERPRISE_DIR ?= ../../enterprise
2016-03-18 12:46:57 -04:00
BUILD_ENTERPRISE ?= true
BUILD_ENTERPRISE_READY = false
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = team
2016-05-20 10:41:47 -04:00
BUILD_HASH_ENTERPRISE = none
2016-03-18 12:46:57 -04:00
i f n e q ( $( wildcard $ ( BUILD_ENTERPRISE_DIR ) /.) , )
2023-06-11 10:54:35 +05:30
MMCTL_TESTFLAGS += -ldflags '-X "$(MMCTL_PKG).EnableEnterpriseTests=true" -X "github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=true"'
2023-06-05 12:42:55 +02:00
MMCTL_BUILD_TAGS += enterprise
2022-06-09 11:45:17 +02:00
ifeq ( $( BUILD_ENTERPRISE) ,true)
BUILD_ENTERPRISE_READY = true
BUILD_TYPE_NAME = enterprise
BUILD_HASH_ENTERPRISE = $( shell cd $( BUILD_ENTERPRISE_DIR) && git rev-parse HEAD)
2024-01-08 10:47:24 -04:00
BUILD_TAGS += enterprise
2022-06-09 11:45:17 +02:00
else
BUILD_ENTERPRISE_READY = false
BUILD_TYPE_NAME = team
endif
2015-07-29 23:55:45 -08:00
e l s e
2016-03-18 12:46:57 -04:00
BUILD_ENTERPRISE_READY = false
2016-04-06 09:33:33 -04:00
BUILD_TYPE_NAME = team
2015-07-29 23:55:45 -08:00
e n d i f
2022-06-23 07:55:50 -04:00
2024-01-08 10:47:24 -04:00
# Clean up the old means of importing enterprise source, if it exists
i f n e q ( $( wildcard channels /imports /imports .go ) , )
IGNORE := $( shell rm -f channels/imports/imports.go)
e n d i f
# Source available, already included with enterprise but also available during development.
i f e q ( $( BUILD_NUMBER ) , d e v )
BUILD_TAGS += sourceavailable
e n d i f
2022-06-23 07:55:50 -04:00
# Webapp
2023-03-22 17:22:27 -04:00
BUILD_WEBAPP_DIR ?= ../webapp
2015-07-29 23:55:45 -08:00
2021-04-01 13:44:56 -04:00
# We need current user's UID for `run-haserver` so docker compose does not run server
# as root and mess up file permissions for devs. When running like this HOME will be blank
2021-04-28 08:29:55 +02:00
# and docker will add '/', so we need to set the go-build cache location or we'll get
2021-04-01 13:44:56 -04:00
# permission errors on build as it tries to create a cache in filesystem root.
export CURRENT_UID = $( shell id -u) :$( shell id -g)
i f e q ( $( HOME ) , / )
export XDG_CACHE_HOME = /tmp/go-cache/
e n d i f
2020-01-21 18:19:49 +05:30
# Go Flags
2020-04-07 09:01:06 +05:30
GOFLAGS ?= $( GOFLAGS:)
2020-01-27 13:34:35 +05:30
# We need to export GOBIN to allow it to be set
# for processes spawned from the Makefile
export GOBIN ?= $( PWD) /bin
2023-12-14 09:58:11 +01:00
GO ?= go
DELVE ?= dlv
2023-06-11 10:54:35 +05:30
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.BuildNumber= $( BUILD_NUMBER) "
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.BuildDate= $( BUILD_DATE) "
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.BuildHash= $( BUILD_HASH) "
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) "
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) "
2020-09-21 10:28:46 +03:00
2019-07-16 16:08:31 +03:00
GO_MAJOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $( shell $( GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
2021-01-29 14:01:13 +05:30
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 15
2019-07-16 16:08:31 +03:00
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)
2016-03-18 12:46:57 -04:00
2016-09-21 04:59:11 -07:00
# GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not
BUILDER_GOOS_GOARCH = " $( shell $( GO) env GOOS) _ $( shell $( GO) env GOARCH) "
2021-09-06 10:04:32 +02:00
PLATFORM_FILES = "./cmd/mattermost"
2017-10-12 12:24:54 -07:00
2016-03-18 12:46:57 -04:00
# Output paths
2015-06-14 23:53:32 -08:00
DIST_ROOT = dist
DIST_PATH = $( DIST_ROOT) /mattermost
2021-10-12 11:12:32 +02:00
DIST_PATH_LIN_AMD64 = $( DIST_ROOT) /linux_amd64/mattermost
DIST_PATH_LIN_ARM64 = $( DIST_ROOT) /linux_arm64/mattermost
2024-02-28 09:09:37 +02:00
DIST_PATH_OSX_AMD64 = $( DIST_ROOT) /darwin_amd64/mattermost
DIST_PATH_OSX_ARM64 = $( DIST_ROOT) /darwin_arm64/mattermost
2021-07-19 13:35:21 +01:00
DIST_PATH_WIN = $( DIST_ROOT) /windows/mattermost
2015-06-14 23:53:32 -08:00
2017-03-16 17:00:00 -04:00
# Packages lists
2023-08-22 12:48:53 +02:00
TE_PACKAGES = $( shell $( GO) list ./public/...) $( shell $( GO) list ./... | grep -vE 'server/v8/cmd/mmctl' )
2023-06-05 12:42:55 +02:00
MMCTL_PACKAGES = $( shell $( GO) list ./... | grep -E 'server/v8/cmd/mmctl' )
2017-03-16 17:00:00 -04:00
2021-02-25 23:22:26 -05:00
TEMPLATES_DIR = templates
2018-07-16 17:02:13 +02:00
# Plugins Packages
2023-08-25 14:39:25 -05:00
PLUGIN_PACKAGES ?= $( PLUGIN_PACKAGES:)
2024-06-21 09:56:05 -04:00
PLUGIN_PACKAGES += mattermost-plugin-calls-v0.28.2
2024-03-01 05:15:53 +05:30
PLUGIN_PACKAGES += mattermost-plugin-github-v2.2.0
2024-05-23 14:34:52 -04:00
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.9.1
2024-04-24 03:13:47 +05:30
PLUGIN_PACKAGES += mattermost-plugin-jira-v4.1.1
2024-04-11 09:21:23 -07:00
PLUGIN_PACKAGES += mattermost-plugin-playbooks-v1.39.3
2023-10-19 10:17:53 -04:00
PLUGIN_PACKAGES += mattermost-plugin-nps-v1.3.3
2023-06-13 17:48:27 -06:00
PLUGIN_PACKAGES += mattermost-plugin-servicenow-v2.3.4
2024-04-30 00:18:40 -07:00
PLUGIN_PACKAGES += mattermost-plugin-zoom-v1.8.0
2024-06-10 07:13:36 -07:00
PLUGIN_PACKAGES += mattermost-plugin-ai-v0.8.1
2024-06-17 18:30:06 +05:30
PLUGIN_PACKAGES += focalboard-v8.0.0
2018-07-16 17:02:13 +02:00
2022-05-05 21:42:31 +05:30
EE_PACKAGES = $( shell $( GO) list $( BUILD_ENTERPRISE_DIR) /...)
2017-11-14 13:13:31 -06:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2023-06-14 23:33:26 +02:00
ALL_PACKAGES = $( TE_PACKAGES) $( EE_PACKAGES)
2017-11-14 13:13:31 -06:00
e l s e
2023-06-14 23:33:26 +02:00
ALL_PACKAGES = $( TE_PACKAGES)
2022-11-22 07:47:07 +04:00
e n d i f
2024-07-08 08:16:09 +02:00
CONFIG_FILE_PATH ?= ./config/config.json
2020-02-11 12:29:38 -05:00
all : run ## Alias for 'run'.
2020-02-03 16:58:15 -05:00
2020-07-13 22:29:39 +02:00
- i n c l u d e c o n f i g . o v e r r i d e . m k
2022-06-09 11:45:17 +02:00
# Make sure not to modify an overridden ENABLED_DOCKER_SERVICES variable
DOCKER_SERVICES_OVERRIDE = false
i f n e q ( , $( ENABLED_DOCKER_SERVICES ) )
$( info ENABLED_DOCKER_SERVICES has been overridden)
DOCKER_SERVICES_OVERRIDE = true
e n d i f
2020-07-13 22:29:39 +02:00
i n c l u d e c o n f i g . m k
2017-08-10 09:11:55 -07:00
i n c l u d e b u i l d / * . m k
2023-08-21 09:50:30 +02:00
i n c l u d e p u b l i c / M a k e f i l e
2015-11-22 20:39:03 -05:00
2023-06-11 10:54:35 +05:30
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.MockCWS= $( MM_ENABLE_CWS_MOCK) "
2023-08-31 20:29:04 +05:30
LDFLAGS += -X " github.com/mattermost/mattermost/server/public/model.MattermostGiphySdkKey= $( MM_GIPHY_SDK_KEY) "
2021-04-22 15:25:56 +03:00
2020-07-13 22:29:39 +02:00
RUN_IN_BACKGROUND ?=
i f e q ( $( RUN_SERVER_IN_BACKGROUND ) , t r u e )
RUN_IN_BACKGROUND := &
e n d i f
2022-02-15 06:38:50 -07:00
DOCKER_COMPOSE_OVERRIDE =
i f n e q ( "$(wildcard ./docker-compose.override.yaml)" , "" )
2022-06-09 11:45:17 +02:00
DOCKER_COMPOSE_OVERRIDE = -f docker-compose.override.yaml
2022-02-15 06:38:50 -07:00
e n d i f
2023-12-02 17:50:15 +05:30
i f e q ( $( ARM_BASED_MAC ) , t r u e )
$( info Apple Silicon detected, applying elasticsearch override)
2022-06-17 13:42:56 +02:00
DOCKER_COMPOSE_OVERRIDE := -f docker-compose.makefile.m1.yml $( DOCKER_COMPOSE_OVERRIDE)
e n d i f
2022-06-09 11:45:17 +02:00
i f n e q ( $( DOCKER_SERVICES_OVERRIDE ) , t r u e )
ifeq ( ,$( findstring minio,$( ENABLED_DOCKER_SERVICES) ) )
TEMP_DOCKER_SERVICES:= $( TEMP_DOCKER_SERVICES) minio
2020-08-11 10:41:23 +02:00
endif
2022-06-09 11:45:17 +02:00
ifeq ( $( BUILD_ENTERPRISE_READY) ,true)
ifeq ( ,$( findstring openldap,$( ENABLED_DOCKER_SERVICES) ) )
TEMP_DOCKER_SERVICES:= $( TEMP_DOCKER_SERVICES) openldap
endif
ifeq ( ,$( findstring elasticsearch,$( ENABLED_DOCKER_SERVICES) ) )
TEMP_DOCKER_SERVICES:= $( TEMP_DOCKER_SERVICES) elasticsearch
2022-06-17 13:42:56 +02:00
endif
2020-08-11 10:41:23 +02:00
endif
2022-06-09 11:45:17 +02:00
ENABLED_DOCKER_SERVICES:= $( ENABLED_DOCKER_SERVICES) $( TEMP_DOCKER_SERVICES)
2020-07-29 20:21:15 +05:30
e n d i f
2017-12-20 14:49:45 -05:00
start-docker : ## Starts the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f n e q ( $( IS_CI ) , f a l s e )
@echo CI Build: skipping docker start
e l s e i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker start
e l s e
2015-11-22 20:39:03 -05:00
@echo Starting docker containers
2023-11-13 14:30:24 +01:00
docker compose rm start_dependencies
$( GO) run ./build/docker-compose-generator/main.go $( ENABLED_DOCKER_SERVICES) | docker compose -f docker-compose.makefile.yml -f /dev/stdin $( DOCKER_COMPOSE_OVERRIDE) run -T --rm start_dependencies
2022-06-09 11:45:17 +02:00
ifneq ( ,$( findstring openldap,$( ENABLED_DOCKER_SERVICES) ) )
2023-11-13 14:30:24 +01:00
cat tests/${ LDAP_DATA } -data.ldif | docker compose -f docker-compose.makefile.yml $( DOCKER_COMPOSE_OVERRIDE) exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest || true' ;
2022-06-09 11:45:17 +02:00
endif
ifneq ( ,$( findstring mysql-read-replica,$( ENABLED_DOCKER_SERVICES) ) )
2021-03-12 12:37:30 -05:00
./scripts/replica-mysql-config.sh
2022-06-09 11:45:17 +02:00
endif
2018-12-10 11:58:09 -05:00
e n d i f
2016-09-15 09:35:44 -03:00
2023-04-20 14:34:36 -04:00
update-docker : stop -docker ## Updates the docker containers for local development.
@echo Updating docker containers
2023-11-13 14:30:24 +01:00
$( GO) run ./build/docker-compose-generator/main.go $( ENABLED_DOCKER_SERVICES) | docker compose -f docker-compose.makefile.yml -f /dev/stdin $( DOCKER_COMPOSE_OVERRIDE) up --no-start
2023-04-20 14:34:36 -04:00
2021-04-28 08:29:55 +02:00
run-haserver :
2021-01-18 19:38:44 +02:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2021-04-01 13:44:56 -04:00
@echo Starting mattermost in an HA topology '(3 node cluster)'
2021-01-18 19:38:44 +02:00
2023-11-13 14:30:24 +01:00
docker compose -f docker-compose.yaml $( DOCKER_COMPOSE_OVERRIDE) up --remove-orphans haproxy
2021-01-18 19:38:44 +02:00
e n d i f
2021-04-28 08:29:55 +02:00
stop-haserver :
2021-04-01 13:44:56 -04:00
@echo Stopping docker containers for HA topology
2023-11-13 14:30:24 +01:00
docker compose stop
2021-04-01 13:44:56 -04:00
2017-12-20 14:49:45 -05:00
stop-docker : ## Stops the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker stop
e l s e
2015-11-22 20:39:03 -05:00
@echo Stopping docker containers
2015-06-14 23:53:32 -08:00
2023-11-13 14:30:24 +01:00
docker compose stop
2019-09-30 20:50:56 +02:00
e n d i f
2018-12-10 11:58:09 -05:00
2017-12-20 14:49:45 -05:00
clean-docker : ## Deletes the docker containers for local development.
2019-09-30 20:50:56 +02:00
i f e q ( $( MM_NO_DOCKER ) , t r u e )
@echo No Docker Enabled: skipping docker clean
e l s e
2015-11-22 20:39:03 -05:00
@echo Removing docker containers
2015-06-14 23:53:32 -08:00
2023-11-13 14:30:24 +01:00
docker compose down -v
docker compose rm -v
2019-09-30 20:50:56 +02:00
e n d i f
2016-04-21 22:37:01 -07:00
2019-11-18 16:38:13 +05:30
plugin-checker :
2023-05-10 13:07:02 -03:00
$( GO) run $( GOFLAGS) ./public/plugin/checker
2016-10-17 09:52:47 -04:00
2023-09-29 11:41:53 -03:00
prepackaged-plugins : ## Populate the prepackaged-plugins directory.
2023-08-25 14:39:25 -05:00
@echo Downloading prepackaged plugins: $( PLUGIN_PACKAGES)
2020-01-22 13:39:02 -05:00
mkdir -p prepackaged_plugins
@cd prepackaged_plugins && for plugin_package in $( PLUGIN_PACKAGES) ; do \
2024-07-03 08:23:43 +03:00
curl -f -O -L https://plugins.releases.mattermost.com/release/$$ plugin_package.tar.gz; \
curl -f -O -L https://plugins.releases.mattermost.com/release/$$ plugin_package.tar.gz.sig; \
2020-01-22 13:39:02 -05:00
done
2020-02-03 16:58:15 -05:00
prepackaged-binaries : ## Populate the prepackaged-binaries to the bin directory
2020-02-14 16:45:32 -04:00
i f e q ( $( shell test -f bin /mmctl && printf "yes ") , y e s )
2023-06-05 12:42:55 +02:00
@echo "MMCTL already exists in bin/mmctl, not compiling."
2020-02-03 16:58:15 -05:00
e l s e
2023-06-05 12:42:55 +02:00
$( MAKE) mmctl-build
2020-02-03 16:58:15 -05:00
e n d i f
2019-11-18 16:38:13 +05:30
golangci-lint : ## Run golangci-lint on codebase
2024-03-22 10:23:21 +05:30
$( GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1
2019-10-26 12:42:07 +05:30
@echo Running golangci-lint
2022-02-07 23:37:04 +05:30
$( GOBIN) /golangci-lint run ./...
2023-05-30 15:16:42 +05:30
$( GOBIN) /golangci-lint run ./public/...
2019-11-25 23:24:54 +05:30
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2022-06-09 11:45:17 +02:00
ifneq ( $( MM_NO_ENTERPRISE_LINT) ,true)
2023-03-22 17:22:27 -04:00
$( GOBIN) /golangci-lint run $( BUILD_ENTERPRISE_DIR) /...
2022-06-09 11:45:17 +02:00
endif
2020-01-07 12:37:57 +01:00
e n d i f
2019-10-26 12:42:07 +05:30
2020-02-13 13:26:58 +01:00
app-layers : ## Extract interface from App struct
2022-01-14 20:15:07 +05:30
$( GO) install github.com/reflog/struct2interface@v0.6.1
2023-03-22 17:22:27 -04:00
$( GOBIN) /struct2interface -f "channels/app" -o "channels/app/app_iface.go" -p "app" -s "App" -i "AppIface" -t ./channels/app/layer_generators/app_iface.go.tmpl
$( GO) run ./channels/app/layer_generators -in ./channels/app/app_iface.go -out ./channels/app/opentracing/opentracing_layer.go -template ./channels/app/layer_generators/opentracing_layer.go.tmpl
2018-11-29 17:19:26 +01:00
i18n-extract : ## Extract strings for translation from the source code
2023-07-17 16:15:58 +03:00
cd ../tools/mmgotool && $( GO) install .
2020-07-21 14:07:27 +02:00
$( GOBIN) /mmgotool i18n extract --portal-dir= ""
2018-11-29 17:19:26 +01:00
2021-01-04 21:22:34 +01:00
i18n-check : ## Exit on empty translation strings and translation source strings
2023-07-17 16:15:58 +03:00
cd ../tools/mmgotool && $( GO) install .
2020-08-31 10:43:09 +02:00
$( GOBIN) /mmgotool i18n clean-empty --portal-dir= "" --check
2021-01-04 21:22:34 +01:00
$( GOBIN) /mmgotool i18n check-empty-src --portal-dir= ""
2020-08-31 10:43:09 +02:00
2017-12-20 14:49:45 -05:00
store-mocks : ## Creates mock files.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir channels/store --name ".*Store" --output channels/store/storetest/mocks --note 'Regenerate this file using `make store-mocks`.'
2017-10-26 11:36:54 -05:00
2020-09-08 20:30:54 +02:00
telemetry-mocks : ## Creates mock files.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir platform/services/telemetry --all --output platform/services/telemetry/mocks --note 'Regenerate this file using `make telemetry-mocks`.'
2020-09-08 20:30:54 +02:00
2019-08-01 22:10:58 +02:00
store-layers : ## Generate layers for the store
2023-03-22 17:22:27 -04:00
$( GO) generate $( GOFLAGS) ./channels/store
2019-08-01 22:10:58 +02:00
2022-04-15 11:59:59 +05:30
new-migration : ## Creates a new migration. Run with make new-migration name=<>
2023-06-08 16:30:21 +03:00
$( GO) install github.com/mattermost/morph/cmd/morph@1e0640c
2021-02-23 16:22:31 +02:00
@echo "Generating new migration for mysql"
2023-06-08 16:30:21 +03:00
$( GOBIN) /morph new script $( name) --driver mysql --dir channels/db/migrations --sequence
2021-02-23 16:22:31 +02:00
@echo "Generating new migration for postgres"
2023-06-08 16:30:21 +03:00
$( GOBIN) /morph new script $( name) --driver postgres --dir channels/db/migrations --sequence
2021-02-23 16:22:31 +02:00
2021-03-02 14:37:21 +01:00
filestore-mocks : ## Creates mock files.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir platform/shared/filestore --all --output platform/shared/filestore/mocks --note 'Regenerate this file using `make filestore-mocks`.'
2018-09-20 19:07:03 +02:00
2018-05-10 09:46:09 -07:00
ldap-mocks : ## Creates mock files for ldap.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2024-04-25 12:46:19 +02:00
$( GOBIN) /mockery --dir $( BUILD_ENTERPRISE_DIR) /ldap --all --inpackage --note 'Regenerate this file using `make ldap-mocks`.'
2018-05-15 13:33:47 -07:00
plugin-mocks : ## Creates mock files for plugins.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-05-10 13:07:02 -03:00
$( GOBIN) /mockery --dir ./public/plugin --name API --output ./public/plugin/plugintest --outpkg plugintest --case underscore --note 'Regenerate this file using `make plugin-mocks`.'
$( GOBIN) /mockery --dir ./public/plugin --name Hooks --output ./public/plugin/plugintest --outpkg plugintest --case underscore --note 'Regenerate this file using `make plugin-mocks`.'
$( GOBIN) /mockery --dir ./public/plugin --name Driver --output ./public/plugin/plugintest --outpkg plugintest --case underscore --note 'Regenerate this file using `make plugin-mocks`.'
2018-06-25 12:33:13 -07:00
2019-07-08 11:32:29 -04:00
einterfaces-mocks : ## Creates mock files for einterfaces.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-09-07 08:50:22 +02:00
$( GOBIN) /mockery --dir einterfaces --all --output einterfaces/mocks --note 'Regenerate this file using `make einterfaces-mocks`.'
2019-07-08 11:32:29 -04:00
2020-03-13 15:33:18 +01:00
searchengine-mocks : ## Creates mock files for searchengines.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir platform/services/searchengine --all --output platform/services/searchengine/mocks --note 'Regenerate this file using `make searchengine-mocks`.'
2020-03-13 15:33:18 +01:00
2021-04-01 13:44:56 -04:00
sharedchannel-mocks : ## Creates mock files for shared channels.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir= ./platform/services/sharedchannel --name= ServerIface --output= ./platform/services/sharedchannel --inpackage --outpkg= sharedchannel --testonly --note 'Regenerate this file using `make sharedchannel-mocks`.'
$( GOBIN) /mockery --dir= ./platform/services/sharedchannel --name= AppIface --output= ./platform/services/sharedchannel --inpackage --outpkg= sharedchannel --testonly --note 'Regenerate this file using `make sharedchannel-mocks`.'
2021-04-01 13:44:56 -04:00
2021-06-17 17:37:34 +05:30
misc-mocks : ## Creates mocks for misc interfaces.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir channels/utils --name LicenseValidatorIface --output channels/utils/mocks --note 'Regenerate this file using `make misc-mocks`.'
2021-06-17 17:37:34 +05:30
2022-03-02 14:26:57 -07:00
email-mocks : ## Creates mocks for misc interfaces.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir channels/app/email --name ServiceInterface --output channels/app/email/mocks --note 'Regenerate this file using `make email-mocks`.'
2022-03-02 14:26:57 -07:00
2022-10-06 11:04:21 +03:00
platform-mocks : ## Creates mocks for platform interfaces.
2024-04-13 08:15:59 +05:30
$( GO) install github.com/vektra/mockery/v2/...@v2.42.2
2023-03-22 17:22:27 -04:00
$( GOBIN) /mockery --dir channels/app/platform --name SuiteIFace --output channels/app/platform/mocks --note 'Regenerate this file using `make platform-mocks`.'
2022-10-06 11:04:21 +03:00
2023-06-05 12:42:55 +02:00
mmctl-mocks : ## Creates mocks for mmctl
$( GO) install github.com/golang/mock/mockgen@v1.6.0
2023-06-11 10:54:35 +05:30
$( GOBIN) /mockgen -destination= cmd/mmctl/mocks/client_mock.go -copyright_file= cmd/mmctl/mocks/copyright.txt -package= mocks github.com/mattermost/mattermost/server/v8/cmd/mmctl/client Client
2023-06-05 12:42:55 +02:00
2018-06-25 12:33:13 -07:00
pluginapi : ## Generates api and hooks glue code for plugins
2023-06-23 12:24:52 +02:00
cd ./public && $( GO) generate $( GOFLAGS) ./plugin
2017-12-05 16:35:46 -05:00
2023-08-21 09:50:30 +02:00
mocks : store -mocks telemetry -mocks filestore -mocks ldap -mocks plugin -mocks einterfaces -mocks searchengine -mocks sharedchannel -mocks misc -mocks email -mocks platform -mocks mmctl -mocks mocks -public
2022-07-05 18:39:31 +03:00
2023-06-12 18:51:43 +02:00
layers : app -layers store -layers pluginapi
2022-07-05 18:39:31 +03:00
generated : mocks layers
2022-05-05 21:42:31 +05:30
check-prereqs-enterprise : setup -go -work ## Checks prerequisite software status for enterprise.
2020-07-22 11:29:12 +00:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
./scripts/prereq-check-enterprise.sh
e n d i f
2022-06-23 07:55:50 -04:00
setup-go-work : export BUILD_ENTERPRISE_READY := $( BUILD_ENTERPRISE_READY )
2022-05-05 21:42:31 +05:30
setup-go-work : ## Sets up your go.work file
2023-05-10 13:07:02 -03:00
i f n e q ( $( IGNORE_GO_WORK_IF_EXISTS ) , t r u e )
@echo "Creating a go.work file"
rm -f go.work
2024-03-19 10:53:26 -06:00
$( GO) work init
$( GO) work use .
$( GO) work use ./public
2023-05-10 13:07:02 -03:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2024-03-19 10:53:26 -06:00
$( GO) work use ../../enterprise
2023-05-10 13:07:02 -03:00
e n d i f
e n d i f
2022-05-05 21:42:31 +05:30
2023-05-30 15:16:42 +05:30
check-style : plugin -checker vet golangci -lint ## Runs style/lint checks
2023-05-05 10:08:35 +05:30
2016-05-13 16:17:07 -04:00
2023-06-15 15:27:52 -03:00
gotestsum :
2023-10-23 11:54:42 -03:00
$( GO) install gotest.tools/gotestsum@v1.11.0
2018-11-28 09:05:39 -05:00
2023-06-15 15:27:52 -03:00
test-compile : gotestsum ## Compile tests.
2018-11-28 10:56:21 -08:00
@echo COMPILE TESTS
2023-08-22 12:48:53 +02:00
for package in $( TE_PACKAGES) $( EE_PACKAGES) ; do \
2018-11-28 10:56:21 -08:00
$( GO) test $( GOFLAGS) -c $$ package; \
done
2022-06-13 16:20:50 +02:00
modules-tidy :
2024-01-08 10:47:24 -04:00
mv enterprise/external_imports.go enterprise/external_imports.go.orig
2022-06-13 16:20:50 +02:00
-$( GO) mod tidy
2023-05-10 13:07:02 -03:00
-cd public && $( GO) mod tidy
2024-01-08 10:47:24 -04:00
mv enterprise/external_imports.go.orig enterprise/external_imports.go
2022-06-13 16:20:50 +02:00
2023-06-15 15:27:52 -03:00
test-server-pre : check -prereqs -enterprise start -docker gotestsum ## Runs tests.
2018-12-06 13:19:32 -05:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
@echo Running all tests
e l s e
@echo Running only TE tests
e n d i f
2021-03-22 23:11:50 +05:30
2023-06-15 15:27:52 -03:00
test-server-race : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server-race : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server-race : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
2021-03-22 23:11:50 +05:30
test-server-race : test -server -pre
2023-06-15 15:27:52 -03:00
i f e q ( $( IS_CI ) , t r u e )
2023-06-30 15:00:37 -03:00
GOMAXPROCS = 4 $( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- -race $( GOFLAGS) -timeout= 90m
2023-06-15 15:27:52 -03:00
e l s e
2023-06-30 15:00:37 -03:00
$( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- -race $( GOFLAGS) -timeout= 90m
2023-06-15 15:27:52 -03:00
e n d i f
2022-06-09 11:45:17 +02:00
i f n e q ( $( IS_CI ) , t r u e )
ifneq ( $( MM_NO_DOCKER) ,true)
ifneq ( $( TEMP_DOCKER_SERVICES) ,)
@echo Stopping temporary docker services
2023-11-13 14:30:24 +01:00
docker compose stop $( TEMP_DOCKER_SERVICES)
2021-03-22 23:11:50 +05:30
endif
endif
2022-06-09 11:45:17 +02:00
e n d i f
2021-03-22 23:11:50 +05:30
2023-06-15 15:27:52 -03:00
test-server : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
2021-03-22 23:11:50 +05:30
test-server : test -server -pre
2023-09-07 13:06:18 +03:00
$( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- $( GOFLAGS) -timeout= 90m
2022-06-09 11:45:17 +02:00
i f n e q ( $( IS_CI ) , t r u e )
ifneq ( $( MM_NO_DOCKER) ,true)
ifneq ( $( TEMP_DOCKER_SERVICES) ,)
@echo Stopping temporary docker services
2023-11-13 14:30:24 +01:00
docker compose stop $( TEMP_DOCKER_SERVICES)
2020-08-11 10:41:23 +02:00
endif
endif
2022-06-09 11:45:17 +02:00
e n d i f
2020-08-11 10:41:23 +02:00
2023-06-15 15:27:52 -03:00
test-server-ee : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server-ee : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server-ee : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
test-server-ee : check -prereqs -enterprise start -docker gotestsum ## Runs EE tests.
2020-07-22 15:33:46 +05:30
@echo Running only EE tests
2023-06-15 15:27:52 -03:00
$( GOBIN) /gotestsum --packages= " $( EE_PACKAGES) " -- $( GOFLAGS) -timeout= 20m
2020-07-22 15:33:46 +05:30
2023-06-15 15:27:52 -03:00
test-server-quick : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server-quick : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server-quick : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
2020-07-22 11:29:12 +00:00
test-server-quick : check -prereqs -enterprise ## Runs only quick tests.
2020-03-02 17:13:39 +01:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
@echo Running all tests
2023-08-22 12:48:53 +02:00
$( GOBIN) /gotestsum --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- $( GOFLAGS) -short
2020-03-02 17:13:39 +01:00
e l s e
@echo Running only TE tests
2023-08-22 12:48:53 +02:00
$( GOBIN) /gotestsum --packages= " $( TE_PACKAGES) " -- $( GOFLAGS) -short
2020-03-02 17:13:39 +01:00
e n d i f
2017-12-20 14:49:45 -05:00
internal-test-web-client : ## Runs web client tests.
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( PLATFORM_FILES) test web_client_tests
2016-04-21 22:37:01 -07:00
2017-12-20 14:49:45 -05:00
run-server-for-web-client-tests : ## Tests the server for web client.
2017-10-12 12:24:54 -07:00
$( GO) run $( GOFLAGS) $( PLATFORM_FILES) test web_client_tests_server
2017-03-23 18:05:36 +00:00
2017-12-20 14:49:45 -05:00
test-client : ## Test client app.
2016-05-13 16:17:07 -04:00
@echo Running client tests
2016-04-21 22:37:01 -07:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) test
2017-12-20 14:49:45 -05:00
test : test -server test -client ## Runs all checks and tests below (except race detection and postgres).
2015-06-14 23:53:32 -08:00
2017-12-20 14:49:45 -05:00
cover : ## Runs the golang coverage tool. You must run the unit tests first.
2016-05-20 09:40:52 -04:00
@echo Opening coverage info in browser. If this failed run make test first
$( GO) tool cover -html= cover.out
$( GO) tool cover -html= ecover.out
2023-10-30 16:41:14 +01:00
test-data : export MM_SERVICESETTINGS_ENABLELOCALMODE := true
2023-10-23 09:22:07 -07:00
test-data : run -server inject -test -data stop -server ## start a local instance and add test data to it.
2022-03-07 12:57:04 -07:00
inject-test-data : # add test data to the local instance.
2021-08-23 09:45:07 -04:00
@if ! ./scripts/wait-for-system-start.sh; then \
2023-08-16 10:09:11 +03:00
make stop-server; \
2021-08-23 09:45:07 -04:00
fi
bin/mmctl config set TeamSettings.MaxUsersPerTeam 100 --local
bin/mmctl sampledata -u 60 --local
2018-01-31 16:32:18 -08:00
@echo You may need to restart the Mattermost server before using the following
2018-03-23 20:32:10 +01:00
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2019-08-02 19:42:25 +02:00
@echo Login with a system admin account username = sysadmin password = Sys@dmin-sample1
@echo Login with a regular account username = user-1 password = SampleUs@r-1
2018-03-23 20:32:10 +01:00
@echo = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
2018-01-31 16:32:18 -08:00
2023-06-15 15:27:52 -03:00
test-mmctl-unit : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-mmctl-unit : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-mmctl-unit : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
test-mmctl-unit : gotestsum
2023-06-05 12:42:55 +02:00
@echo Running mmctl unit tests
2023-06-15 15:27:52 -03:00
$( GOBIN) /gotestsum --packages= " $( MMCTL_PACKAGES) " -- -tags 'unit $(MMCTL_BUILD_TAGS)' $( MMCTL_TESTFLAGS)
2023-06-05 12:42:55 +02:00
2023-06-15 15:27:52 -03:00
test-mmctl-e2e : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-mmctl-e2e : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-mmctl-e2e : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
test-mmctl-e2e : gotestsum start -docker
2023-06-05 12:42:55 +02:00
@echo Running mmctl e2e tests
2023-06-15 15:27:52 -03:00
$( GOBIN) /gotestsum --packages= " $( MMCTL_PACKAGES) " -- -tags 'e2e $(MMCTL_BUILD_TAGS)' $( MMCTL_TESTFLAGS)
2023-06-05 12:42:55 +02:00
2023-08-28 14:01:14 +02:00
test-mmctl : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-mmctl : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-mmctl : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
2023-06-15 15:27:52 -03:00
test-mmctl : gotestsum start -docker
2023-06-05 12:42:55 +02:00
@echo Running all mmctl tests
2023-06-15 15:27:52 -03:00
$( GOBIN) /gotestsum --packages= " $( MMCTL_PACKAGES) " -- -tags 'unit e2e $(MMCTL_BUILD_TAGS)' $( MMCTL_TESTFLAGS)
2023-06-05 12:42:55 +02:00
2023-08-28 14:01:14 +02:00
test-mmctl-coverage : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-mmctl-coverage : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-mmctl-coverage : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
2023-06-15 15:27:52 -03:00
test-mmctl-coverage : gotestsum start -docker
2023-06-05 12:42:55 +02:00
@echo Running all mmctl tests with coverage
2023-06-15 15:27:52 -03:00
$( GOBIN) /gotestsum --packages= " $( MMCTL_PACKAGES) " -- -tags 'unit e2e $(MMCTL_BUILD_TAGS)' -coverprofile= mmctlcover.out $( MMCTL_TESTFLAGS)
2023-06-05 12:42:55 +02:00
$( GO) tool cover -html= mmctlcover.out
2019-07-16 16:08:31 +03:00
validate-go-version : ## Validates the installed version of go against Mattermost's minimum requirement.
@if [ $( GO_MAJOR_VERSION) -gt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
exit 0 ; \
elif [ $( GO_MAJOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
elif [ $( GO_MINOR_VERSION) -lt $( MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)' ; \
exit 1; \
fi
2021-02-25 23:22:26 -05:00
build-templates : ## Compile all mjml email templates
cd $( TEMPLATES_DIR) && $( MAKE) build
2023-03-22 17:22:27 -04:00
run-server : setup -go -work prepackaged -binaries validate -go -version start -docker client ## Starts the server.
2016-03-18 12:46:57 -04:00
@echo Running mattermost for development
2023-03-22 17:22:27 -04:00
mkdir -p $( BUILD_WEBAPP_DIR) /channels/dist/files
2024-01-08 10:47:24 -04:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $( PLATFORM_FILES) $( RUN_IN_BACKGROUND)
2016-03-18 12:46:57 -04:00
2019-08-16 02:45:42 -04:00
debug-server : start -docker ## Compile and start server using delve.
2023-03-22 17:22:27 -04:00
mkdir -p $( BUILD_WEBAPP_DIR) /channels/dist/files
2018-08-27 13:56:31 +02:00
$( DELVE) debug $( PLATFORM_FILES) --build-flags= " -ldflags '\
2023-06-11 10:54:35 +05:30
-X github.com/mattermost/mattermost/server/public/model.BuildNumber= $( BUILD_NUMBER) \
-X \" github.com/mattermost/mattermost/server/public/model.BuildDate= $( BUILD_DATE) \" \
-X github.com/mattermost/mattermost/server/public/model.BuildHash= $( BUILD_HASH) \
-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) \
2024-01-08 10:47:24 -04:00
-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) ' \
-tags '$(BUILD_TAGS)' "
2018-08-27 13:56:31 +02:00
2019-08-16 02:45:42 -04:00
debug-server-headless : start -docker ## Debug server from within an IDE like VSCode or IntelliJ.
2023-03-22 17:22:27 -04:00
mkdir -p $( BUILD_WEBAPP_DIR) /channels/dist/files
2019-07-17 14:36:58 +03:00
$( DELVE) debug --headless --listen= :2345 --api-version= 2 --accept-multiclient $( PLATFORM_FILES) --build-flags= " -ldflags '\
2023-06-11 10:54:35 +05:30
-X github.com/mattermost/mattermost/server/public/model.BuildNumber= $( BUILD_NUMBER) \
-X \" github.com/mattermost/mattermost/server/public/model.BuildDate= $( BUILD_DATE) \" \
-X github.com/mattermost/mattermost/server/public/model.BuildHash= $( BUILD_HASH) \
-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise= $( BUILD_HASH_ENTERPRISE) \
2024-01-08 10:47:24 -04:00
-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady= $( BUILD_ENTERPRISE_READY) ' \
-tags '$(BUILD_TAGS)' "
2019-07-17 14:36:58 +03:00
2017-12-20 14:49:45 -05:00
run-cli : start -docker ## Runs CLI.
2016-07-06 10:11:21 -08:00
@echo Running mattermost for development
2016-10-19 14:49:25 -04:00
@echo Example should be like 'make ARGS="-version" run-cli'
2016-07-06 10:11:21 -08:00
2024-01-08 10:47:24 -04:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $( PLATFORM_FILES) ${ ARGS }
2016-07-06 10:11:21 -08:00
2023-03-22 17:22:27 -04:00
run-client : client ## Runs the webapp.
2016-03-18 12:46:57 -04:00
@echo Running mattermost client for development
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) run
2016-03-18 12:46:57 -04:00
2023-03-22 17:22:27 -04:00
client : ## Sets up a symlink to the compiled files generated by the web app
@echo Setting up symlink to client directory
ln -nfs $( BUILD_WEBAPP_DIR) /channels/dist client
run-client-fullmap : client ## Legacy alias to run-client
2018-12-05 19:13:00 +01:00
@echo Running mattermost client for development
2016-03-29 18:32:15 -04:00
2018-12-05 19:13:00 +01:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) run
2016-03-29 18:32:15 -04:00
2023-12-02 17:50:15 +05:30
run : run -server run -client ## Runs the server and webapp.
2016-02-17 10:14:29 -05:00
2018-12-05 19:13:00 +01:00
run-fullmap : run -server run -client ## Legacy alias to run
2016-03-29 18:32:15 -04:00
2017-12-20 14:49:45 -05:00
stop-server : ## Stops the server.
2016-03-18 12:46:57 -04:00
@echo Stopping mattermost
2016-10-04 08:56:01 -04:00
i f e q ( $( BUILDER_GOOS_GOARCH ) , "windows_amd64" )
wmic process where "Caption='go.exe' and CommandLine like '%go.exe run%'" call terminate
wmic process where "Caption='mattermost.exe' and CommandLine like '%go-build%'" call terminate
e l s e
2021-09-06 10:04:32 +02:00
@for PID in $$ ( ps -ef | grep "[g]o run" | grep "mattermost" | awk '{ print $$2 }' ) ; do \
2016-02-17 10:14:29 -05:00
echo stopping go $$ PID; \
2015-06-14 23:53:32 -08:00
kill $$ PID; \
done
2021-09-06 10:04:32 +02:00
@for PID in $$ ( ps -ef | grep "[g]o-build" | grep "mattermost" | awk '{ print $$2 }' ) ; do \
2016-02-17 10:14:29 -05:00
echo stopping mattermost $$ PID; \
kill $$ PID; \
done
2017-01-12 21:17:29 +05:30
e n d i f
2015-07-27 09:48:35 -04:00
2017-12-20 14:49:45 -05:00
stop-client : ## Stops the webapp.
2016-03-18 12:46:57 -04:00
@echo Stopping mattermost client
2016-03-18 08:48:26 -04:00
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) stop
2015-12-08 13:38:43 -05:00
2019-11-12 08:32:06 +01:00
stop : stop -server stop -client stop -docker ## Stops server, client and the docker compose.
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
restart : restart -server restart -client ## Restarts the server and webapp.
2016-07-05 11:10:28 -04:00
2017-12-20 14:49:45 -05:00
restart-server : | stop -server run -server ## Restarts the mattermost server to pick up development change.
2016-03-18 12:46:57 -04:00
2021-01-18 19:38:44 +02:00
restart-haserver :
@echo Restarting mattermost in an HA topology
2023-11-13 14:30:24 +01:00
docker compose restart follower2
docker compose restart follower
docker compose restart leader
docker compose restart haproxy
2021-01-18 19:38:44 +02:00
2017-12-20 14:49:45 -05:00
restart-client : | stop -client run -client ## Restarts the webapp.
2016-03-18 12:46:57 -04:00
2017-12-20 14:49:45 -05:00
run-job-server : ## Runs the background job server.
2017-05-18 15:05:57 -04:00
@echo Running job server for development
2024-01-08 10:47:24 -04:00
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $( PLATFORM_FILES) jobserver &
2017-05-18 15:05:57 -04:00
2017-12-20 14:49:45 -05:00
config-ldap : ## Configures LDAP.
2017-11-03 08:45:19 -07:00
@echo Setting up configuration for local LDAP
2024-07-08 08:16:09 +02:00
# Check if jq is installed
@jq --version > /dev/null 2>& 1 || ( echo "jq is not installed. Please install jq to continue." && exit 1)
TMPDIR = $( mktemp -d)
jq --slurp '.[0] * .[1]' ${ CONFIG_FILE_PATH } build/docker/keycloak/ldap.mmsettings.json > ${ TMPDIR } /config.json
cp ${ TMPDIR } /config.json ${ CONFIG_FILE_PATH }
rm ${ TMPDIR } /config.json
2017-11-03 08:45:19 -07:00
2024-04-03 15:01:33 -04:00
config-saml : ## Configures SAML.
@echo Setting up configuration for local SAML with keycloak, please ensure your keycloak is running on http://localhost:8484
2024-07-08 08:16:09 +02:00
# Check if jq is installed
@jq --version > /dev/null 2>& 1 || ( echo "jq is not installed. Please install jq to continue." && exit 1)
@cp build/docker/keycloak/keycloak.crt ./config/saml-idp.crt
TMPDIR = $( mktemp -d)
jq --slurp '.[0] * .[1]' ${ CONFIG_FILE_PATH } build/docker/keycloak/saml.mmsettings.json > ${ TMPDIR } /config.json
cp ${ TMPDIR } /config.json ${ CONFIG_FILE_PATH }
rm ${ TMPDIR } /config.json
config-openid : ## Configures OpenID.
@echo Setting up configuration for local OpenID with keycloak, please ensure your keycloak is running on http://localhost:8484
# Check if jq is installed
@jq --version > /dev/null 2>& 1 || ( echo "jq is not installed. Please install jq to continue." && exit 1)
TMPDIR = $( mktemp -d)
jq --slurp '.[0] * .[1]' ${ CONFIG_FILE_PATH } build/docker/keycloak/openid.mmsettings.json > ${ TMPDIR } /config.json
cp ${ TMPDIR } /config.json ${ CONFIG_FILE_PATH }
rm ${ TMPDIR } /config.json
@echo Finished setting up configuration for local OpenID with keycloak
2024-04-03 15:01:33 -04:00
2023-08-17 11:16:16 -03:00
config-reset : ## Resets the config/config.json file to the default production values.
@echo Resetting configuration to production default
2017-11-03 08:45:19 -07:00
rm -f config/config.json
2023-08-17 11:16:16 -03:00
OUTPUT_CONFIG = $( PWD) /config/config.json $( GO) $( GOFLAGS) run -tags production ./scripts/config_generator
2017-11-03 08:45:19 -07:00
2019-08-29 22:44:13 +02:00
diff-config : ## Compares default configuration between two mattermost versions
@./scripts/diff-config.sh
2022-01-19 23:37:27 -05:00
clean : stop -docker ## Clean up everything except persistent server data.
2016-03-18 12:46:57 -04:00
@echo Cleaning
rm -Rf $( DIST_ROOT)
2019-11-26 19:37:41 +01:00
$( GO) clean $( GOFLAGS) -i ./...
2016-03-18 12:46:57 -04:00
2016-03-24 22:34:35 +09:00
cd $( BUILD_WEBAPP_DIR) && $( MAKE) clean
2015-07-27 09:48:35 -04:00
2022-05-05 21:42:31 +05:30
find . -type d -name data | xargs rm -rf
2016-03-18 12:46:57 -04:00
rm -rf logs
rm -f mattermost.log
2017-09-25 15:02:41 -04:00
rm -f mattermost.log.jsonl
2016-05-13 16:17:07 -04:00
rm -f npm-debug.log
2016-03-18 12:46:57 -04:00
rm -f .prepare-go
2016-05-20 09:40:52 -04:00
rm -f cover.out
rm -f ecover.out
rm -f *.out
rm -f *.test
2023-03-22 17:22:27 -04:00
rm -f channels/imports/imports.go
2018-05-17 22:24:49 -04:00
rm -f cmd/mattermost/cprofile*.out
2016-03-18 12:46:57 -04:00
2019-07-01 06:44:26 -05:00
nuke : clean clean -docker ## Clean plus removes persistent server data.
2016-03-18 12:46:57 -04:00
@echo BOOM
2015-07-27 09:48:35 -04:00
2016-03-18 12:46:57 -04:00
rm -rf data
2022-06-20 12:03:34 +05:30
rm -f go.work go.work.sum
2015-07-27 09:48:35 -04:00
2017-12-20 14:49:45 -05:00
setup-mac : ## Adds macOS hosts entries for Docker.
2016-03-18 12:46:57 -04:00
echo $$ ( boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
2017-01-02 20:24:03 -05:00
2019-06-03 17:10:08 -04:00
update-dependencies : ## Uses go get -u to update all the dependencies while holding back any that require it.
2019-04-10 07:56:17 -07:00
@echo Updating Dependencies
2022-05-10 11:29:51 +03:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2024-01-08 10:47:24 -04:00
@echo Enterprise repository detected, temporarily removing external_imports.go
mv enterprise/external_imports.go enterprise/external_imports.go.orig
2022-11-17 09:27:08 +05:30
e n d i f
2019-04-10 07:56:17 -07:00
# Update all dependencies (does not update across major versions)
2020-02-03 16:19:38 +00:00
$( GO) get -u ./...
2019-04-10 07:56:17 -07:00
2021-03-25 14:45:13 +05:30
# Tidy up
$( GO) mod tidy
2022-05-10 11:29:51 +03:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2024-01-08 10:47:24 -04:00
mv enterprise/external_imports.go.orig enterprise/external_imports.go
2022-11-17 09:27:08 +05:30
e n d i f
2019-12-10 13:10:35 +01:00
vet : ## Run mattermost go vet specific checks
2021-09-02 13:36:20 +05:30
$( GO) install github.com/mattermost/mattermost-govet/v2@new
2024-05-06 10:47:48 +02:00
$( GO) vet -vettool= $( GOBIN) /mattermost-govet -structuredLogging -inconsistentReceiverName -emptyStrCmp -tFatal -configtelemetry -errorAssertions -license -inconsistentReceiverName.ignore= session_serial_gen.go,team_member_serial_gen.go,user_serial_gen.go ./...
ifeq ( $( BUILD_ENTERPRISE_READY) ,true)
2022-06-09 11:45:17 +02:00
ifneq ( $( MM_NO_ENTERPRISE_LINT) ,true)
2024-05-06 10:47:48 +02:00
$( GO) vet -vettool= $( GOBIN) /mattermost-govet -structuredLogging -inconsistentReceiverName -emptyStrCmp -tFatal -configtelemetry -enterpriseLicense $( BUILD_ENTERPRISE_DIR) /...
2022-06-09 11:45:17 +02:00
endif
2020-01-07 12:37:57 +01:00
e n d i f
2017-02-09 13:39:15 -08:00
2023-10-16 11:27:43 -03:00
vet-api : export GO := $( GO )
vet-api : export GOBIN := $( GOBIN )
vet-api : export ROOT := $( ROOT )
vet-api : ## Run mattermost go vet to verify api4 documentation, currently not passing
$( GO) install github.com/mattermost/mattermost-govet/v2@new
make -C ../api build
./scripts/vet-api-check.sh
2022-01-07 20:02:54 +05:30
gen-serialized : export LICENSE_HEADER :=$( LICENSE_HEADER )
2020-08-13 13:05:57 +05:30
gen-serialized : ## Generates serialization methods for hot structs
# This tool only works at a file level, not at a package level.
2021-01-29 14:01:13 +05:30
# There will be some warnings about "unresolved identifiers",
# but that is because of the above problem. Since we are generating
# methods for all the relevant files at a package level, all
# identifiers will be resolved. An alternative to remove the warnings
# would be to temporarily move all the structs to the same file,
2021-01-24 23:58:26 -05:00
# but that involves a lot of manual work.
2022-01-07 20:02:54 +05:30
$( GO) install github.com/tinylib/msgp@v1.1.6
2023-05-10 13:07:02 -03:00
$( GOBIN) /msgp -file= ./public/model/session.go -tests= false -o= ./public/model/session_serial_gen.go
2022-01-07 20:02:54 +05:30
@echo " $$ LICENSE_HEADER " > tmp.go
2023-05-10 13:07:02 -03:00
@cat ./public/model/session_serial_gen.go >> tmp.go
@mv tmp.go ./public/model/session_serial_gen.go
$( GOBIN) /msgp -file= ./public/model/user.go -tests= false -o= ./public/model/user_serial_gen.go
2022-01-07 20:02:54 +05:30
@echo " $$ LICENSE_HEADER " > tmp.go
2023-05-10 13:07:02 -03:00
@cat ./public/model/user_serial_gen.go >> tmp.go
@mv tmp.go ./public/model/user_serial_gen.go
$( GOBIN) /msgp -file= ./public/model/team_member.go -tests= false -o= ./public/model/team_member_serial_gen.go
2022-01-07 20:02:54 +05:30
@echo " $$ LICENSE_HEADER " > tmp.go
2023-05-10 13:07:02 -03:00
@cat ./public/model/team_member_serial_gen.go >> tmp.go
@mv tmp.go ./public/model/team_member_serial_gen.go
2020-08-13 13:05:57 +05:30
2017-12-20 14:49:45 -05:00
todo : ## Display TODO and FIXME items in the source code.
2022-05-05 21:42:31 +05:30
@! ag --ignore Makefile --ignore-dir runtime '(TODO|XXX|FIXME|"FIX ME")[: ]+'
2017-01-02 20:24:03 -05:00
i f e q ( $( BUILD_ENTERPRISE_READY ) , t r u e )
2023-03-22 17:22:27 -04:00
@! ag --ignore Makefile --ignore-dir runtime '(TODO|XXX|FIXME|"FIX ME")[: ]+' $( BUILD_ENTERPRISE_DIR) /
2017-01-02 20:24:03 -05:00
e n d i f
2017-12-20 14:49:45 -05:00
2023-06-05 12:42:55 +02:00
mmctl-build : ## Compiles and generates the mmctl binary
2023-10-20 11:23:05 +02:00
go build -trimpath -ldflags '$(MMCTL_LDFLAGS)' -o bin/mmctl ./cmd/mmctl
2023-06-05 12:42:55 +02:00
mmctl-docs : ## Generate the mmctl docs
rm -rf ./cmd/mmctl/docs
cd ./cmd/mmctl && go run mmctl.go docs
2022-01-19 23:37:27 -05:00
## Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2017-12-20 14:49:45 -05:00
help :
2019-08-09 10:22:33 -04:00
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2020-07-13 22:29:39 +02:00
@echo
@echo You can modify the default settings for this Makefile creating a file config.mk based on the default-config.mk
@echo
2022-06-21 09:34:36 +03:00
migrations-extract :
@echo Listing migration files
2023-03-22 17:22:27 -04:00
@echo "# Autogenerated file to synchronize migrations sequence in the PR workflow, please do not edit.\n#" > channels/db/migrations/migrations.list
find channels/db/migrations -maxdepth 2 -mindepth 2 | sort >> channels/db/migrations/migrations.list
2023-08-16 10:09:11 +03:00
test-migration :
$( GO) install github.com/mattermost/morph/cmd/morph@latest
# apply postgres migrations to the new db
bin/morph apply up --driver postgres --dsn " ${ POSTGRES_DSN } " --path ${ POSTGRES_MIGRATIONS_PATH } --number -1
# create temporary file for the config
@cp tests/template.load tests/temp.load
# set required values for the pgloader config, these values are read from /build/dotenv/migration.env in the CI
# do for psql credentials
@sed -i'' -e 's|{{ .pg_user }}|${PG_USERNAME}|g' tests/temp.load
@sed -i'' -e 's|{{ .pg_password }}|${PG_PASSWORD}|g' tests/temp.load
@sed -i'' -e 's|{{ .target_schema }}|${PG_SCHEMA}|g' tests/temp.load
# do for mysql credentials
@sed -i'' -e 's|{{ .mysql_user }}|${MYSQL_USERNAME}|g' tests/temp.load
@sed -i'' -e 's|{{ .mysql_password }}|${MYSQL_PASSWORD}|g' tests/temp.load
@sed -i'' -e 's|{{ .source_schema }}|${MYSQL_SCHEMA}|g' tests/temp.load
# run pgloader and save the logs
2024-01-11 22:18:20 +05:30
pgloader --debug tests/temp.load > migration.log
2023-08-16 10:09:11 +03:00
$( GO) install github.com/mattermost/dbcmp/cmd/dbcmp@latest
# compare two database contents
# db_migrations differ due to a typo in the 92. migration name
# for now we exclude plugins such as playbooks and focalboard
# we also exlude systems table temporarily due to adding some keys while running the initial migration
bin/dbcmp --source " ${ MYSQL_DSN } " --target " ${ POSTGRES_DSN } " --exclude= "db_migrations" ,"ir_" ,"focalboard" ,"systems"