2016-08-12 17:18:15 +00:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Darwin)
|
|
|
|
DHOST := $(shell echo $$(docker-machine ip))
|
|
|
|
else
|
|
|
|
DHOST := 127.0.0.1
|
|
|
|
endif
|
2016-08-11 19:06:09 +00:00
|
|
|
|
2014-05-20 06:02:59 +00:00
|
|
|
all: get-deps build
|
|
|
|
|
2016-07-21 19:48:29 +00:00
|
|
|
.PHONY: build
|
2014-05-20 06:02:59 +00:00
|
|
|
build:
|
2016-07-21 19:48:29 +00:00
|
|
|
go build ./...
|
2014-01-07 17:15:27 +00:00
|
|
|
|
2016-07-21 19:48:29 +00:00
|
|
|
.PHONY: get-deps
|
2014-01-07 17:15:27 +00:00
|
|
|
get-deps:
|
2016-07-21 19:48:29 +00:00
|
|
|
go get -v ./...
|
2014-01-07 17:15:27 +00:00
|
|
|
|
2016-07-21 19:48:29 +00:00
|
|
|
.PHONY: test
|
2016-07-21 20:34:24 +00:00
|
|
|
test: get-deps metalint docs-check check
|
2014-05-20 06:02:59 +00:00
|
|
|
|
2016-07-21 19:48:29 +00:00
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
go test -v -race -cover ./...
|
|
|
|
|
|
|
|
.PHONY: metalint
|
|
|
|
metalint:
|
|
|
|
which gometalinter > /dev/null || (go get github.com/alecthomas/gometalinter && gometalinter --install --update)
|
2016-08-12 17:39:06 +00:00
|
|
|
gometalinter --cyclo-over=20 -e "struct field Id should be ID" --enable="gofmt -s" --enable=misspell --disable=lll --fast ./...
|
2016-07-21 19:48:29 +00:00
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
|
|
|
@go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }'
|
|
|
|
|
|
|
|
.PHONY: docker-test
|
|
|
|
docker-test:
|
|
|
|
docker run -d -p 5432:5432 --name=pgstore_test_1 postgres:9.4
|
2016-08-11 19:06:09 +00:00
|
|
|
@echo "Ugly hack: Sleeping for 75 secs to give the Postgres container time to come up..."
|
|
|
|
sleep 75
|
|
|
|
@echo "Waking up - let's do this!"
|
2016-07-21 19:48:29 +00:00
|
|
|
docker run --rm --link pgstore_test_1:postgres postgres:9.4 psql -c 'create database test;' -U postgres -h postgres
|
2016-08-11 19:06:09 +00:00
|
|
|
PGSTORE_TEST_CONN="postgres://postgres@$(DHOST):5432/test?sslmode=disable" make test
|
2016-07-21 19:48:29 +00:00
|
|
|
docker kill pgstore_test_1
|
|
|
|
docker rm pgstore_test_1
|
|
|
|
|
|
|
|
.PHONY: docker-clean
|
|
|
|
docker-clean:
|
|
|
|
-docker kill pgstore_test_1
|
|
|
|
-docker rm pgstore_test_1
|
2016-07-21 20:34:24 +00:00
|
|
|
|
|
|
|
.PHONY: docs-dep
|
|
|
|
which embedmd > /dev/null || go get github.com/campoy/embedmd
|
|
|
|
|
|
|
|
.PHONY: docs-check
|
|
|
|
docs-check: docs-dep
|
|
|
|
@echo "Checking if docs are generated, if this fails, run 'make docs'."
|
|
|
|
embedmd README.md | diff README.md -
|
|
|
|
|
|
|
|
.PHONY: docs
|
|
|
|
docs: docs-dep
|
|
|
|
embedmd -w README.md
|