forked from wal-g/wal-g
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (91 loc) · 4.67 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
MAIN_PG_PATH := main/pg
MAIN_MYSQL_PATH := main/mysql
MAIN_REDIS_PATH := main/redis
MAIN_MONGO_PATH := main/mongo
DOCKER_COMMON := golang ubuntu s3
CMD_FILES = $(wildcard wal-g/*.go)
PKG_FILES = $(wildcard internal/**/*.go internal/**/**/*.go internal/*.go)
TEST_FILES = $(wildcard test/*.go testtools/*.go)
PKG := github.com/wal-g/wal-g
COVERAGE_FILE := coverage.out
.PHONY: unittest fmt lint install clean
ifdef GOTAGS
override GOTAGS := -tags $(GOTAGS)
endif
test: install deps lint unittest pg_build mysql_build redis_build mongo_build unlink_brotli pg_integration_test mysql_integration_test redis_integration_test mongo_integration_test
pg_test: install deps pg_build lint unittest unlink_brotli pg_integration_test
pg_build: $(CMD_FILES) $(PKG_FILES)
(cd $(MAIN_PG_PATH) && go build -o wal-g $(GOTAGS) -ldflags "-s -w -X github.com/wal-g/wal-g/cmd.BuildDate=`date -u +%Y.%m.%d_%H:%M:%S` -X github.com/wal-g/wal-g/cmd.GitRevision=`git rev-parse --short HEAD` -X github.com/wal-g/wal-g/cmd.WalgVersion=`git tag -l --points-at HEAD`")
pg_int_tests_only:
docker-compose build pg_tests
docker-compose up --exit-code-from pg_tests pg_tests
pg_integration_test:
docker-compose build $(DOCKER_COMMON) pg pg_tests
docker-compose up --exit-code-from pg_tests pg_tests
pg_clean:
(cd $(MAIN_PG_PATH) && go clean)
./cleanup.sh
pg_install: pg_build
mv $(MAIN_PG_PATH)/wal-g $(GOBIN)/wal-g
mysql_test: install deps mysql_build lint unittest unlink_brotli mysql_integration_test
mysql_build: $(CMD_FILES) $(PKG_FILES)
(cd $(MAIN_MYSQL_PATH) && go build -o wal-g $(GOTAGS) -ldflags "-s -w -X github.com/wal-g/wal-g/cmd.BuildDate=`date -u +%Y.%m.%d_%H:%M:%S` -X github.com/wal-g/wal-g/cmd.GitRevision=`git rev-parse --short HEAD` -X github.com/wal-g/wal-g/cmd.WalgVersion=`git tag -l --points-at HEAD`")
mysql_integration_test:
docker-compose build $(DOCKER_COMMON) mysql mysql_tests
docker-compose up --exit-code-from mysql_tests mysql_tests
mysql_clean:
(cd $(MAIN_MYSQL_PATH) && go clean)
./cleanup.sh
mysql_install: mysql_build
mv $(MAIN_MYSQL_PATH)/wal-g $(GOBIN)/wal-g
mongo_test: install deps mongo_build lint unittest unlink_brotli mongo_integration_test
mongo_build: $(CMD_FILES) $(PKG_FILES)
(cd $(MAIN_MONGO_PATH) && go build -o wal-g $(GOTAGS) -ldflags "-s -w -X github.com/wal-g/wal-g/cmd.BuildDate=`date -u +%Y.%m.%d_%H:%M:%S` -X github.com/wal-g/wal-g/cmd.GitRevision=`git rev-parse --short HEAD` -X github.com/wal-g/wal-g/cmd.WalgVersion=`git tag -l --points-at HEAD`")
mongo_install: mongo_build
mv $(MAIN_MONGO_PATH)/wal-g $(GOBIN)/wal-g
mongo_integration_test:
docker-compose build $(DOCKER_COMMON) mongo mongo_tests
docker-compose up --exit-code-from mongo_tests mongo_tests
redis_test: install deps redis_build lint unittest unlink_brotli redis_integration_test
redis_build: $(CMD_FILES) $(PKG_FILES)
(cd $(MAIN_REDIS_PATH) && go build -o wal-g $(GOTAGS) -ldflags "-s -w -X github.com/wal-g/wal-g/cmd.BuildDate=`date -u +%Y.%m.%d_%H:%M:%S` -X github.com/wal-g/wal-g/cmd.GitRevision=`git rev-parse --short HEAD` -X github.com/wal-g/wal-g/cmd.WalgVersion=`git tag -l --points-at HEAD`")
redis_integration_test:
docker-compose build $(DOCKER_COMMON) redis redis_tests
docker-compose up --exit-code-from redis_tests redis_tests
redis_clean:
(cd $(MAIN_REDIS_PATH) && go clean)
./cleanup.sh
redis_install: redis_build
mv $(MAIN_REDIS_PATH)/wal-g $(GOBIN)/wal-g
unittest:
go list ./... | grep -Ev 'vendor|submodules|tmp' | xargs go vet
go test -v $(TEST_MODIFIER) ./internal/
go test -v $(TEST_MODIFIER) ./internal/compression/
go test -v $(TEST_MODIFIER) ./internal/crypto/openpgp/
go test -v $(TEST_MODIFIER) ./internal/databases/mysql
go test -v $(TEST_MODIFIER) ./internal/storages/azure/
go test -v $(TEST_MODIFIER) ./internal/storages/fs/
go test -v $(TEST_MODIFIER) ./internal/storages/gcs/
go test -v $(TEST_MODIFIER) ./internal/storages/s3/
go test -v $(TEST_MODIFIER) ./internal/storages/storage
go test -v $(TEST_MODIFIER) ./internal/storages/swift/
go test -v $(TEST_MODIFIER) ./internal/walparser/
go test -v $(TEST_MODIFIER) ./utility
coverage:
go list ./... | grep -Ev 'vendor|submodules|tmp' | xargs go test -v $(TEST_MODIFIER) -coverprofile=$(COVERAGE_FILE) | grep -v 'no test files'
go tool cover -html=$(COVERAGE_FILE)
fmt: $(CMD_FILES) $(PKG_FILES) $(TEST_FILES)
gofmt -s -w $(CMD_FILES) $(PKG_FILES) $(TEST_FILES)
lint: $(CMD_FILES) $(PKG_FILES) $(TEST_FILES)
go list ./... | grep -Ev 'vendor|submodules|tmp' | xargs golint
deps:
git submodule update --init
dep ensure
./link_brotli.sh
install:
go get -u github.com/golang/dep/cmd/dep
go get -u golang.org/x/lint/golint
unlink_brotli:
rm -rf vendor/github.com/google/brotli/*
mv tmp/* vendor/github.com/google/brotli/
rm -rf tmp/