...
1UNAME := $(shell uname)
2ifeq ($(UNAME), Darwin)
3 DHOST := $(shell echo $$(docker-machine ip))
4else
5 DHOST := 127.0.0.1
6endif
7
8all: get-deps build
9
10.PHONY: build
11build:
12 go build ./...
13
14.PHONY: get-deps
15get-deps:
16 go get -v ./...
17
18.PHONY: test
19test: get-deps lint-check docs-check check
20
21.PHONY: check
22check:
23 go test -v -race -cover ./...
24
25.PHONY: lint-check
26lint-check:
27 golangci-lint run
28
29.PHONY: fmt
30fmt:
31 @go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }'
32
33.PHONY: docker-test
34docker-test:
35 docker run -d -p 5432:5432 --name=pgstore_test_1 postgres:9.4
36 @echo "Ugly hack: Sleeping for 75 secs to give the Postgres container time to come up..."
37 sleep 75
38 @echo "Waking up - let's do this!"
39 docker run --rm --link pgstore_test_1:postgres postgres:9.4 psql -c 'create database test;' -U postgres -h postgres
40 PGSTORE_TEST_CONN="postgres://postgres@$(DHOST):5432/test?sslmode=disable" make test
41 docker kill pgstore_test_1
42 docker rm pgstore_test_1
43
44.PHONY: docker-clean
45docker-clean:
46 -docker kill pgstore_test_1
47 -docker rm pgstore_test_1
48
49.PHONY: docs-dep
50 which embedmd > /dev/null || go get github.com/campoy/embedmd
51
52.PHONY: docs-check
53docs-check: docs-dep
54 @echo "Checking if docs are generated, if this fails, run 'make docs'."
55 embedmd README.md | diff README.md -
56
57.PHONY: docs
58docs: docs-dep
59 embedmd -w README.md
View as plain text