-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
97 lines (77 loc) · 3.88 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
HEAD_SHORT ?= $(shell git rev-parse --short HEAD)
PLATFORM ?= $(shell uname -m)
BIN_VERSION?="git"
HTTP_PORT ?= 8080
GO_BINDATA=go run github.com/go-bindata/go-bindata/v3/[email protected]
SQLC=go run github.com/kyleconroy/sqlc/cmd/[email protected]
GOVVV=go run github.com/ahmetb/[email protected]
ABIGEN=go run github.com/ethereum/go-ethereum/cmd/[email protected]
GOVVV_FLAGS=$(shell $(GOVVV) -flags -version $(BIN_VERSION) -pkg $(shell go list ./buildinfo))
# Code generation
ethereum: ethereum-testcontroller ethereum-testerc721 ethereum-testerc721a
$(ABIGEN) --abi ./pkg/tables/impl/ethereum/abi.json --pkg ethereum --type Contract --out pkg/tables/impl/ethereum/contract.go --bin pkg/tables/impl/ethereum/bytecode.bin
.PHONY: ethereum
ethereum-testcontroller:
$(ABIGEN) --abi ./pkg/tables/impl/ethereum/test/controller/abi.json --pkg controller --type Contract --out pkg/tables/impl/ethereum/test/controller/controller.go --bin pkg/tables/impl/ethereum/test/controller/bytecode.bin
.PHONY: ethereum-testcontroller
ethereum-testerc721:
$(ABIGEN) --abi ./pkg/tables/impl/ethereum/test/erc721Enumerable/abi.json --pkg erc721Enumerable --type Contract --out pkg/tables/impl/ethereum/test/erc721Enumerable/erc721Enumerable.go --bin pkg/tables/impl/ethereum/test/erc721Enumerable/bytecode.bin
.PHONY: ethereum-testerc721
ethereum-testerc721a:
$(ABIGEN) --abi ./pkg/tables/impl/ethereum/test/erc721aQueryable/abi.json --pkg erc721aQueryable --type Contract --out pkg/tables/impl/ethereum/test/erc721aQueryable/erc721aQueryable.go --bin pkg/tables/impl/ethereum/test/erc721aQueryable/bytecode.bin
.PHONY: ethereum-testerc721a
database-assets:
cd pkg/database && $(GO_BINDATA) -pkg migrations -prefix migrations/ -o migrations/migrations.go -ignore=migrations.go migrations && $(SQLC) generate; cd -;
.PHONY: database-assets
mocks: clean-mocks
go run github.com/vektra/mockery/[email protected] --name='\b(?:Gateway)\b' --recursive --with-expecter
.PHONY: mocks
clean-mocks:
rm -rf mocks
.PHONY: clean-mocks
EVM_EVENTS_ORIGIN:="docker/deployed/testnet/api/backup_database.db"
EVM_EVENTS_TARGET:="pkg/eventprocessor/impl/testdata/evm_history.db"
generate-history-db:
rm -f ${EVM_EVENTS_TARGET}
sqlite3 ${EVM_EVENTS_ORIGIN} 'ATTACH DATABASE ${EVM_EVENTS_TARGET} as target' 'CREATE TABLE target.system_evm_events as select * from system_evm_events'
zstd -f ${EVM_EVENTS_TARGET}
rm ${EVM_EVENTS_TARGET}
# Build
build-api:
go build -ldflags="${GOVVV_FLAGS}" ./cmd/api
.PHONY: build-api
build-healthbot:
go build -ldflags="${GOVVV_FLAGS}" ./cmd/healthbot
.PHONY: build-healthbot
build-api-debug:
go build -ldflags="${GOVVV_FLAGS}" -gcflags="all=-N -l" ./cmd/api
.PHONY: build-api-debug
image:
docker build --platform linux/amd64 -t tableland/api:sha-$(HEAD_SHORT) -t tableland/api:latest -f ./cmd/api/Dockerfile .
.PHONY: image
# Test
test:
go test ./... -short -race
.PHONY: test
test-replayhistory:
go test ./pkg/eventprocessor/impl -run=TestReplayProductionHistory -race
# Lint
lint:
go run github.com/golangci/golangci-lint/cmd/[email protected] run
.PHONY: lint
# OpenAPI
SPEC_URL=https://raw.githubusercontent.com/tablelandnetwork/docs/main/specs/validator/tableland-openapi-spec.yaml
APIV1=${PWD}/internal/router/controllers/apiv1
gen-api-v1:
mkdir -p ${APIV1}
curl -s ${SPEC_URL} > ${APIV1}/tableland-openapi-spec.yaml
docker run -w /gen -e GEN_DIR=/gen -v ${APIV1}:/gen --entrypoint /bin/sh textile/swagger-codegen-cli:3.0.41 -lc \
" java -jar /opt/swagger-codegen-cli/swagger-codegen-cli.jar generate --lang go-server -o /gen -i tableland-openapi-spec.yaml --additional-properties=packageName=apiv1 \
&& cd /gen \
&& mv go/* . \
&& rm -rf go main.go Dockerfile README.md api .swagger-codegen .swagger-codegen-ignore *.yaml \
&& sed -i 's/\*OneOfTableAttributesValue/interface{}/' model_table_attributes.go \
&& sed -i 's/\OneOfQueryParamsItems/interface{}/' model_query.go \
"
sudo chown -R ${USER} ${APIV1}
.PHONY: gen-api-v1