-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (40 loc) · 1.31 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
#! /usr/bin/make
SHELL = /bin/bash
BUILDTIME = $(shell date -u --rfc-3339=seconds)
GITHASH = $(shell git describe --dirty --always --tags)
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)'
COVERAGE_PATH ?= .coverage
depend: deps
deps:
go get ./...
go mod tidy
go mod vendor
version:
@echo $(SHORTBUILDTAG)
build:
CGO_ENABLED=0 go build -mod=vendor -ldflags "$(LDFLAGS)" -o ./bin/searmage ./cmd/searmage
build_c:
CGO_ENABLED=1 go build -mod=vendor -ldflags "$(LDFLAGS)" -o ./bin/searmage_cgo ./cmd/searmage
unit-test:
@go test -race -count=3 ./...
test:
@go test -v -race -count=2 ./...
bench:
@go test -benchmem -run=^$ -v -count=2 -bench . ./...
coverage:
@go test -covermode=count -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