This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (40 loc) · 1.67 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CURRENT_DIR=$(shell pwd)
BIN_DIR=${CURRENT_DIR}/bin
PACKAGE=github.com/one-zero-eight/Search/cmd/app
GOLANGCI_LINT_VERSION:=$(shell golangci-lint --version 2> /dev/null)
GOOSE_VERSION:=$(shell goose --version 2> /dev/null)
# Some colors for formatting
CLR_GREEN=\033[32m
##@ Common
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
#
# Source: https://www.padok.fr/en/blog/beautiful-makefile-awk
.PHONY: help
help: ## display this message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: build
build: ## build application
go build -o ${BIN_DIR}/app ${PACKAGE}
.PHONY: run
run: build ## run application
go run ${PACKAGE}
.PHONY: lint
lint: golangci-lint-installed ## run linters
@golangci-lint run && echo "${CLR_GREEN}ok"
# Helpers
.PHONY: golangci-lint-installed
golangci-lint-installed:
ifndef GOLANGCI_LINT_VERSION
@echo "golangci-lint is not installed (https://golangci-lint.run/usage/install/)" && exit 1
endif
.PHONY: gooose-installed
goose-installed:
ifndef GOOSE_VERSION
@echo "goose is not installed (https://pressly.github.io/goose/)" && exit 1
endif