-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (37 loc) · 1.07 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
SHELL = /bin/bash
CONTRACT_URL=https://raw.githubusercontent.com/liuzhaomax/maxblog-devops/main/contracts/user.yaml
CONTRACT_PATH=../spec/user.yaml
BUILT_FILE=bin/main
TEST_INCLUSION=$(shell go list ./... | grep -Ewv 'main|test|internal|src/router|src/dataAPI/handler')
API_ENV=local
SCENARIO=all
# 读取contract
spec:
go test -v ./script -run TestGetContract -url=$(CONTRACT_URL) -path=$(CONTRACT_PATH)
# 打包
build:
go build -o $(BUILT_FILE) main/main.go
# 依赖注入
wire:
wire ./internal/app
# 运行
run:
go run main/main.go -c environment/config/dev.yaml
# 语法检查
# vendor确保lint不会启用下载,不然在ci过程中会timeout
lint:
go mod tidy
go mod vendor
golangci-lint run -v -c ./.golangci.yml ./...
# 单元测试
unit:
go test -v -timeout 1000s -covermode=atomic -coverpkg=./... -coverprofile=unit_test.out $(TEST_INCLUSION)
go tool cover -html=unit_test.out
# 打测试桩
stub:
go test ./test/imposter/imposter_test.go -run TestUpdateImposter
# 接口测试
api:
go test -v -tags $(SCENARIO) ./test -args -env=$(ENV)
.PHONY: spec
.PHONY: stub