2020-09-16 21:03:14 +02:00
|
|
|
.PHONY: deps build run lint mocks run-mainnet-online run-mainnet-offline run-testnet-online \
|
|
|
|
run-testnet-offline check-comments add-license check-license shorten-lines test \
|
|
|
|
coverage spellcheck salus build-local coverage-local format check-format
|
|
|
|
|
|
|
|
ADDLICENSE_CMD=go run github.com/google/addlicense
|
|
|
|
ADDLICENCE_SCRIPT=${ADDLICENSE_CMD} -c "Coinbase, Inc." -l "apache" -v
|
|
|
|
SPELLCHECK_CMD=go run github.com/client9/misspell/cmd/misspell
|
|
|
|
GOLINES_CMD=go run github.com/segmentio/golines
|
|
|
|
GOLINT_CMD=go run golang.org/x/lint/golint
|
2020-09-18 21:26:51 +02:00
|
|
|
GOVERALLS_CMD=go run github.com/mattn/goveralls
|
2020-09-16 21:03:14 +02:00
|
|
|
GOIMPORTS_CMD=go run golang.org/x/tools/cmd/goimports
|
|
|
|
GO_PACKAGES=./services/... ./indexer/... ./bitcoin/... ./configuration/...
|
|
|
|
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
|
|
|
|
TEST_SCRIPT=go test ${GO_PACKAGES}
|
|
|
|
LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam
|
|
|
|
PWD=$(shell pwd)
|
|
|
|
NOFILE=100000
|
|
|
|
|
|
|
|
deps:
|
|
|
|
go get ./...
|
|
|
|
|
|
|
|
build:
|
|
|
|
docker build -t rosetta-bitcoin:latest https://github.com/coinbase/rosetta-bitcoin.git
|
|
|
|
|
|
|
|
build-local:
|
|
|
|
docker build -t rosetta-bitcoin:latest .
|
|
|
|
|
2020-09-19 02:39:40 +02:00
|
|
|
build-release:
|
2020-09-21 17:42:00 +02:00
|
|
|
# make sure to always set version with vX.X.X
|
2020-09-19 02:39:40 +02:00
|
|
|
docker build -t rosetta-bitcoin:$(version) .;
|
2020-09-22 05:39:28 +02:00
|
|
|
docker save rosetta-bitcoin:$(version) | gzip > rosetta-bitcoin-$(version).tar.gz;
|
2020-09-21 17:42:00 +02:00
|
|
|
|
|
|
|
pull-remote:
|
|
|
|
curl -L https://github.com/coinbase/rosetta-bitcoin/releases/latest/download/rosetta-bitcoin.tar.gz -o rosetta-bitcoin.tar.gz;
|
|
|
|
docker load --input rosetta-bitcoin.tar.gz;
|
|
|
|
rm rosetta-bitcoin.tar.gz;
|
2020-09-19 02:39:40 +02:00
|
|
|
|
2020-09-16 21:03:14 +02:00
|
|
|
run-mainnet-online:
|
|
|
|
docker run -d --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest
|
|
|
|
|
|
|
|
run-mainnet-offline:
|
|
|
|
docker run -d -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest
|
|
|
|
|
|
|
|
run-testnet-online:
|
|
|
|
docker run -d --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 18333:18333 rosetta-bitcoin:latest
|
|
|
|
|
|
|
|
run-testnet-offline:
|
|
|
|
docker run -d -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest
|
|
|
|
|
|
|
|
train:
|
|
|
|
./zstd-train.sh $(network) transaction $(data-directory)
|
|
|
|
|
|
|
|
check-comments:
|
|
|
|
${GOLINT_CMD} -set_exit_status ${GO_FOLDERS} .
|
|
|
|
|
|
|
|
lint: | check-comments
|
2020-09-21 00:24:43 +02:00
|
|
|
golangci-lint run --timeout 2m0s -v -E ${LINT_SETTINGS},gomnd
|
2020-09-16 21:03:14 +02:00
|
|
|
|
|
|
|
add-license:
|
|
|
|
${ADDLICENCE_SCRIPT} .
|
|
|
|
|
|
|
|
check-license:
|
|
|
|
${ADDLICENCE_SCRIPT} -check .
|
|
|
|
|
|
|
|
shorten-lines:
|
|
|
|
${GOLINES_CMD} -w --shorten-comments ${GO_FOLDERS} .
|
|
|
|
|
|
|
|
format:
|
|
|
|
gofmt -s -w -l .
|
|
|
|
${GOIMPORTS_CMD} -w .
|
|
|
|
|
|
|
|
check-format:
|
|
|
|
! gofmt -s -l . | read
|
|
|
|
! ${GOIMPORTS_CMD} -l . | read
|
|
|
|
|
|
|
|
test:
|
|
|
|
${TEST_SCRIPT}
|
|
|
|
|
|
|
|
coverage:
|
|
|
|
if [ "${COVERALLS_TOKEN}" ]; then ${TEST_SCRIPT} -coverprofile=c.out -covermode=count; ${GOVERALLS_CMD} -coverprofile=c.out -repotoken ${COVERALLS_TOKEN}; fi
|
|
|
|
|
|
|
|
coverage-local:
|
|
|
|
${TEST_SCRIPT} -cover
|
|
|
|
|
|
|
|
salus:
|
|
|
|
docker run --rm -t -v ${PWD}:/home/repo coinbase/salus
|
|
|
|
|
|
|
|
spellcheck:
|
|
|
|
${SPELLCHECK_CMD} -error .
|
|
|
|
|
|
|
|
mocks:
|
|
|
|
rm -rf mocks;
|
|
|
|
mockery --dir indexer --all --case underscore --outpkg indexer --output mocks/indexer;
|
|
|
|
mockery --dir services --all --case underscore --outpkg services --output mocks/services;
|
|
|
|
${ADDLICENCE_SCRIPT} .;
|