-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
92 lines (69 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
84
85
86
87
88
89
90
91
92
BINARY="qurl"
DOCKER-IMAGE="repejota/qurl"
VERSION=`cat VERSION`
BUILD=`git symbolic-ref HEAD 2> /dev/null | cut -b 12-`-`git log --pretty=format:%h -1`
PACKAGES = "./..."
# Setup the -ldflags option for go build here, interpolate the variable
# values
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
.PHONY: build
install: clean
go install $(LDFLAGS) -v $(PACKAGES)
.PHONY: build
build: clean
go build $(LDFLAGS) -v ./cmd/$(BINARY)
.PHONY: version
version:
@echo $(VERSION)-$(BUILD)
.PHONY: clean
clean:
go clean
rm -rf $(BINARY)
rm -rf coverage-all.out
# Docker
.PHONY: docker
docker: clean
docker build -t $(DOCKER-IMAGE) .
docker tag $(DOCKER-IMAGE) $(DOCKER-IMAGE):$(VERSION)
docker push $(DOCKER-IMAGE)
docker rmi $(DOCKER-IMAGE)
docker rmi $(DOCKER-IMAGE):$(VERSION)
docker-scratch: clean build
docker build -t $(DOCKER-IMAGE):scratch -f Dockerfile.scratch .
docker tag $(DOCKER-IMAGE):scratch $(DOCKER-IMAGE):scratch-$(VERSION)
docker push $(DOCKER-IMAGE)
docker rmi $(DOCKER-IMAGE):scratch
docker rmi $(DOCKER-IMAGE):scratch-$(VERSION)
rm -rf qurl
docker-run: clean
docker run -it --rm --name $(BINARY) $(DOCKER-IMAGE)
# Testing
test:
go test -v $(PACKAGES)
cover:
go test -cover $(PACKAGES)
cover-html:
echo "mode: count" > coverage-all.out
$(foreach pkg,$(shell go list ./...),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
rm -rf coverage.out
go tool cover -html=coverage-all.out
# Lint
lint:
gometalinter --tests .
# Dependencies
deps:
go get -u github.com/PuerkitoBio/goquery
dev-deps:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
# Documentation
docs: docs-clean
cd docs-src && hugo
docs-clean:
rm -rf docs/*
docs-serve:
cd docs-src && hugo server -D
godoc-serve:
godoc -http=":9090"