Add Makefile to coordinate builds

pull/10616/head
Chris Goller 2016-09-15 16:01:51 -05:00
parent fa8d2d912b
commit d40f53913e
2 changed files with 39 additions and 4 deletions

30
Makefile Normal file
View File

@ -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

View File

@ -2,19 +2,24 @@
machine: machine:
services: services:
- docker - 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: dependencies:
pre: pre:
- git config --global url."git@github.com:".insteadOf "https://github.com/" - git config --global url."git@github.com:".insteadOf "https://github.com/"
- go get -u github.com/sparrc/gdm - make prepare
- gdm restore
override: override:
- docker info - docker info
- docker build --rm=false -t influxdata/mrfusion .
test: test:
override: 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 - docker run -d -p 8080:5000 -e PORT=5000 influxdata/mrfusion; sleep 10
- curl --retry 10 --retry-delay 5 -v http://localhost:8080 - curl --retry 10 --retry-delay 5 -v http://localhost:8080