forked from romie-gr/romie
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (59 loc) · 1.86 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Global variables used later
NAME=romie
GOCMD=LC_ALL=C go
TIMEOUT=5
# go tools
export PATH := ./bin:$(PATH)
export GO111MODULE := on
export GOPROXY = https://proxy.golang.org,direct
# go source files
SRC = $(shell find . -type f -name "*.go")
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD-`pwd`})
.PHONY: all build setup fmt test cover lint clean todo run serve help
## all: Default target, now is build
all: build
## build: Builds the binary
build: fmt
@echo "Building..."
@$(GOCMD) build -o ${NAME}
## setup: Runs mod download and generate
setup:
@echo "Downloading tools and dependencies..."
@$(GOCMD) mod download -x
@$(GOCMD) generate -v ./...
## fmt: Runs go goimports and gofmt
fmt: setup
@echo "Checking the imports..."
@$(GOCMD)imports -w ${SRC}
@echo "Formating the go files..."
@$(GOCMD)fmt -w -s ${SRC}
## test: Runs the tests with coverage
test:
@echo "Running tests..."
@$(GOCMD) test -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... -run . -timeout $(TIMEOUT)m
## cover: Runs all tests and opens the coverage report in the browser
cover: test
@$(GOCMD) tool cover -html=coverage.txt
## lint: Runs golangci-lint (configuration at .golangci.yml) and misspell
lint: setup
@echo "Running linters..."
@golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 ./...
@misspell ./...
## clean: Runs go clean
clean:
@echo "Cleaning..."
@$(GOCMD) clean
## todo: Shows all TODO strings with line numbers
todo:
@grep -I -R -n TODO * --exclude=Makefile
## run: Runs go run
run: build
@$(GOCMD) run ${TARGET}
## serve: Serves the documentation locally using Docker
serve:
@docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material
## help: Prints this help message
help:
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'