Skip to content

Commit

Permalink
Merge pull request #433 from iov-one/travis_cache_gopath
Browse files Browse the repository at this point in the history
Optimize CI tests
  • Loading branch information
husio authored Mar 25, 2019
2 parents 6a15a94 + 845158e commit 4c2f122
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 48 deletions.
82 changes: 48 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,65 @@ os:
go:
- "1.10"
- "1.11"
# - tip
#- "1.12"


env:
- GORACE="halt_on_error=1"
BUILD_VERSION=$(echo ${TRAVIS_COMMIT} | cut -c 1-10)
TM_VERSION=v0.27.4
FORCE_TM_TEST=1
global:
- TM_VERSION=v0.27.4
- BUILD_VERSION=$(echo ${TRAVIS_COMMIT} | cut -c 1-10)
- MAIN_GO_VERSION=1.11
- GORACE="halt_on_error=1"
- FORCE_TM_TEST=1

install:
- make deps
- go get -d github.com/tendermint/tendermint/... ;
cd ${GOPATH}/src/github.com/tendermint/tendermint ;
git checkout ${TM_VERSION} ;
make get_tools && make check && make install ;
cd - ;
rm -rf ${GOPATH}/src/github.com/tendermint/tendermint
cd -;

cache:
directories:
- $GOPATH
- $GOCACHE

script:
- make lint
- make build
- make test
- make dist

after_script:
- make cover
- ./coverage/upload.sh

after_success:
- if [[ "$TRAVIS_GO_VERSION" == "1.10" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_BRANCH" == "master" ]] && [[ "$TRAVIS_TAG" == "" ]] && [[ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag "iov1/bcpd:${BUILD_VERSION}" "iov1/bcpd:latest" ;
docker push "iov1/bcpd:latest";
docker tag "iov1/bnsd:${BUILD_VERSION}" "iov1/bnsd:latest" ;
docker push "iov1/bnsd:latest";
docker logout;
fi
# build the tagged image
- if [[ "$TRAVIS_GO_VERSION" == "1.10" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_TAG" != "" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag "iov1/bcpd:${BUILD_VERSION}" "iov1/bcpd:$TRAVIS_TAG" ;
docker push "iov1/bcpd:$TRAVIS_TAG";
docker tag "iov1/bnsd:${BUILD_VERSION}" "iov1/bnsd:$TRAVIS_TAG" ;
docker push "iov1/bnsd:$TRAVIS_TAG";
docker logout;
fi
- make lint;
- make test;
- if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" ]]; then
make cover;
./coverage/upload.sh;
fi;
- if [[ "$TRAVIS_GO_VERSION" == "$MAIN_GO_VERSION" && "$TRAVIS_OS_NAME" == "linux" ]]; then
release_latest=$( [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_TAG" == "" && "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]] && echo "yes" || echo "no" );
release_tag=$( [[ "$TRAVIS_TAG" != "" ]] && echo "yes" || echo "no" );

if [[ $release_latest == "yes" || $release_tag == "yes" ]]; then
make dist;
fi

if [[ $release_latest == "yes" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag "iov1/bcpd:${BUILD_VERSION}" "iov1/bcpd:latest" ;
docker push "iov1/bcpd:latest";
docker tag "iov1/bnsd:${BUILD_VERSION}" "iov1/bnsd:latest" ;
docker push "iov1/bnsd:latest";
docker logout;
fi;

if [[ $release_tag == "yes" ]]; then
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker tag "iov1/bcpd:${BUILD_VERSION}" "iov1/bcpd:$TRAVIS_TAG" ;
docker push "iov1/bcpd:$TRAVIS_TAG";
docker tag "iov1/bnsd:${BUILD_VERSION}" "iov1/bnsd:$TRAVIS_TAG" ;
docker push "iov1/bnsd:$TRAVIS_TAG";
docker logout;
fi;
fi;


notifications:
email: false

Expand Down
24 changes: 10 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all install build test tf cover deps tools prototools protoc
.PHONY: all install test tf cover deps prototools protoc govet

EXAMPLES := examples/mycoind cmd/bcpd cmd/bnsd

Expand All @@ -12,19 +12,15 @@ GOPATH ?= $$HOME/go

PROTOC_FLAGS := -I=. -I=./vendor -I=$(GOPATH)/src

all: deps build test
all: deps test

dist:
cd cmd/bnsd ; make dist ; cd -
cd cmd/bcpd ; make dist ; cd -
cd cmd/bnsd && $(MAKE) dist
cd cmd/bcpd && $(MAKE) dist

install:
for ex in $(EXAMPLES); do cd $$ex && make install && cd -; done

# This is to make sure it all compiles
build:
go build ./...

test:
go vet ./...
go test -race ./...
Expand All @@ -50,16 +46,16 @@ cover:
github.com/iov-one/weave/cmd/bnsd/scenarios
cat coverage/*.out > coverage/coverage.txt

deps: tools
@rm -rf vendor/
deps:
#rm -rf vendor/
ifndef $(shell command -v dep help > /dev/null)
go get github.com/golang/dep/cmd/dep
endif
dep ensure -vendor-only

tools:
@go get github.com/golang/dep/cmd/dep

lint:
ifndef $(shell command -v prototool help > /dev/null)
@go get github.com/uber/prototool/cmd/prototool
go get github.com/uber/prototool/cmd/prototool
endif
prototool lint

Expand Down

0 comments on commit 4c2f122

Please sign in to comment.