This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
45 lines (37 loc) · 1.63 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
NAMESPACE := logicmonitor
REPOSITORY := argus
VERSION ?= $(shell git describe --tags --always --dirty)
default: build
gofmt:
ifeq ($(shell uname -s), Darwin)
find pkg/ -type f | grep go | egrep -v "mocks|gomock" | xargs gofmt -l -d -s -w; sync
find pkg/ -type f | grep go | egrep -v "mocks|gomock" | xargs gofumpt -l -d -s -w; sync
find pkg/ -type f | grep go | egrep -v "mocks|gomock" | xargs gci -w; sync
find pkg/ -type f | grep go | egrep -v "mocks|gomock" | xargs goimports -l -d -w; sync
find cmd/ -type f | grep go | egrep -v "mocks|gomock" | xargs gofmt -l -d -s -w; sync
find cmd/ -type f | grep go | egrep -v "mocks|gomock" | xargs gofumpt -l -d -s -w; sync
find cmd/ -type f | grep go | egrep -v "mocks|gomock" | xargs gci -w; sync
find cmd/ -type f | grep go | egrep -v "mocks|gomock" | xargs goimports -l -d -w; sync
gofmt -l -d -s -w main.go; sync
gofumpt -l -d -s -w main.go; sync
gci -w main.go; sync
goimports -l -d -w main.go; sync
endif
build: gofmt
docker build --build-arg VERSION=$(VERSION) -t $(NAMESPACE)/$(REPOSITORY):$(VERSION) .
dev: gofmt
docker build --build-arg VERSION=$(VERSION) -t $(NAMESPACE)/$(REPOSITORY):$(VERSION) -f Dockerfile.dev .
lint: gofmt
docker build --build-arg VERSION=$(VERSION) -t $(NAMESPACE)/$(REPOSITORY):$(VERSION) -f Dockerfile.lint .
mockgen:
go generate ./...
test: mockgen lint
go test ./... -v -coverprofile=coverage.txt -race
go tool cover -html=coverage.txt -o coverage.html
devsetup:
which mockgen || go get github.com/golang/mock/mockgen
which gofumpt || go get mvdan.cc/gofumpt
which gci || go get github.com/daixiang0/gci
.PHONY: docs
docs:
cd docs/source && hugo