forked from robinjoseph08/go-pg-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (65 loc) · 1.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
DIRS ?= $(shell find . -name '*.go' | grep --invert-match 'vendor' | xargs -n 1 dirname | sort --unique)
SETUP_PKGS := \
github.com/alecthomas/gometalinter \
github.com/golang/dep/cmd/dep \
github.com/git-chglog/git-chglog/cmd/git-chglog \
github.com/mattn/goveralls \
TFLAGS ?=
COVERAGE_PROFILE ?= coverage.out
HTML_OUTPUT ?= coverage.html
PSQL := $(shell command -v psql 2> /dev/null)
TEST_DATABASE_USER ?= go_pg_migrations_user
TEST_DATABASE_NAME ?= go_pg_migrations
default: install
.PHONY: clean
clean:
@echo "---> Cleaning"
rm -rf ./vendor
coveralls:
@echo "---> Sending coverage info to Coveralls"
goveralls -coverprofile=$(COVERAGE_PROFILE) -service=travis-ci
.PHONY: enforce
enforce:
@echo "---> Enforcing coverage"
./scripts/coverage.sh $(COVERAGE_PROFILE)
.PHONY: html
html:
@echo "---> Generating HTML coverage report"
go tool cover -html $(COVERAGE_PROFILE) -o $(HTML_OUTPUT)
open $(HTML_OUTPUT)
.PHONY: install
install:
@echo "---> Installing dependencies"
dep ensure
.PHONY: lint
lint:
@echo "---> Linting..."
gometalinter --vendor --tests $(DIRS)
.PHONY: release
release:
@echo "---> Creating new release"
ifndef tag
$(error tag must be specified)
endif
git-chglog --output CHANGELOG.md --next-tag $(tag)
git add CHANGELOG.md
git commit -m $(tag)
git tag $(tag)
git push origin master --tags
.PHONY: setup
setup:
@echo "--> Setting up"
go get -u -v $(SETUP_PKGS)
gometalinter --install
ifdef PSQL
dropdb --if-exists $(TEST_DATABASE_NAME)
dropuser --if-exists $(TEST_DATABASE_USER)
createuser --createdb $(TEST_DATABASE_USER)
createdb -U $(TEST_DATABASE_USER) $(TEST_DATABASE_NAME)
else
$(error Postgres should be installed)
endif
.PHONY: test
test:
@echo "---> Testing"
TEST_DATABASE_USER=$(TEST_DATABASE_USER) TEST_DATABASE_NAME=$(TEST_DATABASE_NAME) go test ./... -coverprofile $(COVERAGE_PROFILE) $(TFLAGS)