-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 1.85 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
#! /usr/bin/make
SHELL = /bin/bash
BUILDTIME = $(shell date -u --rfc-3339=seconds)
GITHASH = $(shell git describe --dirty --always)
GITCOMMITNO = $(shell git rev-list --all --count)
SHORTBUILDTAG = v0.0.$(GITCOMMITNO)-$(GITHASH)
BUILDINFO = Build Time:$(BUILDTIME)
LDFLAGS = -X 'main.buildTag=$(SHORTBUILDTAG)' -X 'main.buildInfo=$(BUILDINFO)'
TEST_AMQP_URI ?= amqp://guest:guest@localhost:5672/
COVERAGE_PATH ?= .coverage
depend: deps
deps:
go get ./...
go mod tidy
version:
@echo $(SHORTBUILDTAG)
unit-test:
@go test -failfast -race -count=3 ./...
test:
@TEST_AMQP_URI=$(TEST_AMQP_URI) go test -failfast -v -race -count=2 -tags="rabbit" ./...
bench:
@TEST_AMQP_URI=$(TEST_AMQP_URI) go test -failfast -benchmem -run=^$ -v -count=2 -tags="rabbit" -bench . ./...
coverage:
@TEST_AMQP_URI=$(TEST_AMQP_URI) go test -failfast -covermode=count -tags="rabbit" -coverprofile=$(COVERAGE_PATH)
coverage-html:
@rm $(COVERAGE_PATH) || true
@$(MAKE) coverage
@rm $(COVERAGE_PATH).html || true
@go tool cover -html=$(COVERAGE_PATH) -o $(COVERAGE_PATH).html
coverage-browser:
@rm $(COVERAGE_PATH) || true
@$(MAKE) coverage
@go tool cover -html=$(COVERAGE_PATH)
update-readme-badge:
@go tool cover -func=$(COVERAGE_PATH) -o=$(COVERAGE_PATH).badge
@go run github.com/AlexBeauchemin/[email protected] -filename=$(COVERAGE_PATH).badge
# pkg.go.dev documentation is updated via go get updating the google proxy
update-godocs:
@cd ../regex-img; \
GOPROXY=https://proxy.golang.org go get -u github.com/danlock/rmq; \
go mod tidy
release:
@$(MAKE) deps
ifeq ($(findstring dirty,$(SHORTBUILDTAG)),dirty)
@echo "Version $(SHORTBUILDTAG) is filthy, commit to clean it" && exit 1
endif
@read -t 5 -p "$(SHORTBUILDTAG) will be the new released version. Hit enter to proceed, CTRL-C to cancel."
@$(MAKE) test
@$(MAKE) bench
@git tag $(SHORTBUILDTAG)
@git push origin $(SHORTBUILDTAG)