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 b68369325..a8487700b 100644 --- a/circle.yml +++ b/circle.yml @@ -2,13 +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/" + - 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 - - docker build --rm=false -t influxdata/mrfusion . + test: override: + - 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