-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
326 lines (248 loc) · 9.18 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
SHELL=/usr/bin/env bash
GO_BUILD_IMAGE?=golang:1.22.7
PG_IMAGE?=postgres:10
REDIS_IMAGE?=redis:6
LILY_IMAGE_NAME?=filecoin/lily
# LILY_VERSION is the nearest tag plus number of commits and short form of
# most recent commit since the tag, if any. It may be overriden by the environment.
LILY_VERSION?=$(shell git describe --always --tag --dirty)
docker_sanitized_lily_version=$(shell echo ${LILY_VERSION} | sed 's:/:-:g')
unexport GOFLAGS
CLEAN:=
BINS:=
GOFLAGS:=
.PHONY: all
all: build
## FFI
FFI_PATH:=extern/filecoin-ffi/
FFI_DEPS:=.install-filcrypto
FFI_DEPS:=$(addprefix $(FFI_PATH),$(FFI_DEPS))
$(FFI_DEPS): build/.filecoin-install ;
build/.filecoin-install: $(FFI_PATH)
$(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%)
@touch $@
MODULES+=$(FFI_PATH)
BUILD_DEPS+=build/.filecoin-install
CLEAN+=build/.filecoin-install
ffi-version-check:
@[[ "$$(awk '/const Version/{print $$5}' extern/filecoin-ffi/version.go)" -eq 3 ]] || (echo "FFI version mismatch, update submodules"; exit 1)
BUILD_DEPS+=ffi-version-check
.PHONY: ffi-version-check
$(MODULES): build/.update-modules ;
# dummy file that marks the last time modules were updated
build/.update-modules:
git submodule update --init --recursive
touch $@
CLEAN+=build/.update-modules
ldflags=-X=github.com/filecoin-project/lily/version.GitVersion=$(LILY_VERSION)
ifneq ($(strip $(LDFLAGS)),)
ldflags+=-extldflags=$(LDFLAGS)
endif
GOFLAGS+=-ldflags="$(ldflags)"
.PHONY: build
build: deps lily
.PHONY: deps
deps: $(BUILD_DEPS)
# test starts dependencies and runs all tests
.PHONY: test
test: testfull
.PHONY: dockerup
dockerup:
docker-compose up -d
.PHONY: dockerdown
dockerdown:
docker-compose down
# testfull runs all tests
.PHONY: testfull
testfull: build
docker-compose up -d
sleep 2
LILY_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" ./lily migrate --latest
-TZ= PGSSLMODE=disable LILY_TEST_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" go test ./...
docker-compose down
# testshort runs tests that don't require external dependencies such as postgres or redis
.PHONY: testshort
testshort:
go test -short ./...
.PHONY: lily
lily:
rm -f lily
go build $(GOFLAGS) -o lily -mod=readonly .
BINS+=lily
ifeq ($(shell uname -s), Darwin)
export CGO_ENABLED=1
ifeq ($(shell uname -m), arm64)
export GOARCH=arm64
export LIBRARY_PATH=/opt/homebrew/lib
export FFI_BUILD_FROM_SOURCE=1
endif
endif
.PHONY: clean
clean:
rm -rf $(CLEAN) $(BINS)
.PHONY: dist-clean
dist-clean:
git clean -xdff
git submodule deinit --all -f
.PHONY: test-coverage
test-coverage:
LILY_TEST_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" go test -coverprofile=coverage.out ./...
# tools
toolspath:=support/tools
$(toolspath)/bin/golangci-lint: $(toolspath)/go.mod
@mkdir -p $(dir $@)
(cd $(toolspath); go build -tags tools -o $(@:$(toolspath)/%=%) github.com/golangci/golangci-lint/cmd/golangci-lint)
.PHONY: lint
lint: $(toolspath)/bin/golangci-lint
$(toolspath)/bin/golangci-lint run --concurrency 8 ./...
actors-code-gen:
go run ./gen/inline-gen . gen/inlinegen-data.json
go run ./chain/actors/agen
go fmt ./...
actors-gen: actors-code-gen
./scripts/fiximports
.PHONY: actors-gen
.PHONY: tasks-gen
tasks-gen:
go run ./chain/indexer/tasktype/tablegen
go fmt ./...
.PHONY: itest
itest:
LILY_TEST_DB="postgres://postgres:password@localhost:5432/postgres?sslmode=disable" go test --tags=integration ./itests/
# dev-nets
2k: GOFLAGS+=-tags=2k
2k: build
calibnet: GOFLAGS+=-tags=calibnet
calibnet: build
nerpanet: GOFLAGS+=-tags=nerpanet
nerpanet: build
butterflynet: GOFLAGS+=-tags=butterflynet
butterflynet: build
interopnet: GOFLAGS+=-tags=interopnet
interopnet: build
# alias to match other network-specific targets
mainnet: build
# Dockerfiles
docker-clean:
rm Dockerfile Dockerfile.dev
docker-files: Dockerfile Dockerfile.dev
Dockerfile:
@echo "Writing ./Dockerfile..."
@cat build/docker/header.tpl \
build/docker/builder.tpl \
build/docker/prod_entrypoint.tpl \
> ./Dockerfile
Dockerfile.dev:
@echo "Writing ./Dockerfile.dev..."
@cat build/docker/header.tpl \
build/docker/builder.tpl \
build/docker/dev_entrypoint.tpl \
> ./Dockerfile.dev
# Docker images
# MAINNET
.PHONY: docker-mainnet
docker-mainnet: LILY_DOCKER_FILE ?= Dockerfile
docker-mainnet: LILY_NETWORK_TARGET ?= mainnet
docker-mainnet: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)
docker-mainnet: docker-build-image-template
.PHONY: docker-mainnet-push
docker-mainnet-push: docker-mainnet docker-tag-and-push-template
.PHONY: docker-mainnet-dev
docker-mainnet-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-mainnet-dev: LILY_NETWORK_TARGET ?= mainnet
docker-mainnet-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-dev
docker-mainnet-dev: docker-build-image-template
.PHONY: docker-mainnet-dev-push
docker-mainnet-dev-push: docker-mainnet-dev docker-tag-and-push-template
# CALIBNET
.PHONY: docker-calibnet
docker-calibnet: LILY_DOCKER_FILE ?= Dockerfile
docker-calibnet: LILY_NETWORK_TARGET ?= calibnet
docker-calibnet: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-calibnet
docker-calibnet: docker-build-image-template
.PHONY: docker-calibnet-push
docker-calibnet-push: docker-calibnet docker-tag-and-push-template
.PHONY: docker-calibnet-dev
docker-calibnet-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-calibnet-dev: LILY_NETWORK_TARGET ?= calibnet
docker-calibnet-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-calibnet-dev
docker-calibnet-dev: docker-build-image-template
.PHONY: docker-calibnet-dev-push
docker-calibnet-dev-push: docker-calibnet-dev docker-tag-and-push-template
# INTEROPNET
.PHONY: docker-interopnet
docker-interopnet: LILY_DOCKER_FILE ?= Dockerfile
docker-interopnet: LILY_NETWORK_TARGET ?= interopnet
docker-interopnet: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-interopnet
docker-interopnet: docker-build-image-template
.PHONY: docker-interopnet-push
docker-interopnet-push: docker-interopnet docker-tag-and-push-template
.PHONY: docker-interopnet-dev
docker-interopnet-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-interopnet-dev: LILY_NETWORK_TARGET ?= interopnet
docker-interopnet-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-interopnet-dev
docker-interopnet-dev: docker-build-image-template
.PHONY: docker-interopnet-dev-push
docker-interopnet-dev-push: docker-interopnet-dev docker-tag-and-push-template
# BUTTERFLYNET
.PHONY: docker-butterflynet
docker-butterflynet: LILY_DOCKER_FILE ?= Dockerfile
docker-butterflynet: LILY_NETWORK_TARGET ?= butterflynet
docker-butterflynet: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-butterflynet
docker-butterflynet: docker-build-image-template
.PHONY: docker-butterflynet-push
docker-butterflynet-push: docker-butterflynet docker-tag-and-push-template
.PHONY: docker-butterflynet-dev
docker-butterflynet-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-butterflynet-dev: LILY_NETWORK_TARGET ?= butterflynet
docker-butterflynet-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-butterflynet-dev
docker-butterflynet-dev: docker-build-image-template
.PHONY: docker-butterflynet-dev-push
docker-butterflynet-dev-push: docker-butterflynet-dev docker-tag-and-push-template
# NERPANET
.PHONY: docker-nerpanet
docker-nerpanet: LILY_DOCKER_FILE ?= Dockerfile
docker-nerpanet: LILY_NETWORK_TARGET ?= nerpanet
docker-nerpanet: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-nerpanet
docker-nerpanet: docker-build-image-template
.PHONY: docker-nerpanet-push
docker-nerpanet-push: docker-nerpanet docker-tag-and-push-template
.PHONY: docker-nerpanet-dev
docker-nerpanet-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-nerpanet-dev: LILY_NETWORK_TARGET ?= nerpanet
docker-nerpanet-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-nerpanet-dev
docker-nerpanet-dev: docker-build-image-template
.PHONY: docker-nerpanet-dev-push
docker-nerpanet-dev-push: docker-nerpanet-dev docker-tag-and-push-template
# 2K
.PHONY: docker-2k
docker-2k: LILY_DOCKER_FILE ?= Dockerfile
docker-2k: LILY_NETWORK_TARGET ?= 2k
docker-2k: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-2k
docker-2k: docker-build-image-template
.PHONY: docker-2k-push
docker-2k-push: docker-2k docker-tag-and-push-template
.PHONY: docker-2k-dev
docker-2k-dev: LILY_DOCKER_FILE ?= Dockerfile.dev
docker-2k-dev: LILY_NETWORK_TARGET ?= 2k
docker-2k-dev: LILY_IMAGE_TAG ?= $(docker_sanitized_lily_version)-2k-dev
docker-2k-dev: docker-build-image-template
.PHONY: docker-2k-dev-push
docker-2k-dev-push: docker-2k-dev docker-tag-and-push-template
.PHONY: docker-build-image-template
docker-build-image-template: clean docker-files
@echo "Building $(LILY_IMAGE_NAME):$(LILY_IMAGE_TAG) docker image for $(LILY_NETWORK_TARGET)..."
docker build -f $(LILY_DOCKER_FILE) \
--build-arg LILY_VERSION=$(LILY_VERSION) \
--build-arg LILY_NETWORK_TARGET=$(LILY_NETWORK_TARGET) \
--build-arg GO_BUILD_IMAGE=$(GO_BUILD_IMAGE) \
-t $(LILY_IMAGE_NAME) \
-t $(LILY_IMAGE_NAME):latest \
-t $(LILY_IMAGE_NAME):$(LILY_IMAGE_TAG) \
.
.PHONY: docker-tag-and-push-template
docker-tag-and-push-template:
./scripts/push-docker-tags.sh $(LILY_IMAGE_NAME) $(LILY_IMAGE_TAG)
.PHONY: docker-image
docker-image: docker-mainnet
@echo "*** Deprecated make target 'docker-image': Please use 'make docker-mainnet' instead. ***"