-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (127 loc) · 4.61 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
PACKAGE = syncer
IMPORT = github.com/warp-contracts/syncer
GOROOT = $(CURDIR)/.gopath~
GOPATH = $(CURDIR)/.gopath~
BIN = $(GOPATH)/bin
BASE = $(GOPATH)/src/$(PACKAGE)
PATH := bin:$(PATH)
GO = go
VERSION ?= $(shell git describe --tags --always --match=v* 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo v0)
DATE ?= $(shell date +%FT%T%z)
export GOPATH
# Display utils
V = 0
Q = $(if $(filter 1,$V),,@)
M = $(shell printf "\033[34;1m▶\033[0m")
# Default target
.PHONY: all
all: build lint | $(BASE); $(info $(M) built and lint everything!) @
# Setup
$(BASE): ; $(info $(M) setting GOPATH…)
@mkdir -p $(dir $@)
@ln -sf $(CURDIR) $@
# External tools
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) installing $(REPOSITORY)…)
$Q tmp=$$(mktemp -d); \
env GO111MODULE=on GOPATH=$$tmp GOBIN=$(BIN) $(GO) install $(REPOSITORY) \
|| ret=$$?; \
exit $$ret
GOLANGCILINT = $(BIN)/golangci-lint
$(BIN)/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.55.2
GENTOOL = $(BIN)/gentool
$(BIN)/gentool: REPOSITORY=gorm.io/gen/tools/gentool@latest
# Build targets
.PHONY: build
build: | $(BASE); $(info $(M) building executable…) @
$Q cd $(BASE) && $(GO) build \
-tags release \
-ldflags="-s -w -X $(IMPORT)/src/utils/build_info.Version=$(VERSION) -X $(IMPORT)/src/utils/build_info.BuildDate=$(DATE)" \
-o bin/$(PACKAGE) main.go
.PHONY: build-race
build-race: | $(BASE); $(info $(M) building executable…) @
$Q cd $(BASE) && $(GO) build -race \
-tags release \
-ldflags="-s -w -X $(IMPORT)/src/utils/build_info.Version=$(VERSION) -X $(IMPORT)/src/utils/build_info.BuildDate=$(DATE)" \
-o bin/$(PACKAGE) main.go
.PHONY: run
run: build-race | ; $(info $(M) starting app with default params…)
bin/$(PACKAGE) sync
.PHONY: contract
contract: build-race | ; $(info $(M) starting synchronizing contracts with default params…)
bin/$(PACKAGE) contract --start 1289644 --stop 1289645
.PHONY: bundle
bundle: build-race | ; $(info $(M) starting bundling with default params…)
bin/$(PACKAGE) bundle
.PHONY: check
check: build-race | ; $(info $(M) starting checking with default params…)
bin/$(PACKAGE) check
.PHONY: forward
forward: build-race | ; $(info $(M) starting forwarding with default params…)
bin/$(PACKAGE) forward
.PHONY: relay
relay: build-race | ; $(info $(M) starting relaying with default params…)
bin/$(PACKAGE) relay
.PHONY: gateway
gateway: build-race | ; $(info $(M) starting relaying with default params…)
bin/$(PACKAGE) gateway
.PHONY: load
load: build-race | ; $(info $(M) starting loading with default params…)
bin/$(PACKAGE) load
.PHONY: send
send: build-race | ; $(info $(M) starting sending with default params…)
bin/$(PACKAGE) send
.PHONY: evolve
evolve: build-race | ; $(info $(M) starting evolve with default params…)
bin/$(PACKAGE) evolve
.PHONY: warpy_sync
warpy_sync: build-race | ; $(info $(M) starting warpy_sync with default params…)
bin/$(PACKAGE) warpy_sync
.PHONY: interact
interact: build-race | ; $(info $(M) starting interact with default params…)
bin/$(PACKAGE) interact
.PHONY: lint
lint: $(GOLANGCILINT) | $(BASE) ; $(info $(M) running golangci-lint) @
$Q $(GOLANGCILINT) run
.PHONY: generate
generate: $(GENTOOL) | $(BASE) ; $(info $(M) generating model from the database) @
$Q $(GENTOOL) -db postgres -dsn "host=127.0.0.1 user=postgres password=postgres dbname=warp port=7654 sslmode=disable" -tables "interactions"
.PHONY: test
test:
$(GO) test ./...
.PHONY: version
version:
$Q echo -n $(VERSION) > .version
.PHONY: clean
clean:
rm -rf bin/$(PACKAGE) .gopath~
.PHONY: logs-sync
logs-sync:
kubectl logs -f -n syncer-prod deployment/syncer-prod-warp-syncer -c syncer
.PHONY: logs-bundler
logs-bundler:
kubectl logs -f -n syncer-prod deployment/syncer-prod-warp-syncer -c bundler
.PHONY: logs-check
logs-check:
kubectl logs -f -n syncer-prod deployment/syncer-prod-warp-syncer -c checker
.PHONY: health
health:
curl -s http://localhost:3333/v1/health | jq
.PHONY: docker-build
docker-build: all | ; $(info $(M) building docker container) @
$(GO) mod vendor
DOCKER_BUILDKIT=0 docker build -t "warpredstone/syncer:latest" .
DOCKER_BUILDKIT=0 docker build -t "warpredstone/syncer:$(VERSION)" .
rm -rf vendor
.PHONY: docker-push
docker-push: all | ; $(info $(M) building docker container) @
$(GO) mod vendor
docker login
DOCKER_BUILDKIT=0 TAG=$(VERSION) docker buildx bake -f docker-bake.hcl --push
rm -rf vendor
.PHONY: docker-run
docker-run: docker-build | ; $(info $(M) running docker container) @
docker compose --profile syncer up syncer