-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
61 lines (46 loc) · 1.56 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
export GOPATH ?= $(shell go env GOPATH)
export GO111MODULE ?= on
BIN_DIR = bin
APPNAME = app
LDFLAGS ?=
COVERPROFILE ?= coverage.txt
#.DEFAULT_GOAL := all
.PHONY: all
all: build
.PHONY: mod
mod:
go mod download
.PHONY: clean
clean: ## run all cleanup tasks
go clean ./...
rm -f $(COVERPROFILE)
rm -rf $(BIN_DIR)
golangci: ## install golangci-linter
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${BIN_DIR} v1.21.0
.PHONY: install_deps
install_deps: golangci ## install necessary dependencies
.PHONY: build
build: ## build all applications
go build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(APPNAME) cmd/app/*.go
go build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/migrate cmd/migration/*.go
.PHONY: generate
generate: ## generate mocks
go generate ./...
.PHONY: unit
unit: ## run unit tests
go test -v ./... -count 10 -race
.PHONY: test
test: unit ## run unit and integrations tests with race
go test -v ./... -tags integration -count 10 -race --failfast
.PHONY: test-with-coverage
test-with-coverage: ## run tests with coverage mode
go test -v ./... -tags integration -count 1 --coverprofile=$(COVERPROFILE) --covermode=count
.PHONY: migrate
migrate: ## do migration
go run ./cmd/migration/main.go -dir scripts/migrations -init
.PHONY: lint
lint: golangci ## run linter
${BIN_DIR}/golangci-lint --color=always run ./... -v --timeout 5m
.PHONY: help
help: ## display help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'