diff --git a/Makefile b/Makefile index 14cf3b42c..718e7fb68 100644 --- a/Makefile +++ b/Makefile @@ -41,18 +41,18 @@ $(RUNSVINIT): vendor/runsvinit/*.go $(SCOPE_EXE): $(shell find ./ -path ./vendor -prune -o -type f -name *.go) prog/static.go ifeq ($(BUILD_IN_CONTAINER),true) -$(SCOPE_EXE) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) + +$(SCOPE_EXE) $(RUNSVINIT) tests shell: $(SCOPE_BACKEND_BUILD_UPTODATE) @mkdir -p $(shell pwd)/.pkg - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope -e GOARCH -e GOOS \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd):/go/src/github.com/weaveworks/scope \ -v $(shell pwd)/.pkg:/go/pkg \ + -e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \ + -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW \ $(SCOPE_BACKEND_BUILD_IMAGE) SCOPE_VERSION=$(SCOPE_VERSION) GO_BUILD_INSTALL_DEPS=$(GO_BUILD_INSTALL_DEPS) $@ -shell: - @mkdir -p $(shell pwd)/.pkg - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope -e GOARCH -e GOOS \ - -v $(shell pwd)/.pkg:/go/pkg \ - $(SCOPE_BACKEND_BUILD_IMAGE) SCOPE_VERSION=$(SCOPE_VERSION) GO_BUILD_INSTALL_DEPS=$(GO_BUILD_INSTALL_DEPS) $@ else + $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE) time go build $(GO_BUILD_FLAGS) -o $@ ./$(@D) @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ @@ -69,6 +69,10 @@ $(RUNSVINIT): shell: /bin/bash + +tests: + ./tools/test -no-go-get + endif static: prog/static.go @@ -116,16 +120,6 @@ clean: rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \ $(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/app.js docker/weave .pkg -ifeq ($(BUILD_IN_CONTAINER),true) -tests: $(SCOPE_BACKEND_BUILD_UPTODATE) - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope \ - -e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL -e CIRCLE_NODE_INDEX -e COVERDIR\ - $(SCOPE_BACKEND_BUILD_IMAGE) tests -else -tests: - ./tools/test -no-go-get -endif - deps: go get -u -f -tags netgo \ github.com/golang/lint/golint \ diff --git a/backend/Dockerfile b/backend/Dockerfile index d3ecdea53..b7107b1c2 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,6 +1,6 @@ FROM golang:1.5.2 ENV GO15VENDOREXPERIMENT 1 RUN apt-get update && apt-get install -y libpcap-dev python-requests time -RUN go clean -i net && go install -tags netgo std +RUN go clean -i net && go install -tags netgo std && go install -race -tags netgo std COPY build.sh / ENTRYPOINT ["/build.sh"] diff --git a/tools/test b/tools/test index 73a5952ef..5b88d5270 100755 --- a/tools/test +++ b/tools/test @@ -57,6 +57,9 @@ fi PACKAGE_BASE=$(go list -e ./) +# Speed up the tests by compiling and installing their dependancies first. +go test -i $GO_TEST_ARGS $TESTDIRS + for dir in $TESTDIRS; do if [ -z "$NO_GO_GET" ]; then go get -t -tags netgo $dir