forked from meoying/dbproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (54 loc) · 1.46 KB
/
Makefile
File metadata and controls
67 lines (54 loc) · 1.46 KB
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
.PHONY: setup
setup:
@sh ./.script/setup.sh
.PHONY: tidy
tidy:
@go mod tidy -v
.PHONY: fmt
fmt:
@sh ./.script/fmt.sh
.PHONY: lint
lint:
@golangci-lint run -c ./.script/.golangci.yml
.PHONY: check
check:
@$(MAKE) --no-print-directory tidy
@$(MAKE) --no-print-directory fmt
@$(MAKE) --no-print-directory lint
# 单元测试
.PHONY: ut
ut:
@echo "运行单元测试中......"
@go test -race -failfast -count=1 ./...
# e2e 测试
.PHONY: e2e
e2e:
@echo "运行集成测试中......"
@sh ./.script/integrate_test.sh
.PHONY: e2e_up
e2e_up:
docker compose -p dbproxy -f .script/integration_test_compose.yml up -d
.PHONY: e2e_down
e2e_down:
docker compose -p dbproxy -f .script/integration_test_compose.yml down -v
.PHONY: test
test:
@make ut
@make e2e
# 定义镜像变量
IMAGE_VERSION ?= v0.5
IMAGE_NAME = flycash/dbproxy:dbproxy-$(IMAGE_VERSION)
.PHONY: build_docker_image
build_docker_image:
@docker build --progress plain -t $(IMAGE_NAME) -f ./Dockerfile .
@make update_compose_file
.PHONY: update_compose_file
update_compose_file:
@sed -i.bak -e "/dbproxy-forward:/,/image:/s|image:.*|image: $(IMAGE_NAME)|" \
-e "/dbproxy-sharding:/,/image:/s|image:.*|image: $(IMAGE_NAME)|" \
./.script/integration_test_compose.yml
@rm ./.script/integration_test_compose.yml.bak # 删除备份文件
.PHONY: push_docker_image
push_docker_image:
@echo "上传镜像 $(IMAGE_NAME) 中.....需要先执行docker login"
@docker push $(IMAGE_NAME)