2017-10-12 08:35:19 -07:00
ROOT := $( dir $( abspath $( lastword $( MAKEFILE_LIST))))
2026-09-09 17:20:12 -04:00
# Must be read before parse-time Enterprise detection so BUILD_ENTERPRISE_DIR applies.
-include $( ROOT ) config.override.mk
2020-02-03 16:58:15 -05:00
ifeq ( $( OS ) ,Windows_NT)
PLATFORM := Windows
else
PLATFORM := $( shell uname)
endif
2022-06-17 13:42:56 +02:00
2022-01-07 20:02:54 +05:30
define LICENSE_HEADER
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
endef
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
ifeq ( $( 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
endif
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
2025-05-30 05:58:26 -06:00
# Go test coverage
ENABLE_COVERAGE ?= false
ifeq ( $( ENABLE_COVERAGE ) ,true)
COVERAGE_FLAG = -coverprofile= cover.out -covermode= atomic
endif
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' )
2026-03-20 15:28:36 +02:00
MMCTL_GIT_COMMIT = $( shell git rev-parse HEAD)
MMCTL_GIT_TREE_STATE = $( shell if [ -n " $$ (git status --porcelain 2>/dev/null)" ] ; then echo "dirty" ; else echo "clean" ; fi)
MMCTL_COMMIT_DATE = $( shell TZ = UTC git log -1 --date= format-local:'%Y-%m-%dT%H:%M:%SZ' --format= '%cd' 2>/dev/null || echo "dev" )
2023-10-20 11:23:05 +02:00
MMCTL_LDFLAGS += -X " $( MMCTL_PKG) .buildDate= $( MMCTL_BUILD_DATE) "
2026-03-20 15:28:36 +02:00
MMCTL_LDFLAGS += -X " $( MMCTL_PKG) .gitCommit= $( MMCTL_GIT_COMMIT) "
MMCTL_LDFLAGS += -X " $( MMCTL_PKG) .gitTreeState= $( MMCTL_GIT_TREE_STATE) "
MMCTL_LDFLAGS += -X " $( MMCTL_PKG) .commitDate= $( MMCTL_COMMIT_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
ifneq ( $( 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
else
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
endif
2022-06-23 07:55:50 -04:00
2025-09-15 10:53:28 -03:00
FIPS_ENABLED ?= false
ifeq ( $( FIPS_ENABLED ) ,true)
BUILD_TYPE_NAME := $( BUILD_TYPE_NAME) -fips
endif
2024-01-08 10:47:24 -04:00
# Clean up the old means of importing enterprise source, if it exists
ifneq ( $( wildcard channels /imports /imports .go ) ,)
IGNORE := $( shell rm -f channels/imports/imports.go)
endif
# Source available, already included with enterprise but also available during development.
ifeq ( $( BUILD_NUMBER ) ,dev)
BUILD_TAGS += sourceavailable
endif
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)
ifeq ( $( HOME ) ,/)
export XDG_CACHE_HOME = /tmp/go-cache/
endif
2020-01-21 18:19:49 +05:30
# Go Flags
2026-03-20 15:28:36 +02:00
# Use -buildvcs=false to avoid embedding VCS info which can cause false positives in container scanning tools
export GOFLAGS ?= -buildvcs= false
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
2025-09-15 10:53:28 -03:00
ifeq ( $( FIPS_ENABLED ) ,true)
BUILD_TAGS += requirefips
2026-04-27 21:41:57 -03:00
MMCTL_BUILD_TAGS += requirefips
2025-09-15 10:53:28 -03:00
endif
2023-12-14 09:58:11 +01:00
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)
2025-03-11 11:44:42 -06:00
GO_COMPATIBILITY_TEST_VERSIONS := 1.22.7 1.23.6
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
2026-02-03 15:05:16 +01:00
DIST_PATH_FREEBSD_AMD64 = $( DIST_ROOT) /freebsd_amd64/mattermost
DIST_PATH_FREEBSD_ARM64 = $( DIST_ROOT) /freebsd_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:)
2026-10-19 01:31:48 -04:00
PLUGIN_PACKAGES += mattermost-plugin-calls-v1.12.6
2026-09-21 11:58:04 +03:00
PLUGIN_PACKAGES += mattermost-plugin-github-v3.0.0
2026-09-18 13:01:27 +03:00
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v2.0.0
2026-09-30 17:38:32 +09:00
PLUGIN_PACKAGES += mattermost-plugin-jira-v5.0.0
2026-09-29 22:37:01 -07:00
PLUGIN_PACKAGES += mattermost-plugin-playbooks-v2.12.1
2026-09-18 14:28:18 +07:00
PLUGIN_PACKAGES += mattermost-plugin-zoom-v2.0.0
2026-10-01 10:06:00 +02:00
PLUGIN_PACKAGES += mattermost-plugin-agents-v2.9.0
2026-10-27 14:05:24 +02:00
PLUGIN_PACKAGES += mattermost-plugin-boards-v10.1.0
2024-08-23 18:14:32 +05:30
PLUGIN_PACKAGES += mattermost-plugin-user-survey-v1.1.1
2026-09-23 11:04:06 +03:00
PLUGIN_PACKAGES += mattermost-plugin-mscalendar-v2.0.0
2026-09-25 14:15:17 +09:00
PLUGIN_PACKAGES += mattermost-plugin-msteams-meetings-v3.0.0
2025-05-15 14:24:44 +02:00
PLUGIN_PACKAGES += mattermost-plugin-metrics-v0.7.0
2025-11-12 14:14:41 -05:00
PLUGIN_PACKAGES += mattermost-plugin-channel-export-v1.3.0
2026-10-20 13:31:49 +03:00
PLUGIN_PACKAGES += mattermost-plugin-dataminr-v3.0.0
2026-09-21 13:27:35 -04:00
PLUGIN_PACKAGES += mattermost-plugin-legal-hold-v1.1.6
2018-07-16 17:02:13 +02:00
2025-09-15 10:53:28 -03:00
# Overwrite the definition of PLUGIN_PACKAGES with the list of FIPS-ready plugins
# Note that the '+' in the file name is encoded as %2B for the URL we use to
# download the package from to work. This will no longer be needed when we unify
# the way we pre-package FIPS and non-FIPS plugins.
ifeq ( $( FIPS_ENABLED ) ,true)
2026-09-29 22:37:01 -07:00
PLUGIN_PACKAGES = mattermost-plugin-playbooks-v2.12.1%2Bf370c05-fips
2026-10-01 10:06:00 +02:00
PLUGIN_PACKAGES += mattermost-plugin-agents-v2.9.0%2Bc234d17-fips
2026-10-27 14:05:24 +02:00
PLUGIN_PACKAGES += mattermost-plugin-boards-v10.1.0%2B23ece5d-fips
2025-09-15 10:53:28 -03:00
endif
2022-05-05 21:42:31 +05:30
EE_PACKAGES = $( shell $( GO) list $( BUILD_ENTERPRISE_DIR) /...)
2017-11-14 13:13:31 -06:00
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
2023-06-14 23:33:26 +02:00
ALL_PACKAGES = $( TE_PACKAGES) $( EE_PACKAGES)
2017-11-14 13:13:31 -06:00
else
2023-06-14 23:33:26 +02:00
ALL_PACKAGES = $( TE_PACKAGES)
2022-11-22 07:47:07 +04:00
endif
2024-07-08 08:16:09 +02:00
CONFIG_FILE_PATH ?= ./config/config.json
2026-07-10 13:22:50 -03:00
.PHONY : all
2020-02-11 12:29:38 -05:00
all : run ## Alias for 'run'.
2020-02-03 16:58:15 -05:00
2022-06-09 11:45:17 +02:00
# Make sure not to modify an overridden ENABLED_DOCKER_SERVICES variable
DOCKER_SERVICES_OVERRIDE = false
ifneq (, $( ENABLED_DOCKER_SERVICES ) )
$( info ENABLED_DOCKER_SERVICES has been overridden )
DOCKER_SERVICES_OVERRIDE = true
endif
2020-07-13 22:29:39 +02:00
include config.mk
2017-08-10 09:11:55 -07:00
include build/*.mk
2023-08-21 09:50:30 +02:00
include public/Makefile
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 ?=
ifeq ( $( RUN_SERVER_IN_BACKGROUND ) ,true)
RUN_IN_BACKGROUND := &
endif
2022-02-15 06:38:50 -07:00
DOCKER_COMPOSE_OVERRIDE =
ifneq ( "$(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
endif
2022-06-17 13:42:56 +02:00
2025-09-15 14:58:43 -04:00
# Support for pgvector postgres image
MM_USE_PGVECTOR ?= false
ifeq ( $( MM_USE_PGVECTOR ) ,true)
$( info Using pgvector /pgvector image for PostgreSQL )
DOCKER_COMPOSE_OVERRIDE := -f docker-compose.pgvector.yml $( DOCKER_COMPOSE_OVERRIDE)
endif
2022-06-09 11:45:17 +02:00
ifneq ( $( DOCKER_SERVICES_OVERRIDE ) ,true)
ifeq (, $( findstring minio ,$( ENABLED_DOCKER_SERVICES )) )
TEMP_DOCKER_SERVICES := $( TEMP_DOCKER_SERVICES) minio
2020-08-11 10:41:23 +02:00
endif
2026-05-11 12:06:59 +02:00
ifeq ( ,$( findstring azurite,$( ENABLED_DOCKER_SERVICES)) )
TEMP_DOCKER_SERVICES:= $( TEMP_DOCKER_SERVICES) azurite
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
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
endif
2026-07-10 13:22:50 -03:00
.PHONY : start -docker
2026-03-20 16:12:20 -03:00
start-docker : setup -go -work ## Starts the docker containers for local development.
2019-09-30 20:50:56 +02:00
ifneq ( $( IS_CI ) ,false)
@echo CI Build : skipping docker start
else ifeq ( $( MM_NO_DOCKER ) ,true)
@echo No Docker Enabled : skipping docker start
else
2015-11-22 20:39:03 -05:00
@echo Starting docker containers
2025-09-15 14:58:43 -04:00
ifeq ( $( MM_USE_PGVECTOR ) ,true)
@echo Using pgvector PostgreSQL image
endif
2015-11-22 20:39:03 -05:00
2026-02-27 16:48:17 +01:00
mkdir -p logs
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 )) )
2026-08-21 00:18:06 +02:00
cat tests/custom-schema-objectID.ldif | docker compose -f docker-compose.makefile.yml $(DOCKER_COMPOSE_OVERRIDE) exec -T openldap bash -c 'ldapadd -Y EXTERNAL -H ldapi : /// -w mostest_password || true ';
cat tests/custom-schema-cpa.ldif | docker compose -f docker-compose.makefile.yml ${ DOCKER_COMPOSE_OVERRIDE } exec -T openldap bash -c 'ldapadd -Y EXTERNAL -H ldapi:/// -w mostest_password || true' ;
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_password || true' ;
2022-06-09 11:45:17 +02:00
endif
2018-12-10 11:58:09 -05:00
endif
2016-09-15 09:35:44 -03:00
2026-07-10 13:22:50 -03:00
.PHONY : update -docker
2026-03-20 16:12:20 -03:00
update-docker : setup -go -work stop -docker ## Updates the docker containers for local development.
2023-04-20 14:34:36 -04:00
@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
2026-07-10 13:22:50 -03:00
.PHONY : run -haserver
2021-04-28 08:29:55 +02:00
run-haserver :
2021-01-18 19:38:44 +02:00
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
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
endif
2026-07-10 13:22:50 -03:00
.PHONY : stop -haserver
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
2026-07-10 13:22:50 -03:00
.PHONY : stop -docker
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
ifeq ( $( MM_NO_DOCKER ) ,true)
@echo No Docker Enabled : skipping docker stop
else
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
endif
2018-12-10 11:58:09 -05:00
2026-07-10 13:22:50 -03:00
.PHONY : clean -docker
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
ifeq ( $( MM_NO_DOCKER ) ,true)
@echo No Docker Enabled : skipping docker clean
else
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
2025-10-16 11:22:53 -04:00
2026-10-27 11:40:54 -07:00
docker volume rm mattermost-server_postgres-15-data || true
2019-09-30 20:50:56 +02:00
endif
2016-04-21 22:37:01 -07:00
2026-07-10 13:22:50 -03:00
.PHONY : plugin -checker
2026-03-20 16:12:20 -03:00
plugin-checker : setup -go -work
2023-05-10 13:07:02 -03:00
$( GO) run $( GOFLAGS) ./public/plugin/checker
2016-10-17 09:52:47 -04:00
2026-07-10 13:22:50 -03:00
.PHONY : prepackaged -plugins
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
2026-07-10 13:22:50 -03:00
.PHONY : prepackaged -binaries
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
ifeq ( $( shell test -f bin /mmctl && printf "yes ") ,yes)
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
else
2023-06-05 12:42:55 +02:00
$( MAKE ) mmctl-build
2020-02-03 16:58:15 -05:00
endif
2026-07-10 13:22:50 -03:00
.PHONY : golang -versions
2025-03-11 11:44:42 -06:00
golang-versions : ## Install Golang versions used for compatibility testing (e.g. plugins)
@for version in $( GO_COMPATIBILITY_TEST_VERSIONS) ; do \
$( GO) install golang.org/dl/go$$ version@latest && \
$( GOBIN) /go$$ version download; \
done
export GO_COMPATIBILITY_TEST_VERSIONS = " ${ GO_COMPATIBILITY_TEST_VERSIONS } "
2026-09-03 06:00:50 -03:00
.PHONY : install -golangci -lint
install-golangci-lint :
2026-10-23 13:06:59 -03:00
$( GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
2026-09-03 06:00:50 -03:00
.PHONY : golangci -lint
golangci-lint : setup -go -work install -golangci -lint ## Run golangci-lint on codebase
2019-11-25 23:24:54 +05:30
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
2025-05-30 12:31:30 -03:00
$( GOBIN ) /golangci-lint run ./... ./public/... $( BUILD_ENTERPRISE_DIR ) /...
else
$( GOBIN ) /golangci-lint run ./... ./public/...
2020-01-07 12:37:57 +01:00
endif
2019-10-26 12:42:07 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : i 18n -extract
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
2026-09-08 17:36:16 -03:00
.PHONY : i 18n -verify
i18n-verify : ## Verify the non-English translation files against en.json
cd ../tools/mmgotool && $( GO) install .
$( GOBIN) /mmgotool i18n verify --warn-missing-ids
2026-10-22 16:20:27 -03:00
.PHONY : i 18n -verify -all
i18n-verify-all : i 18n -verify ## Run every translation check: both surfaces' catalogs, the glossary and the translation pipeline
cd ../tools/mmgotool && $( GO) test ./commands/ -run TestServerPluralTableMatchesGoI18n
@test -d $( BUILD_WEBAPP_DIR) /node_modules || { echo " $( BUILD_WEBAPP_DIR) /node_modules is missing; run make -C $( BUILD_WEBAPP_DIR) node_modules" ; exit 1; }
cd $( BUILD_WEBAPP_DIR) /channels && npm run i18n-verify-translations -- --warn-missing-keys
cd .. && node --test i18n/scripts/*.test.mjs
cd .. && node i18n/scripts/check_glossary.mjs
2026-07-10 13:22:50 -03:00
.PHONY : i 18n -check
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
2026-09-03 06:00:50 -03:00
.PHONY : install -mockery
install-mockery :
2025-06-10 15:04:57 -03:00
$( GO) install github.com/vektra/mockery/v2/...@v2.53.4
2026-09-03 06:00:50 -03:00
.PHONY : store -mocks
store-mocks : setup -go -work install -mockery ## Creates mock files.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config channels/store/.mockery.yaml
2017-10-26 11:36:54 -05:00
2026-07-10 13:22:50 -03:00
.PHONY : cache -mocks
2026-09-03 06:00:50 -03:00
cache-mocks : setup -go -work install -mockery
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config platform/services/cache/.mockery.yaml
2024-08-06 09:28:41 +05:30
2020-09-08 20:30:54 +02:00
2026-07-10 13:22:50 -03:00
.PHONY : store -layers
2026-03-20 16:12:20 -03:00
store-layers : setup -go -work ## 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
2026-09-03 06:00:50 -03:00
.PHONY : install -morph
install-morph :
2023-06-08 16:30:21 +03:00
$( GO) install github.com/mattermost/morph/cmd/morph@1e0640c
2026-09-03 06:00:50 -03:00
.PHONY : new -migration
new-migration : install -morph ## Creates a new migration. Run with make new-migration name=<>
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
2026-07-10 13:22:50 -03:00
.PHONY : filestore -mocks
2026-09-03 06:00:50 -03:00
filestore-mocks : setup -go -work install -mockery ## Creates mock files.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config platform/shared/filestore/.mockery.yaml
2018-09-20 19:07:03 +02:00
2026-07-10 13:22:50 -03:00
.PHONY : ldap -mocks
2026-09-03 06:00:50 -03:00
ldap-mocks : setup -go -work install -mockery ## Creates mock files for ldap.
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
2026-07-10 13:22:50 -03:00
.PHONY : plugin -mocks
2026-09-03 06:00:50 -03:00
plugin-mocks : setup -go -work install -mockery ## Creates mock files for plugins.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config public/plugin/.mockery.yaml
2018-06-25 12:33:13 -07:00
2026-07-10 13:22:50 -03:00
.PHONY : einterfaces -mocks
2026-09-03 06:00:50 -03:00
einterfaces-mocks : setup -go -work install -mockery ## Creates mock files for einterfaces.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config einterfaces/.mockery.yaml
2019-07-08 11:32:29 -04:00
2026-07-10 13:22:50 -03:00
.PHONY : searchengine -mocks
2026-09-03 06:00:50 -03:00
searchengine-mocks : setup -go -work install -mockery ## Creates mock files for searchengines.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config platform/services/searchengine/.mockery.yaml
2020-03-13 15:33:18 +01:00
2026-07-10 13:22:50 -03:00
.PHONY : sharedchannel -mocks
2026-09-03 06:00:50 -03:00
sharedchannel-mocks : setup -go -work install -mockery ## Creates mock files for shared channels.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config platform/services/sharedchannel/.mockery.yaml
2021-04-01 13:44:56 -04:00
2026-07-10 13:22:50 -03:00
.PHONY : misc -mocks
2026-09-03 06:00:50 -03:00
misc-mocks : setup -go -work install -mockery ## Creates mocks for misc interfaces.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config channels/utils/.mockery.yaml
2021-06-17 17:37:34 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : email -mocks
2026-09-03 06:00:50 -03:00
email-mocks : setup -go -work install -mockery ## Creates mocks for misc interfaces.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config channels/app/email/.mockery.yaml
2022-03-02 14:26:57 -07:00
2026-07-10 13:22:50 -03:00
.PHONY : platform -mocks
2026-09-03 06:00:50 -03:00
platform-mocks : setup -go -work install -mockery ## Creates mocks for platform interfaces.
2024-11-07 12:48:11 +01:00
$( GOBIN) /mockery --config channels/app/platform/.mockery.yaml
2022-10-06 11:04:21 +03:00
2026-09-03 06:00:50 -03:00
.PHONY : install -mockgen
install-mockgen :
2026-09-18 15:40:13 +02:00
$( GO) install go.uber.org/mock/mockgen@v0.6.0
2026-09-03 06:00:50 -03:00
.PHONY : mmctl -mocks
mmctl-mocks : setup -go -work install -mockgen ## Creates mocks for mmctl
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
2026-07-10 13:22:50 -03:00
.PHONY : pluginapi
2026-03-20 16:12:20 -03:00
pluginapi : setup -go -work ## 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
2026-07-10 13:22:50 -03:00
.PHONY : default -roles -permissions
2026-10-12 05:39:53 +08:00
default-roles-permissions : setup -go -work start -docker ## Generates the Cypress and Playwright default_roles_permissions files from a live database.
2026-05-25 15:03:11 -03:00
$( GO) run $( GOFLAGS) ./scripts/default_permissions_generator \
2026-10-12 05:39:53 +08:00
-out ../e2e-tests/cypress/tests/support/api/default_roles_permissions.js \
-out ../e2e-tests/playwright/lib/src/server/default_roles_permissions.ts
.PHONY : default -feature -flags
default-feature-flags : setup -go -work ## Generates the Playwright default_feature_flags file from the model defaults.
$( GO) run $( GOFLAGS) ./scripts/default_feature_flags_generator \
-out ../e2e-tests/playwright/lib/src/server/default_feature_flags.ts
2026-05-25 15:03:11 -03:00
2026-07-10 13:22:50 -03:00
.PHONY : mocks
2025-09-04 15:46:18 -03:00
mocks : store -mocks filestore -mocks ldap -mocks plugin -mocks einterfaces -mocks searchengine -mocks sharedchannel -mocks misc -mocks email -mocks platform -mocks mmctl -mocks mocks -public cache -mocks
2022-07-05 18:39:31 +03:00
2026-07-10 13:22:50 -03:00
.PHONY : layers
2025-01-29 13:06:55 -07:00
layers : store -layers pluginapi
2022-07-05 18:39:31 +03:00
2026-07-10 13:22:50 -03:00
.PHONY : generated
2026-10-12 05:39:53 +08:00
generated : mocks layers gen -serialized migrations -extract build -templates mmctl -docs modules -tidy default -roles -permissions default -feature -flags ## Regenerate every committed generated asset checked by the check-generated CI job.
2022-07-05 18:39:31 +03:00
2026-07-10 13:22:50 -03:00
.PHONY : check -prereqs -enterprise
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
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
./scripts/prereq-check-enterprise.sh
endif
2026-07-10 13:22:50 -03:00
.PHONY : setup -go -work
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
2026-03-20 16:12:20 -03:00
ifneq ( $( SKIP_SETUP_GO_WORK ) ,true)
@set -e; \
if [ -f go.work ]; then cp -p go.work go.work.bak; fi; \
rm -f go.work; \
$( GO ) work init; \
$( GO ) work use .; \
$( GO ) work use ./public; \
if [ "$(BUILD_ENTERPRISE_READY)" = "true" ]; then \
$( GO ) work use $( BUILD_ENTERPRISE_DIR ) ; \
fi; \
if [ -f go.work.bak ] && cmp -s go.work go.work.bak; then \
mv go.work.bak go.work; \
else \
rm -f go.work.bak; \
echo "Created go.work file" ; \
fi
2023-05-10 13:07:02 -03:00
endif
2022-05-05 21:42:31 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : check -go -fix
2026-06-30 11:04:03 -03:00
check-go-fix : setup -go -work ## Check if go fix would modify any files.
$( GO) fix -diff ./...
2026-07-10 13:22:50 -03:00
.PHONY : check -style
2026-06-30 11:04:03 -03:00
check-style : plugin -checker vet golangci -lint check -go -fix ## Runs style/lint checks
2023-05-05 10:08:35 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : gotestsum
2023-06-15 15:27:52 -03:00
gotestsum :
2026-03-27 21:11:52 +01:00
$( GO) install gotest.tools/gotestsum@v1.13.0
2018-11-28 09:05:39 -05:00
2026-09-03 06:00:50 -03:00
.PHONY : install -ci -tools
install-ci-tools : gotestsum install -golangci -lint install -govet install -mockery install -mockgen install -morph install -msgp ## Install all tools required by CI
.PHONY : go -cache
go-cache : setup -go -work install -ci -tools ## Pre-warm Go module and build cache for CI
$( GO) mod download all
@( cd public && $( GO) mod download all)
$( GO) build ./...
@( cd public && $( GO) build ./...)
$( GO) test -run= ^$$ -count= 1 -short ./...
@( cd public && $( GO) test -run= ^$$ -count= 1 -short ./...)
2026-07-10 13:22:50 -03:00
.PHONY : test -compile
2026-03-20 16:12:20 -03:00
test-compile : setup -go -work 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
2026-07-10 13:22:50 -03:00
.PHONY : modules -tidy
2026-06-30 11:04:03 -03:00
modules-tidy : setup -go -work ## Tidy Go modules
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
2026-07-10 13:22:50 -03:00
.PHONY : test -server -pre
2025-03-11 11:44:42 -06:00
test-server-pre : check -prereqs -enterprise start -docker gotestsum golang -versions ## Runs tests.
2018-12-06 13:19:32 -05:00
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
@echo Running all tests
else
@echo Running only TE tests
endif
2021-03-22 23:11:50 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : test -server -race
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
ifeq ( $( IS_CI ) ,true)
2025-11-18 16:36:01 +01:00
GOMAXPROCS = 4 $( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- -race $( GOFLAGS) -timeout= 3h
2023-06-15 15:27:52 -03:00
else
2025-11-18 16:36:01 +01:00
$( GOBIN ) /gotestsum --rerun-fails = 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- -race $( GOFLAGS) -timeout= 3h
2023-06-15 15:27:52 -03:00
endif
2022-06-09 11:45:17 +02:00
ifneq ( $( IS_CI ) ,true)
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
endif
2021-03-22 23:11:50 +05:30
2026-07-10 13:22:50 -03:00
.PHONY : test -server
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
2025-05-30 05:58:26 -06:00
$( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( TE_PACKAGES) $( EE_PACKAGES) " -- $( GOFLAGS) -timeout= 90m $( COVERAGE_FLAG)
2022-06-09 11:45:17 +02:00
ifneq ( $( IS_CI ) ,true)
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
endif
2020-08-11 10:41:23 +02:00
2026-07-10 13:22:50 -03:00
.PHONY : test -server -ee
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
2026-04-10 11:15:07 -03:00
ES_PACKAGES = $( shell $( GO) list ./enterprise/elasticsearch/...)
2026-07-10 13:22:50 -03:00
.PHONY : test -server -elasticsearch
2026-04-10 11:15:07 -03:00
test-server-elasticsearch : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server-elasticsearch : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server-elasticsearch : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
test-server-elasticsearch : check -prereqs -enterprise start -docker gotestsum ## Runs Elasticsearch tests.
@echo Running only Elasticsearch tests
$( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( ES_PACKAGES) " -- $( GOFLAGS) -timeout= 20m
2026-05-22 12:37:50 -03:00
OS_PACKAGES = $( shell $( GO) list ./enterprise/elasticsearch/opensearch/...)
2026-07-10 13:22:50 -03:00
.PHONY : test -server -opensearch
2026-05-22 12:37:50 -03:00
test-server-opensearch : export GOTESTSUM_FORMAT := $( GOTESTSUM_FORMAT )
test-server-opensearch : export GOTESTSUM_JUNITFILE := $( GOTESTSUM_JUNITFILE )
test-server-opensearch : export GOTESTSUM_JSONFILE := $( GOTESTSUM_JSONFILE )
test-server-opensearch : check -prereqs -enterprise start -docker gotestsum ## Runs OpenSearch tests.
@echo Running only OpenSearch tests
$( GOBIN) /gotestsum --rerun-fails= 3 --packages= " $( OS_PACKAGES) " -- $( GOFLAGS) -timeout= 20m
2026-07-10 13:22:50 -03:00
.PHONY : test -server -quick
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
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
@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
else
@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
endif
2026-07-10 13:22:50 -03:00
.PHONY : internal -test -web -client
2026-03-20 16:12:20 -03:00
internal-test-web-client : setup -go -work ## 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
2026-07-10 13:22:50 -03:00
.PHONY : run -server -for -web -client -tests
2026-03-20 16:12:20 -03:00
run-server-for-web-client-tests : setup -go -work ## 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
2026-07-10 13:22:50 -03:00
.PHONY : test -client
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
2026-07-10 13:22:50 -03:00
.PHONY : 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
2026-07-10 13:22:50 -03:00
.PHONY : cover
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
2026-07-10 13:22:50 -03:00
.PHONY : test -data
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
2026-07-10 13:22:50 -03:00
.PHONY : inject -test -data
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
2026-08-11 10:28:58 -07:00
@echo Login with a regular account username = user-1 password = SampleUs@r-001
2018-03-23 20:32:10 +01:00
@echo ========================================================================
2018-01-31 16:32:18 -08:00
2026-07-10 13:22:50 -03:00
.PHONY : test -mmctl -unit
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 )
2025-08-29 12:01:12 -03:00
test-mmctl-unit : check -prereqs -enterprise 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
2026-07-10 13:22:50 -03:00
.PHONY : test -mmctl -e 2e
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 )
2025-08-29 12:01:12 -03:00
test-mmctl-e2e : check -prereqs -enterprise 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
2026-07-10 13:22:50 -03:00
.PHONY : test -mmctl
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 )
2025-08-29 12:01:12 -03:00
test-mmctl : check -prereqs -enterprise 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
2026-07-10 13:22:50 -03:00
.PHONY : test -mmctl -coverage
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 )
2025-08-29 12:01:12 -03:00
test-mmctl-coverage : check -prereqs -enterprise 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
2026-07-10 13:22:50 -03:00
.PHONY : validate -go -version
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
2026-07-10 13:22:50 -03:00
.PHONY : build -templates
2021-02-25 23:22:26 -05:00
build-templates : ## Compile all mjml email templates
cd $( TEMPLATES_DIR) && $( MAKE) build
2026-07-10 13:22:50 -03:00
.PHONY : run -server
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
2025-09-15 14:58:43 -04:00
ifeq ( $( MM_USE_PGVECTOR ) ,true)
@echo With pgvector PostgreSQL support enabled
endif
2016-03-18 12:46:57 -04:00
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
2026-07-10 13:22:50 -03:00
.PHONY : run -server -faketime
2026-04-04 20:30:36 -03:00
run-server-faketime : setup -go -work prepackaged -binaries validate -go -version start -docker client ## Starts the server with FAKETIME.
ifndef FAKETIME
$(error FAKETIME is not set. Usage : make run -server -faketime FAKETIME ="+30d ")
endif
@if [ "$$(uname)" = "Darwin" ]; then \
LIBFAKETIME = " $$ (brew --prefix libfaketime 2>/dev/null)/lib/faketime/libfaketime.1.dylib" ; \
else \
for p in /usr/lib/x86_64-linux-gnu/faketime /usr/lib/aarch64-linux-gnu/faketime /usr/lib/faketime /usr/lib64/faketime; do \
if [ -f " $$ p/libfaketime.so.1" ] ; then LIBFAKETIME = " $$ p/libfaketime.so.1" ; break; fi ; \
done ; \
fi ; \
[ -f " $$ LIBFAKETIME" ] || { echo "Error: libfaketime not found. Install it with your package manager." ; exit 1; } ; \
echo "Building mattermost..." ; \
$( GO) build $( GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' -o $( GOBIN) /mattermost-faketime $( PLATFORM_FILES) ; \
echo "Running mattermost with FAKETIME= $( FAKETIME) (libfaketime: $$ LIBFAKETIME)" ; \
mkdir -p $( BUILD_WEBAPP_DIR) /channels/dist/files; \
if [ " $$ (uname)" = "Darwin" ] ; then \
DYLD_INSERT_LIBRARIES = " $$ LIBFAKETIME" DYLD_FORCE_FLAT_NAMESPACE = 1 FAKETIME = " $( FAKETIME) " FAKETIME_NO_CACHE = 1 \
$( GOBIN) /mattermost-faketime $( RUN_IN_BACKGROUND) \
else \
LD_PRELOAD = " $$ LIBFAKETIME" FAKETIME = " $( FAKETIME) " FAKETIME_NO_CACHE = 1 \
$( GOBIN) /mattermost-faketime $( RUN_IN_BACKGROUND) \
fi
2026-07-10 13:22:50 -03:00
.PHONY : run -server -pgvector
2025-09-15 14:58:43 -04:00
run-server-pgvector : ## Starts the server with pgvector PostgreSQL image.
@MM_USE_PGVECTOR= true $( MAKE) run-server
2026-07-10 13:22:50 -03:00
.PHONY : debug -server
2026-03-20 16:12:20 -03:00
debug-server : setup -go -work 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
2026-07-10 13:22:50 -03:00
.PHONY : debug -server -headless
2026-03-20 16:12:20 -03:00
debug-server-headless : setup -go -work 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
2026-07-10 13:22:50 -03:00
.PHONY : run -node
2024-09-19 10:00:56 +02:00
run-node : export MM_SERVICESETTINGS_SITEURL =http ://localhost :8066
run-node : export MM_SERVICESETTINGS_LISTENADDRESS =:8066
run-node : export MM_SERVICESETTINGS_ENABLELOCALMODE =true
run-node : export MM_SERVICESETTINGS_LOCALMODESOCKETLOCATION =/var /tmp /mattermost_local_node .socket
run-node : export MM_SQLSETTINGS_DRIVERNAME =postgres
2026-08-21 00:18:06 +02:00
run-node : export MM_SQLSETTINGS_DATASOURCE =postgres ://mmuser :mostest_password @localhost /mattermost_node_test ?sslmode =disable &sslmode =disable &connect_timeout =10&binary_parameters =yes
2024-09-19 10:00:56 +02:00
2026-03-20 16:12:20 -03:00
run-node : setup -go -work start -docker ## Runs a shared channel node.
2024-09-19 10:00:56 +02:00
@echo Running mattermost node
$( GO) run $( GOFLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' $( PLATFORM_FILES) $( RUN_IN_BACKGROUND)
2026-07-10 13:22:50 -03:00
.PHONY : run -cli
2026-03-20 16:12:20 -03:00
run-cli : setup -go -work 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
2026-07-10 13:22:50 -03:00
.PHONY : run -client
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
2026-07-10 13:22:50 -03:00
.PHONY : run -client -fullmap
2023-03-22 17:22:27 -04:00
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
2026-07-10 13:22:50 -03:00
.PHONY : run
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
2026-07-10 13:22:50 -03:00
.PHONY : run -pgvector
2025-09-15 14:58:43 -04:00
run-pgvector : ## Runs the server and webapp with pgvector PostgreSQL image.
@MM_USE_PGVECTOR= true $( MAKE) run
2026-07-10 13:22:50 -03:00
.PHONY : run -fullmap
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
2026-07-10 13:22:50 -03:00
.PHONY : stop -server
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
ifeq ( $( 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
else
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
endif
2015-07-27 09:48:35 -04:00
2026-07-10 13:22:50 -03:00
.PHONY : stop -client
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
2026-07-10 13:22:50 -03:00
.PHONY : stop
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
2026-07-10 13:22:50 -03:00
.PHONY : restart
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
2026-07-10 13:22:50 -03:00
.PHONY : restart -server
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
2026-07-10 13:22:50 -03:00
.PHONY : restart -server -pgvector
2025-09-15 14:58:43 -04:00
restart-server-pgvector : ## Restarts the server with pgvector PostgreSQL image.
@MM_USE_PGVECTOR= true $( MAKE) restart-server
2026-07-10 13:22:50 -03:00
.PHONY : restart -haserver
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
2026-07-10 13:22:50 -03:00
.PHONY : restart -client
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
2026-07-10 13:22:50 -03:00
.PHONY : run -job -server
2026-03-20 16:12:20 -03:00
run-job-server : setup -go -work ## 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
2026-07-10 13:22:50 -03:00
.PHONY : config -ldap
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)
2024-07-24 11:02:47 +02:00
$( eval TMPDIR := $( shell mktemp -d))
2024-07-08 08:16:09 +02:00
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
2026-07-10 13:22:50 -03:00
.PHONY : config -saml
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
2024-07-24 11:02:47 +02:00
$( eval TMPDIR := $( shell mktemp -d))
2024-07-08 08:16:09 +02:00
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
2026-07-10 13:22:50 -03:00
.PHONY : config -openid
2024-07-08 08:16:09 +02:00
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)
2024-07-24 11:02:47 +02:00
$( eval TMPDIR := $( shell mktemp -d))
2024-07-08 08:16:09 +02:00
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
2026-07-10 13:22:50 -03:00
.PHONY : config -reset
2026-03-20 16:12:20 -03:00
config-reset : setup -go -work ## Resets the config/config.json file to the default production values.
2023-08-17 11:16:16 -03:00
@echo Resetting configuration to production default
2017-11-03 08:45:19 -07:00
rm -f config/config.json
2025-08-29 12:01:12 -03:00
OUTPUT_CONFIG = $( PWD) /config/config.json $( GO) run $( GOFLAGS) -tags production ./scripts/config_generator
2017-11-03 08:45:19 -07:00
2026-07-10 13:22:50 -03:00
.PHONY : diff -config
2019-08-29 22:44:13 +02:00
diff-config : ## Compares default configuration between two mattermost versions
@./scripts/diff-config.sh
2026-07-10 13:22:50 -03:00
.PHONY : clean
2026-03-20 16:12:20 -03:00
clean : setup -go -work 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
2026-07-10 13:22:50 -03:00
.PHONY : nuke
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
2026-07-10 13:22:50 -03:00
.PHONY : setup -mac
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
2026-07-10 13:22:50 -03:00
.PHONY : update -dependencies
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
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
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
endif
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
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
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
endif
2026-09-03 06:00:50 -03:00
.PHONY : install -govet
install-govet :
2026-04-01 10:24:22 -03:00
cd ../tools/mattermost-govet && $( GO) install .
2026-09-03 06:00:50 -03:00
.PHONY : vet
vet : setup -go -work install -govet ## Run mattermost go vet specific checks
2026-01-09 14:23:16 -04:00
$( GO) vet -vettool= $( GOBIN) /mattermost-govet \
-structuredLogging \
2026-08-18 19:09:41 -03:00
-mlogFieldNaming \
2026-01-09 14:23:16 -04:00
-inconsistentReceiverName \
-emptyStrCmp \
-tFatal \
-configtelemetry \
-errorAssertions \
-requestCtxNaming \
-license \
-inconsistentReceiverName.ignore= session_serial_gen.go,team_member_serial_gen.go,user_serial_gen.go,utils_serial_gen.go \
-noSelectStar \
2026-03-27 16:34:17 -03:00
-concurrentIndex \
-concurrentIndex.path= ./channels/db/migrations/ \
-concurrentIndex.minMigration= 166 \
2026-09-15 14:39:50 +02:00
-sortSlices \
2026-01-09 14:23:16 -04:00
./...
2025-09-15 10:53:28 -03:00
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
2022-06-09 11:45:17 +02:00
ifneq ( $( MM_NO_ENTERPRISE_LINT ) ,true)
2026-09-15 14:39:50 +02:00
$( GO ) vet -vettool = $( GOBIN) /mattermost-govet -structuredLogging -mlogFieldNaming -inconsistentReceiverName -emptyStrCmp -tFatal -configtelemetry -errorAssertions -requestCtxNaming -sortSlices -enterpriseLicense $( BUILD_ENTERPRISE_DIR) /...
2026-08-18 19:09:41 -03:00
endif
endif
.PHONY : vet -fix
vet-fix : setup -go -work ## Apply the suggested fixes from mattermost go vet checks
cd ../tools/mattermost-govet && $( GO) install .
$( GO) fix -fixtool= $( GOBIN) /mattermost-govet -mlogFieldNaming ./...
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
ifneq ( $( MM_NO_ENTERPRISE_LINT ) ,true)
$( GO ) fix -fixtool = $( GOBIN) /mattermost-govet -mlogFieldNaming $( BUILD_ENTERPRISE_DIR) /...
2022-06-09 11:45:17 +02:00
endif
2020-01-07 12:37:57 +01:00
endif
2017-02-09 13:39:15 -08:00
2026-07-10 13:22:50 -03:00
.PHONY : vet -api
2023-10-16 11:27:43 -03:00
vet-api : export GO := $( GO )
vet-api : export GOBIN := $( GOBIN )
vet-api : export ROOT := $( ROOT )
2026-10-30 15:43:28 -03:00
vet-api : setup -go -work install -govet ## Run mattermost go vet to verify api4 documentation
2023-10-16 11:27:43 -03:00
make -C ../api build
./scripts/vet-api-check.sh
2026-09-03 06:00:50 -03:00
.PHONY : install -msgp
install-msgp :
$( GO) install github.com/tinylib/msgp@v1.1.6
2026-07-10 13:22:50 -03:00
.PHONY : gen -serialized
2022-01-07 20:02:54 +05:30
gen-serialized : export LICENSE_HEADER :=$( LICENSE_HEADER )
2026-09-03 06:00:50 -03:00
gen-serialized : setup -go -work install -msgp ## Generates serialization methods for hot structs
2020-08-13 13:05:57 +05:30
# 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.
2024-09-16 15:44:32 -07:00
$( GOBIN) /msgp -file= ./public/model/utils.go -tests= false -o= ./public/model/utils_serial_gen.go
@echo " $$ LICENSE_HEADER" > tmp.go
@cat ./public/model/utils_serial_gen.go >> tmp.go
@mv tmp.go ./public/model/utils_serial_gen.go
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
2026-07-10 13:22:50 -03:00
.PHONY : todo
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
ifeq ( $( BUILD_ENTERPRISE_READY ) ,true)
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
endif
2017-12-20 14:49:45 -05:00
2026-07-10 13:22:50 -03:00
.PHONY : mmctl -build
2026-03-20 16:12:20 -03:00
mmctl-build : setup -go -work ## Compiles and generates the mmctl binary
2026-03-20 15:28:36 +02:00
$( GO) build $( GOFLAGS) -trimpath -ldflags '$(MMCTL_LDFLAGS)' -o bin/mmctl ./cmd/mmctl
2023-06-05 12:42:55 +02:00
2026-07-10 13:22:50 -03:00
.PHONY : mmctl -docs
2026-03-20 16:12:20 -03:00
mmctl-docs : setup -go -work ## Generate the mmctl docs
2023-06-05 12:42:55 +02:00
rm -rf ./cmd/mmctl/docs
2026-03-20 15:28:36 +02:00
cd ./cmd/mmctl && $( GO) run mmctl.go docs
2023-06-05 12:42:55 +02:00
2022-01-19 23:37:27 -05:00
## Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2026-07-10 13:22:50 -03:00
.PHONY : help
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
2026-07-10 13:22:50 -03:00
.PHONY : migrations -extract
2022-06-21 09:34:36 +03:00
migrations-extract :
@echo Listing migration files
2024-08-09 11:17:15 +02:00
@echo "# Autogenerated file to synchronize migrations sequence in the PR workflow, please do not edit." > channels/db/migrations/migrations.list
2023-03-22 17:22:27 -04:00
find channels/db/migrations -maxdepth 2 -mindepth 2 | sort >> channels/db/migrations/migrations.list
2023-08-16 10:09:11 +03:00
2026-07-13 05:49:33 -03:00
.PHONY : check -backport -migrations
check-backport-migrations : ## Fails if a Postgres migration added on top of the base branch was renumbered or renamed relative to master.
2026-06-29 12:23:08 -04:00
@echo "Checking for renumbered or renamed migrations"
2026-07-13 05:49:33 -03:00
./scripts/check_backport_migrations.sh
2026-06-29 12:23:08 -04:00
2026-07-10 13:22:50 -03:00
.PHONY : test -local -filestore
2026-03-20 16:12:20 -03:00
test-local-filestore : setup -go -work # Run tests for local filestore
2025-02-19 10:18:07 +01:00
$( GO) test ./platform/shared/filestore -run '^TestLocalFileBackend' -v