From 099a9b7b79a30a6d421f8f0da44428b7d8ee6f85 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:04 +0200 Subject: [PATCH 1/9] make: remove uneccessary go install 'go install' is done as part of 'go get -u'. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 448b26f4..d3fb414d 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.") From c6ee2803adb60fc4016afac550e8bfe38197c4bd Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:04 +0200 Subject: [PATCH 2/9] make: define goveralls --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d3fb414d..dd9c7087 100644 --- a/Makefile +++ b/Makefile @@ -167,6 +167,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 # ============= @@ -185,15 +189,11 @@ flake-unit: # ====== 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 +travis: dep lint build itest unit-cover goveralls 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 +travis: dep build itest unit-cover goveralls endif ifeq ($(RACE)$(USE_LINT), TRUETRUE) @@ -246,6 +246,7 @@ clean: unit \ unit-cover \ unit-race \ + goveralls \ flakehunter \ flake-unit \ travis \ From 23c858576fad327bafe133377805b67f156ed76e Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:04 +0200 Subject: [PATCH 3/9] make: define itest-only 'itest-only' can be used to only run integration tests, not build any of the dependencies. This is useful on travis, where manually executing each command makes it easier to track the time spent on each. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dd9c7087..63ec0805 100644 --- a/Makefile +++ b/Makefile @@ -149,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) @@ -242,6 +244,7 @@ clean: install \ scratch \ check \ + itest-only \ itest \ unit \ unit-cover \ From b98ab723ee0981c3be3f9113c26eb757845bc708 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:05 +0200 Subject: [PATCH 4/9] travis: remove unnecessary export PATH This is done automatically by travis as part of the go setup. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0242a0ea..389e1492 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,15 +9,17 @@ matrix: env: RACE=TRUE USE_LINT=FALSE - go: "1.10.x" env: RACE=FALSE USE_LINT=FALSE + 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 + 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' From 9e950b473909e566eaabc9dbc6e1ea2548bd6952 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:05 +0200 Subject: [PATCH 5/9] travis: execute make travis step by step Instead of calling 'make travis' directly, we call each step. This lets us better track how much time is spent on each. Also note that we execute 'itest-only' instead of 'itest', and instead execute the dependencies (btcd, build) manually first. We explicitly set the ITEST environment variable, for readability, and define a new COVER. This is currently true when ITEST=true to keep the existing build configuration, but will later be configured to be independent. --- .travis.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 389e1492..da7030d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,13 @@ language: go matrix: include: - go: "1.11.x" - env: RACE=TRUE USE_LINT=TRUE + env: RACE=true LINT=true - go: "1.11.x" - env: RACE=FALSE USE_LINT=TRUE + env: ITEST=true COVER=true LINT=true - go: "1.10.x" - env: RACE=TRUE USE_LINT=FALSE + env: RACE=true LINT=false - go: "1.10.x" - env: RACE=FALSE USE_LINT=FALSE + env: ITEST=true COVER=true LINT=false sudo: required install: @@ -18,7 +18,23 @@ install: - export PATH=$PATH:$PWD/linux-amd64/ script: - - 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'" From b64d55cdbffa017e30d3c86625b84782f9d06717 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:05 +0200 Subject: [PATCH 6/9] make: remove make travis --- Makefile | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/Makefile b/Makefile index 63ec0805..349686f5 100644 --- a/Makefile +++ b/Makefile @@ -186,26 +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 -endif - -ifeq ($(RACE)$(USE_LINT), FALSEFALSE) -travis: dep build itest unit-cover goveralls -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 # ========= @@ -252,7 +232,6 @@ clean: goveralls \ flakehunter \ flake-unit \ - travis \ fmt \ lint \ list \ From d3c9be1f323ebf84074b31f70a1bfa347bf466bd Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 16 Nov 2018 11:07:03 +0100 Subject: [PATCH 7/9] travis: only run on latest go --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index da7030d7..9ef7f22e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,6 @@ matrix: env: RACE=true LINT=true - go: "1.11.x" env: ITEST=true COVER=true LINT=true - - go: "1.10.x" - env: RACE=true LINT=false - - go: "1.10.x" - env: ITEST=true COVER=true LINT=false sudo: required install: From b4aeb83dbb9ae337f157348736fa287f7f8545c1 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 16 Nov 2018 11:08:16 +0100 Subject: [PATCH 8/9] travis: split up into 3 builds This commit distributes the CI tests into 3 independend builds, by splitting the integration test run and unit test coverage. To better handle the extra cases, we define a build matrix with the three build types (RACE and LINT, ITEST, COVER). --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ef7f22e..d9d64126 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ language: go -matrix: - include: - - go: "1.11.x" - env: RACE=true LINT=true - - go: "1.11.x" - env: ITEST=true COVER=true LINT=true +go: + - "1.11.x" + +env: + matrix: + - RACE=true LINT=true + - ITEST=true + - COVER=true sudo: required install: From aceda7fbcb79f9c1601588eb0d16d796343cd159 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Oct 2018 10:31:05 +0200 Subject: [PATCH 9/9] travis: enable caches This commit sets the GOCACHE environment variable, and enables caching on travis. GOCACHE will tell the compiler (only go 1.10+) where to store build and test artifacts. Caching this directory will significantly speed up succeeding builds and test runs. We also cache vendor/ as this will speed up the call to 'make dep'. A few dependencies in the GOPATH are cached, as calls to 'go get' for these will be sped up. Note that we don't cache the lnd directory, as it will conflict with the changes in the PR being built. --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index d9d64126..efe8dfb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,18 @@ language: go +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