-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (39 loc) · 1.18 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
APP_PATH:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SCRIPTS_PATH:=$(APP_PATH)/scripts
.PHONY: setup fmt lint test mocks test_coverage tidy check docker_up docker_down
GO_PKGS := $(shell go list -f {{.Dir}} ./...)
# 初始化环境
setup:
@echo "初始化开发环境......"
@find "$(SCRIPTS_PATH)" -type f -name '*.sh' -exec chmod +x {} \;
@sh ${SCRIPTS_PATH}/setup.sh
@make tidy
# 代码风格
fmt:
@sh ${SCRIPTS_PATH}/fmt.sh
# 静态扫描
lint:
@golangci-lint run -c .golangci.yml
test:
@go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS)
test_coverage:
@go test -race -v $(GO_FLAGS) -count=1 -coverprofile=coverage.out -covermode=atomic $(GO_PKGS)
@go tool cover -html coverage.out
mocks:
@go generate ./...
# 依赖清理
tidy:
@go mod tidy -v
check:
@echo "整理项目依赖中......"
@$(MAKE) --no-print-directory tidy
@echo "代码风格检查中......"
@$(MAKE) --no-print-directory fmt
@echo "代码静态扫描中......"
@$(MAKE) lint
# 启动本地研发 docker 依赖
docker_up:
docker-compose -f scripts/docker/docker-compose.yml up -d
# 停止本地研发 docker
docker_down:
docker-compose -f scripts/docker/docker-compose.yml down -v