From 87e8bc0fec181e1e981e918f876b2102840d080d Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 15 Sep 2016 15:00:56 -0500 Subject: [PATCH 1/3] Add go testing to circle --- circle.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/circle.yml b/circle.yml index b68369325..cd26795bd 100644 --- a/circle.yml +++ b/circle.yml @@ -4,11 +4,17 @@ machine: - docker dependencies: + pre: + - git config --global url."git@github.com:".insteadOf "https://github.com/" + - go get -u github.com/sparrc/gdm + - gdm restore override: - docker info - docker build --rm=false -t influxdata/mrfusion . + test: override: + - go test -v -race ./... - docker run -d -p 8080:5000 -e PORT=5000 influxdata/mrfusion; sleep 10 - curl --retry 10 --retry-delay 5 -v http://localhost:8080 From f9a5dc75a8393f5109525d674917de9535a8cecd Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 15 Sep 2016 16:01:51 -0500 Subject: [PATCH 2/3] Add Makefile to coordinate builds --- Makefile | 30 ++++++++++++++++++++++++++++++ circle.yml | 13 +++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..2da364920 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +VERSION ?= $$(git describe --always --tags) +COMMIT ?= $$(git rev-parse --short=8 HEAD) +BRANCH ?= $$(git rev-parse --abbrev-ref HEAD | tr / _) +BUILD_TIME ?= $$(date +%FT%T%z) + +SOURCES := $(shell find . -name '*.go') + +LDFLAGS=-ldflags "-s -X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildTime=${BUILD_TIME} -X main.Branch=${BRANCH}" +BINARY=mrfusion + +default: prepare ${BINARY} + +${BINARY}: $(SOURCES) + go build -o ${BINARY} ${LDFLAGS} ./cmd/mr-fusion-server/main.go + +docker-${BINARY}: $(SOURCES) + CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o ${BINARY} ${LDFLAGS} \ + ./cmd/mr-fusion-server/main.go + +prepare: + go get github.com/sparrc/gdm + gdm restore + +clean: + if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi + +test: + go test -race ./... + +.PHONY: clean test diff --git a/circle.yml b/circle.yml index cd26795bd..d0a163359 100644 --- a/circle.yml +++ b/circle.yml @@ -2,19 +2,24 @@ machine: services: - docker + post: + - go version + - go version | grep 1.7.1 || sudo rm -rf /usr/local/go + - wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz + - sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz + - go version dependencies: pre: - git config --global url."git@github.com:".insteadOf "https://github.com/" - - go get -u github.com/sparrc/gdm - - gdm restore + - make prepare override: - docker info - - docker build --rm=false -t influxdata/mrfusion . test: override: - - go test -v -race ./... + - make test + - docker build --rm=false -t influxdata/mrfusion . - docker run -d -p 8080:5000 -e PORT=5000 influxdata/mrfusion; sleep 10 - curl --retry 10 --retry-delay 5 -v http://localhost:8080 From 5706af62a14ae361e8d45c74e3bbc2a5d78c4172 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 15 Sep 2016 18:07:34 -0500 Subject: [PATCH 3/3] Update circle to force using gdm from within .go_workspace --- circle.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index d0a163359..a8487700b 100644 --- a/circle.yml +++ b/circle.yml @@ -4,15 +4,15 @@ machine: - docker post: - go version - - go version | grep 1.7.1 || sudo rm -rf /usr/local/go - - wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz - - sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz + - go version | grep 1.7.1 || (sudo rm -rf /usr/local/go && wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz && sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz) - go version dependencies: pre: - git config --global url."git@github.com:".insteadOf "https://github.com/" - - make prepare + - mkdir -p ${HOME}/.go_workspace/src/github.com/influxdata + - ln -sf ${HOME}/mrfusion ${HOME}/.go_workspace/src/github.com/influxdata + - cd ${HOME}/.go_workspace/src/github.com/influxdata/mrfusion && make override: - docker info