@ -7,8 +7,6 @@ GOBIN?=${GOPATH}/bin
PACKAGES = $( shell go list ./...)
OUTPUT ?= build/tendermint
export GO111MODULE = on
INCLUDE = -I= . -I= ${ GOPATH } /src -I= ${ GOPATH } /src/github.com/gogo/protobuf/protobuf
BUILD_TAGS ?= 'tendermint'
LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit= ` git rev-parse --short= 8 HEAD` -s -w
@ -16,7 +14,9 @@ BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
all : check build test install
check : check_tools
# The below include contains the tools.
i n c l u d e s c r i p t s / d e v t o o l s / M a k e f i l e
i n c l u d e t e s t s . m k
########################################
### Build Tendermint
@ -27,13 +27,6 @@ build:
build_c :
CGO_ENABLED = 1 go build $( BUILD_FLAGS) -tags " $( BUILD_TAGS) cleveldb " -o $( OUTPUT) ./cmd/tendermint/
# Runs `make build_c` from within an Amazon Linux (v2)-based Docker build
# container in order to build an Amazon Linux-compatible binary. Produces a
# compatible binary at ./build/tendermint
build_c-amazonlinux :
$( MAKE) -C ./DOCKER build_amazonlinux_buildimage
docker run --rm -it -v ` pwd ` :/tendermint tendermint/tendermint:build_c-amazonlinux
build_race :
CGO_ENABLED = 1 go build -race $( BUILD_FLAGS) -tags $( BUILD_TAGS) -o $( OUTPUT) ./cmd/tendermint
@ -78,22 +71,6 @@ install_abci:
dist :
@BUILD_TAGS= $( BUILD_TAGS) sh -c " ' $( CURDIR) /scripts/dist.sh' "
########################################
### Tools & dependencies
check_tools :
@# https://stackoverflow.com/a/25668869
@echo " Found tools: $( foreach tool,$( notdir $( GOTOOLS) ) ,\
$( if $( shell which $( tool) ) ,$( tool) ,$( error " No $( tool) in PATH " ) ) ) "
get_tools :
@echo "--> Installing tools"
./scripts/get_tools.sh
update_tools :
@echo "--> Updating tools"
./scripts/get_tools.sh
#For ABCI and libs
get_protoc :
@# https://github.com/google/protobuf/releases
@ -107,6 +84,16 @@ get_protoc:
cd .. && \
rm -rf protobuf-3.6.1
go-mod-cache : go .sum
@echo "--> Download go modules to local cache"
@go mod download
.PHONY : go -mod -cache
go.sum : go .mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
@go mod tidy
draw_deps :
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@ -153,100 +140,6 @@ protoc_grpc: rpc/grpc/types.pb.go
protoc_merkle : crypto /merkle /merkle .pb .go
########################################
### Testing
## required to be run first by most tests
build_docker_test_image :
docker build -t tester -f ./test/docker/Dockerfile .
### coverage, app, persistence, and libs tests
test_cover :
# run the go unit tests with coverage
bash test/test_cover.sh
test_apps :
# run the app tests using bash
# requires `abci-cli` and `tendermint` binaries installed
bash test/app/test.sh
test_abci_apps :
bash abci/tests/test_app/test.sh
test_abci_cli :
# test the cli against the examples in the tutorial at:
# ./docs/abci-cli.md
# if test fails, update the docs ^
@ bash abci/tests/test_cli/test.sh
test_persistence :
# run the persistence tests using bash
# requires `abci-cli` installed
docker run --name run_persistence -t tester bash test/persist/test_failure_indices.sh
# TODO undockerize
# bash test/persist/test_failure_indices.sh
test_p2p :
docker rm -f rsyslog || true
rm -rf test/logs || true
mkdir test/logs
cd test/
docker run -d -v "logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog
cd ..
# requires 'tester' the image from above
bash test/p2p/test.sh tester
# the `docker cp` takes a really long time; uncomment for debugging
#
# mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs
test_integrations :
make build_docker_test_image
make get_tools
make install
make test_cover
make test_apps
make test_abci_apps
make test_abci_cli
make test_libs
make test_persistence
make test_p2p
test_release :
@go test -tags release $( PACKAGES)
test100 :
@for i in { 1..100} ; do make test; done
vagrant_test :
vagrant up
vagrant ssh -c 'make test_integrations'
### go tests
test :
@echo "--> Running go test"
@go test -p 1 $( PACKAGES)
test_race :
@echo "--> Running go test --race"
@go test -p 1 -v -race $( PACKAGES)
# uses https://github.com/sasha-s/go-deadlock/ to detect potential deadlocks
test_with_deadlock :
make set_with_deadlock
make test
make cleanup_after_test_with_deadlock
set_with_deadlock :
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.RWMutex/deadlock.RWMutex/'
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.Mutex/deadlock.Mutex/'
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w
# cleanes up after you ran test_with_deadlock
cleanup_after_test_with_deadlock :
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.RWMutex/sync.RWMutex/'
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.Mutex/sync.Mutex/'
find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w
########################################
### Formatting, linting, and vetting
@ -276,12 +169,19 @@ build-docker:
### Local testnet using docker
# Build linux binary on other platforms
build-linux : get_ tools
build-linux : tools
GOOS = linux GOARCH = amd64 $( MAKE) build
build-docker-localnode :
@cd networks/local && make
# Runs `make build_c` from within an Amazon Linux (v2)-based Docker build
# container in order to build an Amazon Linux-compatible binary. Produces a
# compatible binary at ./build/tendermint
build_c-amazonlinux :
$( MAKE) -C ./DOCKER build_amazonlinux_buildimage
docker run --rm -it -v ` pwd ` :/tendermint tendermint/tendermint:build_c-amazonlinux
# Run a 4-node testnet locally
localnet-start : localnet -stop build -docker -localnode
@if ! [ -f build/node0/config/genesis.json ] ; then docker run --rm -v $( CURDIR) /build:/tendermint:Z tendermint/localnode testnet --config /etc/tendermint/config-template.toml --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2; fi
@ -311,10 +211,6 @@ sentry-stop:
@if [ -z " $( DO_API_TOKEN) " ] ; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
cd networks/remote/terraform && terraform destroy -var DO_API_TOKEN = " $( DO_API_TOKEN) " -var SSH_KEY_FILE = " $( HOME) /.ssh/id_rsa.pub "
# meant for the CI, inspect script & adapt accordingly
build-slate :
bash scripts/slate.sh
# Build hooks for dredd, to skip or add information on some steps
build-contract-tests-hooks :
i f e q ( $( OS ) , W i n d o w s _ N T )
@ -334,4 +230,8 @@ contract-tests:
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY : check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p 2p test test_race test_integrations test_release test 100 vagrant_test fmt rpc -docs build -linux localnet -start localnet -stop build -docker build -docker -localnode sentry -start sentry -config sentry -stop build -slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build -contract -tests -hooks contract -tests build_c -amazonlinux
.PHONY : check build build_race build_abci dist install install_abci check_tools tools update_tools draw_deps \
get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver fmt rpc-docs build-linux localnet-start \
localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop protoc_grpc protoc_all \
build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests \
build_c-amazonlinux