fix: make template build, lint and test cleanly out of the box

This commit is contained in:
2026-09-25 09:05:40 +03:00
parent f3452876da
commit f0e09ef8c9
24 changed files with 128 additions and 244 deletions
+6 -10
View File
@@ -10,11 +10,10 @@ MM_UTILITIES_DIR ?= ../mattermost-utilities
DLV_DEBUG_PORT := 2346
DEFAULT_GOOS := $(shell go env GOOS)
DEFAULT_GOARCH := $(shell go env GOARCH)
SANS_RESTAPITEST = $(shell go list ./... | grep -v 'git.wilix.dev/loop/loop-plugin-apps/test/restapitest' | sed -e 's/git.wilix.dev\/loop\/loop-plugin-apps\//.\//g')
ifneq (,$(wildcard ./.env))
include .env
export $(shell sed 's/=.*//' .env)
export $(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env)
endif
export GO111MODULE=on
@@ -39,8 +38,8 @@ endif
# ====================================================================================
# Used for semver bumping
PROTECTED_BRANCH := master
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`)
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags)
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url` 2>/dev/null)
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION))))
MAJOR := $(word 1,$(VERSION_PARTS))
MINOR := $(word 2,$(VERSION_PARTS))
@@ -159,7 +158,7 @@ apply:
.PHONY: deps
deps:
@$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
@$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.2
@$(GO) install github.com/nicksnyder/go-i18n/v2/goi18n@v2.2.0
## Runs eslint and golangci-lint
@@ -318,7 +317,7 @@ detach: setup-attach
.PHONY: test
test: webapp/node_modules
ifneq ($(HAS_SERVER),)
$(GO) test -v $(GO_TEST_FLAGS) $(SANS_RESTAPITEST)
$(GO) test -v $(GO_TEST_FLAGS) ./...
endif
ifneq ($(HAS_WEBAPP),)
cd webapp && $(NPM) run test;
@@ -328,7 +327,7 @@ endif
.PHONY: coverage
coverage: webapp/node_modules
ifneq ($(HAS_SERVER),)
$(GO) test $(GO_TEST_FLAGS) -coverprofile=server/coverage.txt $(SANS_RESTAPITEST)
$(GO) test $(GO_TEST_FLAGS) -coverprofile=server/coverage.txt ./...
$(GO) tool cover -html=server/coverage.txt
endif
@@ -382,9 +381,6 @@ ifneq ($(HAS_WEBAPP),)
rm -fr webapp/node_modules
endif
rm -fr build/bin/
rm -fr test/restapitest/mattermost.log
rm -fr test/restapitest/notifications.log
rm -fr test/restapitest/data/
# Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: