diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d587999e1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[Makefile] +indent_style = tab + +[*.sh] +indent_style = tab diff --git a/.gitignore b/.gitignore index acc957a9e..4d8d33951 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ remote_dump vendor .vagrant test/p2p/data/ +.glide diff --git a/Makefile b/Makefile index 8835722b8..424acccb7 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,69 @@ -.PHONY: get_deps build all list_deps install +GOTOOLS = \ + github.com/mitchellh/gox \ + github.com/Masterminds/glide +PACKAGES=$(shell go list ./... | grep -v '/vendor/') +BUILD_TAGS?=tendermint +TMROOT = $${TMROOT:-$$HOME/.tendermint} all: get_deps install test -TMROOT = $${TMROOT:-$$HOME/.tendermint} -define NEWLINE - - -endef -NOVENDOR = go list github.com/tendermint/tendermint/... | grep -v /vendor/ - install: get_deps - go install github.com/tendermint/tendermint/cmd/tendermint + @go install ./cmd/tendermint build: - go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint + go build -o build/tendermint ./cmd/tendermint build_race: - go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint + go build -race -o build/tendermint ./cmd/tendermint + +# dist builds binaries for all platforms and packages them for distribution +dist: + @BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'" test: build - go test `${NOVENDOR}` + @echo "--> Running go test" + @go test $(PACKAGES) test_race: build - go test -race `${NOVENDOR}` + @echo "--> Running go test --race" + @go test -race $(PACKAGES) test_integrations: - bash ./test/test.sh + @bash ./test/test.sh test100: build - for i in {1..100}; do make test; done + @for i in {1..100}; do make test; done draw_deps: # requires brew install graphviz go get github.com/hirokidaichi/goviz - goviz -i github.com/tendermint/tendermint/cmd/tendermint | dot -Tpng -o huge.png + goviz -i ./cmd/tendermint | dot -Tpng -o huge.png list_deps: - go list -f '{{join .Deps "\n"}}' github.com/tendermint/tendermint/... | \ + @go list -f '{{join .Deps "\n"}}' ./... | \ grep -v /vendor/ | sort | uniq | \ - xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' + xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' get_deps: - go get -d `${NOVENDOR}` - go list -f '{{join .TestImports "\n"}}' github.com/tendermint/tendermint/... | \ + @go get -d $(PACKAGES) + @go list -f '{{join .TestImports "\n"}}' ./... | \ grep -v /vendor/ | sort | uniq | \ xargs go get -get_vendor_deps: - go get github.com/Masterminds/glide - rm -rf vendor/ - glide install +get_vendor_deps: tools + @rm -rf vendor/ + @echo "--> Running glide install" + @glide install update_deps: - go get -d -u github.com/tendermint/tendermint/... + @echo "--> Updating dependencies" + @go get -d -u ./... revision: -echo `git rev-parse --verify HEAD` > $(TMROOT)/revision -echo `git rev-parse --verify HEAD` >> $(TMROOT)/revision_history + +tools: + go get -u -v $(GOTOOLS) + +.PHONY: install build build_race dist test test_race test_integrations test100 draw_deps list_deps get_deps get_vendor_deps update_deps revision tools diff --git a/scripts/dist.sh b/scripts/dist.sh new file mode 100755 index 000000000..8da29299a --- /dev/null +++ b/scripts/dist.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -e + +# Get the version from the environment, or try to figure it out. +if [ -z $VERSION ]; then + VERSION=$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go) +fi +if [ -z "$VERSION" ]; then + echo "Please specify a version." + exit 1 +fi +echo "==> Building version $VERSION..." + +# Get the parent directory of where this script is. +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" + +# Change into that dir because we expect that. +cd "$DIR" + +# Generate the tag. +if [ -z "$NOTAG" ]; then + echo "==> Tagging..." + git commit --allow-empty -a -m "Release v$VERSION" + git tag -a -m "Version $VERSION" "v${VERSION}" master +fi + +# Do a hermetic build inside a Docker container. +docker build -t tendermint/tendermint-builder scripts/tendermint-builder/ +docker run --rm -e "BUILD_TAGS=$BUILD_TAGS" -v "$(pwd)":/go/src/github.com/tendermint/tendermint tendermint/tendermint-builder ./scripts/dist_build.sh + +# Add "tendermint" and $VERSION prefix to package name. +for FILENAME in $(find ./build/dist -mindepth 1 -maxdepth 1 -type f); do + FILENAME=$(basename "$FILENAME") + mv "./build/dist/${FILENAME}" "./build/dist/tendermint_${VERSION}_${FILENAME}" +done + +# Make the checksums. +pushd ./build/dist +shasum -a256 ./* > "./tendermint_${VERSION}_SHA256SUMS" +popd + +# Done +echo +echo "==> Results:" +ls -hl ./build/dist + +exit 0 diff --git a/scripts/dist_build.sh b/scripts/dist_build.sh new file mode 100755 index 000000000..947a3202b --- /dev/null +++ b/scripts/dist_build.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -e + +# Get the parent directory of where this script is. +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" + +# Change into that dir because we expect that. +cd "$DIR" + +# Get the git commit +GIT_COMMIT="$(git rev-parse --short HEAD)" +GIT_DESCRIBE="$(git describe --tags --always)" +GIT_IMPORT="github.com/tendermint/tendermint/version" + +# Determine the arch/os combos we're building for +XC_ARCH=${XC_ARCH:-"386 amd64 arm"} +XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"} + +# Delete the old dir +echo "==> Removing old directory..." +rm -rf build/dist/* +mkdir -p build/dist + +# Make sure build tools are available. +make tools + +# Get VENDORED dependencies +make get_vendor_deps + +# Build! +echo "==> Building..." +"$(which gox)" \ + -os="${XC_OS}" \ + -arch="${XC_ARCH}" \ + -osarch="!darwin/arm !solaris/amd64 !freebsd/amd64" \ + -ldflags "-X ${GIT_IMPORT}.GitCommit='${GIT_COMMIT}' -X ${GIT_IMPORT}.GitDescribe='${GIT_DESCRIBE}'" \ + -output "build/dist/{{.OS}}_{{.Arch}}/tendermint" \ + -tags="${BUILD_TAGS}" \ + github.com/tendermint/tendermint/cmd/tendermint + +# Zip all the files. +echo "==> Packaging..." +for PLATFORM in $(find ./build/dist -mindepth 1 -maxdepth 1 -type d); do + OSARCH=$(basename "${PLATFORM}") + echo "--> ${OSARCH}" + + pushd "$PLATFORM" >/dev/null 2>&1 + zip "../${OSARCH}.zip" ./* + popd >/dev/null 2>&1 +done + +# Remove build/dist/{{.OS}}_{{.Arch}} directories. +rm -rf build/dist/*/ + +exit 0 diff --git a/scripts/tendermint-builder/Dockerfile b/scripts/tendermint-builder/Dockerfile new file mode 100644 index 000000000..84c198ee0 --- /dev/null +++ b/scripts/tendermint-builder/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.7.4 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + zip \ + && rm -rf /var/lib/apt/lists/* + +# We want to ensure that release builds never have any cgo dependencies so we +# switch that off at the highest level. +ENV CGO_ENABLED 0 + +RUN mkdir -p $GOPATH/src/github.com/tendermint/tendermint +WORKDIR $GOPATH/src/github.com/tendermint/tendermint diff --git a/version/version.go b/version/version.go index e0d7b4261..395087d7d 100644 --- a/version/version.go +++ b/version/version.go @@ -1,7 +1,7 @@ package version const Maj = "0" -const Min = "8" // validator set changes, tmsp->abci, app persistence/recovery, BFT-liveness fix -const Fix = "0" // +const Min = "8" +const Fix = "0" -const Version = Maj + "." + Min + "." + Fix +const Version = "0.8.0"