-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (42 loc) · 1.27 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
.PHONY: test build lint gen all clean update docker run format stats
PKG=github.com/deckarep/tips
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
#VERSION := $(shell git describe --tags --abbrev=0)
LDFLAGS=-ldflags "-X=github.com/deckarep/tips/pkg.AppVersion=$(VERSION)"
COVER=--cover --coverprofile=cover.out
# Define the default goal. When you run "make" without argument, it will run the "all" target.
default: all
# Capture additional arguments which can optionally be passed in.
ARGS ?=
stats:
git diff --stat HEAD~$(ARGS) HEAD
update:
go get -u
go mod tidy
clean:
rm -f *db.bolt
format:
go fmt ./...
# Test the code.
test:
go test -v ./... --race $(COVER) $(PKG)
go tool cover -html=cover.out
go tool cover -func cover.out | grep statements
# Lint the code.
lint:
golangci-lint run
# Run any code generation on this step.
gen:
go run testmode/gen_mock/main.go > testmode/devices.json
docker:
docker build -t docker-tips .
run:
docker run -v .:/home/tipsuser docker-tips:latest
# Build the project: run the linter and then build.
build: lint
go build $(LDFLAGS)
@echo "Build: Successful"
# Run all steps: build and then run the application.
# To forward args optionally set ARGS like: make ARGS="--flag1=value1 --flag2=value2"
all: build
./tips $(ARGS)