-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
83 lines (58 loc) · 1.82 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
80
81
82
83
.PHONY: all
all: build build-frontend fmt vet lint test
ALL_PACKAGES=$(shell go list ./... | grep -v -e "vendor" -e "frontend")
UNIT_TEST_PACKAGES=$(shell go list ./... | grep -v -e "vendor" -e "frontend")
DB_NAME="shop_dev"
TEST_DB_NAME="shop_test"
TEST_DB_PORT=5432
DB_PORT=5432
APP_EXECUTABLE="out/shop"
setup:
go get -u golang.org/x/lint/golint
sudo npm install -g @angular/cli
compile:
mkdir -p out/
go build -o $(APP_EXECUTABLE)
build: compile fmt vet lint
build-frontend:
cd ./frontend;npm install; ng build --base-href /homepage/;
install:
go install ./...
fmt:
go fmt $(ALL_PACKAGES)
vet:
go vet $(ALL_PACKAGES)
lint:
@for p in $(UNIT_TEST_PACKAGES); do \
echo "==> Linting $$p"; \
golint $$p | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } \
done
test: testdb.drop testdb.create testdb.migrate
ENVIRONMENT=test go test $(UNIT_TEST_PACKAGES) -race
db.setup: db.create db.migrate
db.create:
createdb -p $(DB_PORT) -Opostgres -Eutf8 $(DB_NAME)
db.migrate:
$(APP_EXECUTABLE) migrate
db.rollback:
$(APP_EXECUTABLE) rollback
db.drop:
dropdb -p $(DB_PORT) --if-exists -Upostgres $(DB_NAME)
db.reset: db.drop db.create db.migrate
testdb.create:
createdb -p $(TEST_DB_PORT) -Opostgres -Eutf8 $(TEST_DB_NAME)
testdb.migrate:
ENVIRONMENT=test $(APP_EXECUTABLE) migrate
testdb.drop:
dropdb -p $(TEST_DB_PORT) --if-exists -Upostgres $(TEST_DB_NAME)
testdb.reset: testdb.drop testdb.create testdb.migrate
test-cover-html:
@echo "mode: count" > coverage-all.out
$(foreach pkg, $(ALL_PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o out/coverage.html
copy-config:
cp application.yml.sample application.yml
copy-config-ci:
cp ci.yml.sample application.yml