diff --git a/.travis.yml b/.travis.yml index 0242a0ea..efe8dfb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,49 @@ language: go -matrix: - include: - - go: "1.11.x" - env: RACE=TRUE USE_LINT=TRUE - - go: "1.11.x" - env: RACE=FALSE USE_LINT=TRUE - - go: "1.10.x" - env: RACE=TRUE USE_LINT=FALSE - - go: "1.10.x" - env: RACE=FALSE USE_LINT=FALSE +cache: + directories: + - vendor/ + - $GOCACHE + - $GOPATH/src/github.com/btcsuite + - $GOPATH/src/github.com/golang + - $GOPATH/src/gopkg.in/alecthomas + +go: + - "1.11.x" + +env: + global: + - GOCACHE=$HOME/.go-build + matrix: + - RACE=true LINT=true + - ITEST=true + - COVER=true + sudo: required install: - sudo add-apt-repository -y ppa:bitcoin/bitcoin -y - sudo apt-get update -q - sudo apt-get install bitcoind -y - export PATH=$PATH:$PWD/linux-amd64/ + script: - - export PATH=$PATH:$GOPATH/bin - - make travis + # Common for all builds. + - make dep + - make btcd + + # Run linter if LINT=true. + - 'if [ "$LINT" = true ]; then make lint ; fi' + + # Run unit tests with race condition detector. + - 'if [ "$RACE" = true ]; then make unit-race ; fi' + + # Run integration tests. + - 'if [ "$ITEST" = true ]; then make build ; fi' + - 'if [ "$ITEST" = true ]; then make itest-only ; fi' + + # Run unit tests and generate coverage report. + - 'if [ "$COVER" = true ]; then make unit-cover; fi' + - 'if [ "$COVER" = true ]; then make goveralls; fi' + after_script: - echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'" - echo "Uploading to file.io..." && tar -zcvO *.log | curl -s -F 'file=@-;filename=logs.tar.gz' https://file.io | xargs -r0 printf 'logs.tar.gz uploaded to %s\n' diff --git a/Makefile b/Makefile index 448b26f4..349686f5 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,6 @@ $(GOVERALLS_BIN): $(LINT_BIN): @$(call print, "Fetching gometalinter.v2") go get -u $(LINT_PKG) - $(GOINSTALL) $(LINT_PKG) dep: $(DEP_BIN) @$(call print, "Compiling dependencies.") @@ -150,10 +149,12 @@ scratch: dep build check: unit itest -itest: btcd build +itest-only: @$(call print, "Running integration tests.") $(ITEST) +itest: btcd build itest-only + unit: btcd @$(call print, "Running unit tests.") $(UNIT) @@ -168,6 +169,10 @@ unit-race: export CGO_ENABLED=1; env GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE) export CGO_ENABLED=$(CGO_STATUS_QUO) +goveralls: $(GOVERALLS_BIN) + @$(call print, "Sending coverage report.") + $(GOVERALLS_BIN) -coverprofile=profile.cov -service=travis-ci + # ============= # FLAKE HUNTING # ============= @@ -181,30 +186,6 @@ flake-unit: GOTRACEBACK=all $(UNIT) -count=1 while [ $$? -eq 0 ]; do /bin/sh -c "GOTRACEBACK=all $(UNIT) -count=1"; done -# ====== -# TRAVIS -# ====== - -ifeq ($(RACE)$(USE_LINT), FALSETRUE) -travis: dep lint build itest unit-cover $(GOVERALLS_BIN) - @$(call print, "Sending coverage report.") - $(GOVERALLS_BIN) -coverprofile=profile.cov -service=travis-ci -endif - -ifeq ($(RACE)$(USE_LINT), FALSEFALSE) -travis: dep build itest unit-cover $(GOVERALLS_BIN) - @$(call print, "Sending coverage report.") - $(GOVERALLS_BIN) -coverprofile=profile.cov -service=travis-ci -endif - -ifeq ($(RACE)$(USE_LINT), TRUETRUE) -travis: dep lint btcd unit-race -endif - -ifeq ($(RACE)$(USE_LINT), TRUEFALSE) -travis: dep btcd unit-race -endif - # ========= # UTILITIES # ========= @@ -243,13 +224,14 @@ clean: install \ scratch \ check \ + itest-only \ itest \ unit \ unit-cover \ unit-race \ + goveralls \ flakehunter \ flake-unit \ - travis \ fmt \ lint \ list \