This repository has been archived by the owner on Jan 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
218 lines (185 loc) · 6.4 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
TEMPORALVERSION=`git describe --tags`
TEMPORALDEVFLAGS=-config ./testenv/config.json -db.no_ssl -dev
IPFSVERSION=v0.4.23
TESTKEYNAME=admin-key
all: check install
# Build temporal if binary is not already present
temporal:
@make cli
# List all commands
.PHONY: ls
ls:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
# Installs Temporal to GOBIN
.PHONY: install
install: setup cli
@echo "=================== installing Temporal CLI ==================="
sudo cp ./temporal /bin/temporal
/bin/temporal -config ${HOME}/temporal-config.json init
@echo "=================== done ==================="
# Run simple checks
.PHONY: check
check:
@echo "=================== running checks ==================="
git submodule update --init
go vet ./...
@echo "Executing dry run of tests..."
@go test -run xxxx ./...
@echo "=================== done ==================="
# Build Temporal
.PHONY: cli
cli:
@echo "=================== building Temporal CLI ==================="
rm -f temporal
go build -ldflags "-X main.Version=$(TEMPORALVERSION)" ./cmd/temporal
@echo "=================== done ==================="
# Static analysis and style checks
.PHONY: lint
lint:
go fmt ./...
golint $(GOFILES)
# Shellcheck disabled for now - too much to fix
# shellcheck **/*.sh(e[' [[ ! `echo "$REPLY" | grep "vendor/" ` ]]'])
.PHONY: postgres
WAIT=3
postgres:
( cd testenv ; make postgres )
# Set up test environment
.PHONY: testenv
WAIT=3
testenv:
@echo "=================== preparing test env ==================="
( cd testenv ; make testenv )
@echo "Running migrations..."
go run cmd/temporal/main.go -config ./testenv/config.json --db.no_ssl migrate
make api-user
make api-admin
@echo "=================== done ==================="
# Shut down testenv
.PHONY: stop-testenv
stop-testenv:
@echo "=================== shutting down test env ==================="
( cd testenv ; make stop-testenv )
@echo "=================== done ==================="
# Execute short tests
.PHONY: test
test: check
@echo "=================== executing short tests ==================="
go test -race -cover -short ./...
@echo "=================== done ==================="
# Execute all tests
.PHONY: test
test-all: check
@echo "=================== executing all tests ==================="
go test -race -cover ./...
@echo "=================== done ==================="
# Remove assets
.PHONY: clean
clean: stop-testenv
@echo "=================== cleaning up temp assets ==================="
@echo "Removing binary..."
@rm -f temporal
( cd testenv ; make clean )
@echo "=================== done ==================="
# Rebuild generate code
COUNTERFEITER=go run github.com/maxbrunsfeld/counterfeiter/v6
.PHONY: gen
gen:
@echo "=================== regenerating code ==================="
$(COUNTERFEITER) -o ./mocks/orchestrator.mock.go \
github.com/RTradeLtd/grpc/nexus.ServiceClient
$(COUNTERFEITER) -o ./mocks/lens.mock.go \
github.com/RTradeLtd/grpc/lensv2.LensV2Client
$(COUNTERFEITER) -o ./mocks/eth.mock.go \
github.com/RTradeLtd/grpc/pay.SignerClient
$(COUNTERFEITER) -o ./mocks/bch.mock.go \
github.com/gcash/bchwallet/rpc/walletrpc.WalletServiceClient
$(COUNTERFEITER) -o ./mocks/rtfs.mock.go \
github.com/RTradeLtd/rtfs/v2.Manager
@echo "=================== done ==================="
# Rebuild vendored dependencies
.PHONY: vendor
vendor:
@echo "=================== generating dependencies ==================="
GO111MODULE=on go mod vendor
@echo "=================== done ==================="
# Build CLI binary release
.PHONY: release-cli
release-cli:
@echo "=================== cross-compiling CLI ==================="
@bash .scripts/cli.sh
@echo "=================== done ==================="
# Build docker release
.PHONY: docker
docker:
@echo "=================== building docker image ==================="
@docker build --build-arg TEMPORALVERSION=$(TEMPORALVERSION) \
-t rtradetech/temporal:$(TEMPORALVERSION) .
@echo "=================== done ==================="
# Build docker release and push to repository
.PHONY: release-docker
release-docker: docker
@echo "=================== building docker image ==================="
@docker push rtradetech/temporal:$(TEMPORALVERSION)
@echo "=================== done ==================="
# download and setup gvisor runtime
.PHONY: gvisor
gvisor:
wget https://storage.googleapis.com/gvisor/releases/nightly/latest/runsc -O tmp/runsc
wget https://storage.googleapis.com/gvisor/releases/nightly/latest/runsc.sha512 -O tmp/runsc.sha512
sha512sum -c tmp/runsc.sha512
chmod a+x tmp/runsc
sudo mv tmp/runsc /usr/local/bin
sudo cp setup/configs/docker/daemon_passthrough.json /etc/docker/daemon.json
sudo systemctl restart docker
# Run development API
.PHONY: api
api:
go run cmd/temporal/main.go $(TEMPORALDEVFLAGS) api
.PHONY: krab
krab:
go run cmd/temporal/main.go $(TEMPORALDEVFLAGS) krab server
USER=testuser
PASSWORD=admin
.PHONY: api-user
api-user:
go run cmd/temporal/main.go $(TEMPORALDEVFLAGS) user $(USER) $(PASSWORD) $(EMAIL)
.PHONY: api-admin
api-admin:
go run cmd/temporal/main.go $(TEMPORALDEVFLAGS) admin $(USER)
.PHONY: setup
setup:
git submodule update --init
go mod download
( cd testenv ; go mod download )
verifiers: staticcheck
staticcheck:
@echo "Running $@ check"
@GO111MODULE=on ${GOPATH}/bin/staticcheck ./...
# run standard go tooling for better rcode hygiene
.PHONY: tidy
tidy: imports fmt
go vet ./...
golint ./...
# automatically add missing imports
.PHONY: imports
imports:
find . -type f -name '*.go' -exec goimports -w {} \;
# format code and simplify if possible
.PHONY: fmt
fmt:
find . -type f -name '*.go' -exec gofmt -s -w {} \;
# runs the
.PHONY: run-swarm
run-swarm:
docker run --network host --name temporal_swarm -d -it -v ${PWD}/swarmtest/datadir:/data \
-v ${PWD}/swarmtest/passwordfile:/password \
ethersphere/swarm \
--datadir /data \
--password /password \
--debug \
--verbosity 4
.PHONY: stop-swarm
stop-swarm:
docker stop temporal_swarm && docker rm temporal_swarm